I am wondering how to make the GeoJSON search more efficient. I would like to get the search result from more than 1 layer in GeoJSON.
My code is (I attached one of two GeoJSON examples):
var test = [{
"type": "Feature",
"properties": {
"Title": "Waterbeach Church",
"Head": "Chapel Street",
"Description": "Parish community"
},
"geometry": {
"type": "Point",
"coordinates": [
0.192763,
52.263692
]
}
}];
var geojsonMarkerOptions2 = {
radius: 5,
fillColor: "#ffc34d",
color: "#1a1100",
weight: 1,
opacity: 1,
fillOpacity: 0.4
};
var church = L.geoJSON(test, {
pointToLayer: function (feature, latlng) {
return L.circleMarker(latlng, geojsonMarkerOptions2);
},
onEachFeature: function (feature, layer) {
layer.bindPopup('<h1><u><font color="red">'+feature.properties.Title+'</h1></u></font><h2>Address: '+feature.properties.Head+'</h2><p>'+feature.properties.Description+'</p><a>'+feature.properties.URL+'</a>');
}
}).addTo(map);
Afterwards, I am using Leaflet GeoJSON control search, where I want to search between both multiple geoJSON layers (already solved using this link:
L.Control.Search: Using looping for searching data on Leaflet
and for their property features. I am interested in search for more than 1 properties.
When I place another value in "propertyName", then query is redirected to this 2nd value instead of 1st or both.
L.control.search({
layer: L.layerGroup ([sitis, church]),
initial: false,
propertyName: 'Title', 'Head' // Specify which property is searched into.
})
.addTo(map);
Can I have something like: propertyName: L.GeoJSON.PropertyGroup (['Title', 'Head', 'Description]),
Or is there another reasonable solution for this issue?