【问题标题】:Can you draw a circle on a mapbox static map?你能在mapbox静态地图上画一个圆圈吗?
【发布时间】:2015-08-22 02:44:18
【问题描述】:

我有一些geojson 形状要传递给Mapbox static maps API。有些形状是折线,有些是圆,表示为具有半径属性的点,例如:

    {
        "type": "Feature",
        "properties": {
            "radius": 500
        },
        "geometry": {
            "type": "Point",
            "coordinates": [
                30.5,
                50.5
            ]
        }
    }

这些被渲染为带有标记的点。有什么办法可以让一个点渲染为以该点为中心的一定半径的圆?

【问题讨论】:

  • 你找到解决办法了吗?
  • 您找到解决方案了吗?

标签: mapbox


【解决方案1】:

您可以使用 layer type : circle 将点显示为圆形。然后,您可以使用表达式从 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"
            }
        });

【讨论】:

  • 问题是关于静态地图API
猜你喜欢
  • 2011-11-11
  • 2016-07-30
  • 1970-01-01
  • 2011-04-15
  • 1970-01-01
  • 2014-11-15
  • 2013-05-05
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多