Search for markers in a markercluster group Leaflet-MarkerCluster

南楼画角 提交于 2019-12-13 15:46:35

问题


I am using Leaflet.markercluster to cluster my markers in my Mapbox Map. The markers are to be populated using a json file. All I need is a search feature which can popup the requisite marker based on search string. I got to know about Leaflet-search, but am unable to integrate it with my code. How should I go about this?


回答1:


Simply iterate through your layer group (like your Marker Cluster Group), e.g. using eachLayer(fn), test against the marker attributes, and if you find your target marker, get the map to zoom and/or pan to it using markercluster zoomToShowLayer(targetMarker) method.



来源:https://stackoverflow.com/questions/41631492/search-for-markers-in-a-markercluster-group-leaflet-markercluster

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!