I combined two plugins: Leaflet search and cluster. But I want search points and automatically move to a location and view its popup. But it is not working, I can search, move to location but there's no automatic popup.
var markers = L.markerClusterGroup();
var geoJsonLayer = L.geoJson(data, {
onEachFeature: function (feature, layer, marker) {
layer.bindPopup( "ID vzorku " + feature.properties.catalogNumber +
"</br> nadmořská výška "+ feature.properties.elevation + " m n.m."+
"<br> průměrná roční teplota "+feature.properties.t_year +"°C"+
"<br> roční úhrn srážek "+feature.properties.preci2 +" mm " );
}
});
markers.addLayer(geoJsonLayer);
map.addLayer(markers);
//vytvoření panelu pro vyhledávání
var searchControl = new L.Control.Search({
layer: markers,
propertyName: 'catalogNumber', // pole přes které se vyhledává
circleLocation: true,
marker: false,
moveToLocation: function(latlng, catalogNumber, map) { console.log(latlng); map.setView(latlng, 10); }
});
searchControl.on('search:locationfound', function(e) {
//console.log('search:locationfound', );
e.layer.openPopup("OBJECTID");
}).on('search:collapsed', function(e) {
featuresLayer.eachLayer(function(layer) { //restore feature color
featuresLayer.resetStyle(layer);