Answer the question
In order to leave comments, you need to log in
LeaFlet + LeaFlet.search + GeoJSON, search across multiple marker sets?
Hello dear community.
Trying to figure out " LeaFlet JS". With the output of the map itself and markers, everything is clear, but with LeaFlet.search I can’t solve problems.
Two sets of markers are superimposed on the map, in turn, I get them from a GeoJSON file
GeoJSON example
{
"type": "Feature",
"properties": {
"name": "Что-то этакое",
"category": "категория 1",
"popupContent": "Какое-то описание",
"icon": "green"
},
"geometry":{
"type": "Point",
"coordinates": [37.60869026184082,48.8507382697713]
}
}
function onEachFeature(feature, layer) {
if (feature.properties && feature.properties.popupContent) {
layer.bindPopup(feature.properties.popupContent);
}
};
function setMarkerIcon(feature, latlng) {
var marker = new L.Marker(latlng, {icon: set_icon(feature.properties.icon)});
return marker
}
function getMarkers(json_url) {
var sLayer = new L.GeoJSON.AJAX(json_url, {
onEachFeature: onEachFeature,
pointToLayer: setMarkerIcon,
});
return sLayer
}
markersLayer = getMarkers('ololo.olol/data.geojson');
map.addControl( new L.Control.Search({
layer: markersLayer,
propertyName: 'name',
}) );
markersLayer0 = getMarkers('ololo.olol/data0.geojson');
markersLayer1 = getMarkers('ololo.olol/data1.geojson');
groupLayer = new L.LayerGroup();
map.addControl( new L.Control.Search({
layer: groupLayer ,
propertyName: 'name',
}) );
map.addLayer(groupLayer );
groupLayer .addLayer(markersLayer0);
groupLayer .addLayer(markersLayer1);
Answer the question
In order to leave comments, you need to log in
The problem was solved, the author took the pull request.
Who cares, look into the turnip and library examples.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question