在 markercluster 组 Leaflet-MarkerCluster 中搜索标记
Search for markers in a markercluster group Leaflet-MarkerCluster
我正在使用 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,但无法将其与我的代码集成。我该怎么办?
只需遍历您的图层组(例如您的标记群集组),例如使用 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)
方法。
我正在使用 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,但无法将其与我的代码集成。我该怎么办?
只需遍历您的图层组(例如您的标记群集组),例如使用 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)
方法。