问题
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