leaflet-search icon indicating copy to clipboard operation
leaflet-search copied to clipboard

leaflet-search + leaflet-markercluster

Open jhpoosthoek opened this issue 8 years ago • 7 comments

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!

jhpoosthoek avatar Jun 30 '17 14:06 jhpoosthoek

The latest commit should work for markercluster too as it supports searching groups recursively.

bhaskarvk avatar Aug 22 '17 19:08 bhaskarvk

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/ ?

jhpoosthoek avatar Aug 23 '17 16:08 jhpoosthoek

@bhaskarvk searching groups recursively.. but what type of group?

stefanocudini avatar Aug 30 '17 12:08 stefanocudini

Any instance of L.LayerGroup or L.FeatureGroup or L.GeoJSON can be recursively searched by the PR that you merged a while ago.

bhaskarvk avatar Sep 14 '17 20:09 bhaskarvk

@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: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors, Points &copy 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>

JackNL85 avatar May 24 '18 14:05 JackNL85

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?

jhpoosthoek avatar May 24 '18 16:05 jhpoosthoek

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);

knaggs avatar Aug 04 '18 13:08 knaggs