leaflet-search + leaflet-markercluster
Hi, I would like to use leaflet-search alongside https://github.com/Leaflet/Leaflet.markercluster/
This doesn't immediately work. Could you maybe give me a heads up on how to get it working?
Thanks!
The latest commit should work for markercluster too as it supports searching groups recursively.
Thanks! I can't immediately figure out how the recursive search works. Maybe we could work together to make a little example for on your http://labs.easyblog.it/maps/leaflet-search/ ?
@bhaskarvk searching groups recursively.. but what type of group?
Any instance of L.LayerGroup or L.FeatureGroup or L.GeoJSON can be recursively searched by the PR that you merged a while ago.
@jhpoosthoek Heb je dit ooit nog voor elkaar gekregen? Ik loop namelijk tegen hetzelfde probleem aan.
Can't figure it out. The search button doesn't show up. What am i doing wrong?
Code:
<script type="text/javascript">
var tiles = L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
maxZoom: 18,
attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors, Points © 2012 LINZ'
}),
latlng = L.latLng(52.370216, 4.895168);
var map = L.map('map', {center: latlng, zoom: 3, layers: [tiles]});
var markers = L.markerClusterGroup({ chunkedLoading: true, spiderfyOnMaxZoom: true });
for (var i = 0; i < addressPoints.length; i++) {
var a = addressPoints[i];
var title = a[2];
var marker = L.marker(new L.LatLng(a[0], a[1]), { title: title,
autoClose: false,
autoPan: false
});
marker.bindPopup(title);
markers.addLayer(marker);
}
map.addLayer(markers);
var controlSearch = new L.Control.Search({
position:'topright',
layer: markers,
initial: false,
zoom: 12,
marker: false
});
map.addControl( controlSearch );
</script>
Hi @JackNL85, no indeed, I didn't get it to work yet. It's still on my list to search further for a solution but didn't find time yet. @bhaskarvk could you maybe help out here?
I have the mobile example working with Markercluster, but struggling on something else. Trying to add an event listener that is triggered when a search location is found. This is not working..
window.addEventListener("search:locationfound", showresults);