I have a map with a single GeoJSON layer that I referenced in my script (using the AJAX plugin). Now I am trying to add search functionality to the map so that the user can search for features by name. The plugin I am using is the Leaflet Search plugin.
However, I cannot get the search to perform, as it's giving me the "Location not found" error, whenever I type text into the search box. Here is my code:
searchlayer = L.geoJSON.ajax('data.json').addTo(map);
map.addControl(new L.Control.Search({layer:searchlayer});
What am I doing wrong here? I assume that I'm not properly linking the layer and the field to be searched to the search control, but how do I do that?
Found that the issue was not adding the option for the control to search the geojson attribute. The default column that the search button works on is "title". I added the option of propertyName: 'Location' to L.Control.Search and it works perfect now!