我有一些 geojson 形状,我要传递给Mapbox 静态地图 API。一些形状是折线,另一些是圆表示为具有半径属性的点,例如:
{
"type": "Feature",
"properties": {
"radius": 500
},
"geometry": {
"type": "Point",
"coordinates": [
30.5,
50.5
]
}
}
Run Code Online (Sandbox Code Playgroud)
这些被渲染为带有标记的点。有什么办法可以让一个点渲染为以该点为中心的特定半径的圆?
小智 0
您可以使用图层类型:圆形将点显示为圆形。然后,您可以使用表达式从 geojson 属性获取半径:检查JS Fiddle
map.addLayer({
'id': 'demo',
'type': 'circle',
'source': 'points',
'paint': {
// use get expression to get the radius property. Divided by 10 to be able to display it
'circle-radius': ['/',['get', 'radius'],10],
'circle-color': "blue"
}
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
794 次 |
| 最近记录: |