简体   繁体   中英

how to remove marker on mapbox project

I want to remove all markers from my mapbox project. I didn't initialize marker on map via javascript . It's from my mapbox project/api . I just make marker on 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:

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();
// or in short without declaring a separate var:
map.featureLayer.clearLayers();

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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