- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想使用 GeoJSON 数据在 mapbox map 上显示自定义标签,我在功能 properties
下添加了 name
和 color
我想显示为一个区域的多边形填充颜色,我不知道该怎么做,我搜索了很多但在这个主题上一无所获,我是 MapBox 的新手需要你的帮助:
这是代码
var map = new mapboxgl.Map({
container: 'map', // container id
style: 'mapbox://styles/mapbox/streets-v9', // stylesheet location
center: [55.2324,25.073], // starting position
zoom: 12 // starting zoom
});
// Draw map
var draw = new MapboxDraw({
displayControlsDefault: false,
controls: {
polygon: false,
trash: false
}
});
map.addControl(draw);
// Add zoom and rotation controls to the map.
map.addControl(new mapboxgl.NavigationControl());
var featureCollection = {
"type": "FeatureCollection",
"features": [
{
"type":"Feature",
"geometry":{
"type":"Polygon",
"coordinates":[
[
[
53.34234777435083,
24.03841558494339
],
[
53.63384239941877,
23.980642073807147
],
[
53.87583793720404,
24.01330148955786
],
[
53.67509163882116,
23.678780532068288
],
[
53.691591334582085,
23.436787672921128
],
[
53.13885152669846,
23.55531902255817
],
[
53.136101577392935,
23.980642073807147
],
[
53.34234777435083,
24.03841558494339
]
]
]
},
"properties":{
"id":1,
"name":"East Zone",
"color":"#ccccff",
"is_shutdown":false,
"is_active":true
}
},
{
"type":"Feature",
"geometry":{
"type":"Polygon",
"coordinates":[
[
[
54.41277432573249,
24.17109802219355
],
[
54.40221419428706,
23.93479580896283
],
[
54.40190486287914,
23.752296533243648
],
[
54.24386990803268,
23.813378685606605
],
[
54.12084722599417,
24.09616522759087
],
[
54.41277432573249,
24.17109802219355
]
]
]
},
"properties":{
"id":2,
"name":"West Zone",
"color":"#ffcc33",
"is_shutdown":false,
"is_active":true
}
},
{
"type":"Feature",
"geometry":{
"type":"Polygon",
"coordinates":[
[
[
55.01084972481446,
24.07274717129389
],
[
55.04794143668033,
23.858563232484837
],
[
54.967647759445896,
23.5905998890601
],
[
54.901748431837575,
23.38814119539755
],
[
54.58976976470866,
23.47439441289948
],
[
54.41317073001387,
23.67920953874405
],
[
54.43980120450599,
24.219099932016256
],
[
54.72318029018409,
24.176836888624475
],
[
55.01084972481446,
24.07274717129389
]
]
]
},
"properties":{
"id":3,
"name":"South Zone",
"color":"#07ac25",
"is_shutdown":false,
"is_active":true
}
}
]
};
var bbox = turf.bbox(featureCollection);
map.on('load', function () {
featureCollection.features.forEach(function (feature) {
draw.add(feature);
})
});
map.fitBounds(bbox, { padding: 40});
最佳答案
您需要定义代表多边形标签的点并使用符号层。生成标签点的一种方法是 https://github.com/mapbox/polylabel
关于javascript - 如何使用 GeoJSON 在 mapbox map 多边形上显示标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48760501/
刚刚通过 cocoapods 安装了 MapboxGL。我在我的 ViewController 中初始化它,就像给出的示例一样: @IBOutlet weak var mapViewWrapper:
有没有办法更改mapbox-gl-js图标图像的颜色? 取自https://www.mapbox.com/mapbox-gl-js/example/geojson-markers/的代码不会将标记颜色
我正在重写来自 Mapbox.js 的路线规划 Web 应用程序至 Mapbox GL JS图书馆。 几乎所有功能都已实现,但由于 的滞后、不流畅的动画和普遍的缓慢,它几乎无法使用。 map 层 .
我的问题是,如何从 MapBox 服务获取指定路线的海拔剖面图。 在输入中,我们将路径/路线作为坐标数组(纬度、经度)。作为结果,我们想要获得坐标对的数组 - 高程。 如果高程数据的分辨率高于提供的路
如何检查 map 上是否显示了 Mapbox 栅格图层? 我的目标是停止加载动画。我知道我可以检查 map 本身是否准备就绪。 map.on('ready', someFunction) 除了针对特定
https://codepen.io/m12n/pen/XWNRZMg?editors=0010 mapboxgl.accessToken = "pk.eyJ1IjoiaW50ZWxsaWdlbm
我想在我的 map 上添加一个自定义标记。我正在使用 mapbox gl 脚本。 我发现与此主题相关的唯一文档是这个 https://www.mapbox.com/mapbox-gl-js/examp
我需要mapbox gl的某种Google map “空闲”事件。 当触发每个事件并且 map 停止放大/缩小拖动等并且每个图层都已加载时, map 处于空闲状态。 我必须使用此代码 map.on
有没有办法在离线设置中使用 Mapbox GL(询问 JS 和 native )?使用 MBTiles,您可以使用 MBTiles 文件或提取光栅图像。我想知道是否有任何类似的东西可以让 Mapbox
我有一个矩形,需要用正方形填充它。我找到中心线并想沿着该线放置方 block 。但是有没有简单的方法可以在 mapboxgl 中与 turfjs 等其他库一起绘制正方形?就像设置正方形的中心和边长并获
我对 MapBox 中的标记有疑问。我有多个标记,我想对其进行聚类。我使用 MapBox SDK for android。请帮我。非常感谢。 我在 Google Service Map Android
我建立了一个新的 react-native 项目并使用 yarn add @react-native-mapbox-gl/maps 添加了 Mapbox。 这个 Notice, that if you
我建立了一个新的 react-native 项目并使用 yarn add @react-native-mapbox-gl/maps 添加了 Mapbox。 这个 Notice, that if you
是否可以获取对应于 Mapbox 缩放级别的仪表列表?就像下面从 Bing map 中列出的一样:here 最佳答案 是的,就在 Mapbox 文档中: https://docs.mapbox.com
由于 Mapbox GL 文档没有讨论任何关于向 LngLat 坐标添加简单标记的内容,而且实际上只有关于如何添加自定义标记的文档,我希望有人能告诉我您应该如何获取 Mapbox-gl.js实际上为传
我有一个图层将 geojson 源中的点要素渲染为圆圈。以下是其中一项功能的示例: { type: 'Feature', properties: { color: 'red',
如何使用嵌套值以使用 case == 运算符?就像是: this.map.setPaintProperty("somelayer", "fill-color", ["case",
我正在使用 mapbox.js 制作带有地点的 map 。我只是想让 map 返回点击的正确坐标,我使用以下代码成功管理: map.on('click', function(e) { var
我在 style.load 事件上重绘图层并移除图层 map.on('style.load', function() { loadByBounds(tempBou
我正在努力实现更好的文本大小调整,相信通过插值,我也许能够将我当前的文本标签更新为更高效的格式。目前我们正在创建“静态文本”,本质上我们获得了特定缩放级别的理想文本大小,然后在每个缩放级别使用停止缩放
我是一名优秀的程序员,十分优秀!