在标记群集组Leaflet-MarkerCluster中搜索标记 [英] Search for markers in a markercluster group Leaflet-MarkerCluster

查看:479
本文介绍了在标记群集组Leaflet-MarkerCluster中搜索标记的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Leaflet.markercluster 将我的标记聚集在我的传单搜索,但是无法将其与我的代码集成.我该怎么办?

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?

推荐答案

只需遍历您的图层组(例如标记群集组"),例如使用 eachLayer(fn) ,对标记属性进行测试,如果您找到目标标记,使用markercluster zoomToShowLayer(targetMarker) 方法.

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.

这篇关于在标记群集组Leaflet-MarkerCluster中搜索标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆