admin管理员组文章数量:1434934
Example I have create 6 markers on and after zoom change on the current view of map I have 3 markers So how can I get list of current onscreen markers list after zoom change?
map.on('zoomend', function(e) {
// want to get current onscreen markers list
});
Example I have create 6 markers on and after zoom change on the current view of map I have 3 markers So how can I get list of current onscreen markers list after zoom change?
map.on('zoomend', function(e) {
// want to get current onscreen markers list
});
Share
Improve this question
edited Dec 26, 2019 at 12:01
adiga
35.3k9 gold badges65 silver badges87 bronze badges
asked Dec 26, 2019 at 11:46
ashu0047ashu0047
211 silver badge3 bronze badges
2 Answers
Reset to default 4Here's one way of doing it..... iterate the layers on the map, check each one for being a marker and then for being within the current bounds.
function getVisibleMarkers(map) {
var markerList = [];
map.eachLayer(function(layer) {
if ((layer instanceOf L.Marker) && (map.getBounds().contains(layer.getLatLng())){
markerList.push(layer);
};
};
return markerList;
}
Loop on your 6 Markers.
For each Marker, check if it is within current map view port: Check if marker is in view (map) - mapbox
本文标签: javascriptIs it possible to get list of current markers on leaflet MapStack Overflow
版权声明:本文标题:javascript - Is it possible to get list of current markers on leaflet Map? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745630597a2667250.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论