【问题标题】:get coordinates of a marker symbol in mapbox-gl-js and center on it在 mapbox-gl-js 中获取标记符号的坐标并以它为中心
【发布时间】:2016-01-16 22:39:19
【问题描述】:

我在地图上有这个符号

map.addLayer({
    "id": "home",
    "type": "symbol",
    "source": "property",
    "interactive": true,
    "layout": {
        "icon-image": "rocket-15",
    }
});

我想放大这个标记并以它为中心。

到目前为止,我已经尝试过:

map.featuresIn({ layer: 'home' }, function(err, features) {
    console.log(features);
    map.flyTo({ center: features[0].geometry.coordinates,zoom: 11 });
});

我省略了坐标参数,所以我直接引用它(如 API 中所述)。但是,“功能”是空的,我永远不会飞

【问题讨论】:

    标签: marker mapbox-gl-js


    【解决方案1】:

    featuresIn 默认情况下不返回要素的几何图形。为此,您必须包含 includeGeometry: true 参数。

    你会发现this example很有帮助!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-12-10
      • 2022-10-17
      • 1970-01-01
      • 2019-10-29
      • 1970-01-01
      相关资源
      最近更新 更多