简体   繁体   English

如何在mapbox项目上删除标记

[英]how to remove marker on mapbox project

I want to remove all markers from my mapbox project. 我想从我的mapbox项目中删除所有标记。 I didn't initialize marker on map via javascript . 我没有通过javascript初始化地图上的标记。 It's from my mapbox project/api . 来自我的mapbox project/api I just make marker on mapbox.com/projects . 我只是在mapbox.com/projects上做标记。 I just try these but it didn't work. 我只是尝试这些,但没有用。 here is the screenshot of my project: 这是我的项目的屏幕截图: 屏幕截图

featureLayer.clearLayers();
L.mapbox.markerLayer().clearLayers();
markerLayer.clearLayers();

How can I remove all markers from my map. 如何从地图上删除所有标记。

Assuming you've initialized your L.mapbox.Map with a project ID (Assuming, since you've shared completely no code in which we can see how you setup is) and thus the L.mapbox.featureLayer is being created for you, you can get a reference to your featureLayer from your map instance like this: 假设您已经使用项目ID初始化了L.mapbox.Map (假设由于您完全没有共享任何代码,我们可以看到您的设置方式),因此正在为您创建L.mapbox.featureLayer ,您可以从地图实例中获取对featureLayer的引用,如下所示:

var map = L.mapbox.map('map', 'your-project-id');

var featureLayer = map.featureLayer;

When you got a reference to your featureLayer you can use the clearLayers method: 引用featureLayer后,可以使用clearLayers方法:

featureLayer.clearLayers();
// or in short without declaring a separate var:
map.featureLayer.clearLayers();

我找到了类似的链接:通过此选项https://www.mapbox.com/help/remove-feature-editor/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM