'Leaflet search options for multiple markers
I have a leaflet project with around 150 points that should be displayed. The idea is to show the progress of a project, therefore there are 257 symbols which could be assigned to a point. And there is also a pop up which display additional infos. The "database" is an excel sheet which gets updated regularly. So I have a python script which updates my leaflet script. This part is running fine and does what it should.
Current code
var map = L.map('map').setView([47.0, 9.0], 13);
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
maxZoom: 19,
attribution: '© <a href="https://openstreetmap.org/copyright">OpenStreetMap contributors</a>'
}).addTo(map);
// show the scale bar on the lower left corner
L.control.scale({imperial: false, metric: true}).addTo(map);
var symb_A2_22_1 = L.icon({
iconUrl: 'folder/KB-11.png',
iconSize: [42, 20]
});
var A2_22_1 = L.marker([47.4678,8.7049],{icon: symb_A2_22_1}).addTo(map)
A2_22_1.bindPopup("<b>A2-22-1</b><br>x<br>PWD<br>x<br>x")
var symb_A2_22_100 = L.icon({
iconUrl: 'folder/RS-11.png',
iconSize: [42, 20]
});
var A2_22_100 = L.marker([47.4708,8.7059],{icon: symb_A2_22_100}).addTo(map)
A2_22_100.bindPopup("<b>A2-22-100</b><br>x<br>PWD<br>x<br>x)
Now I want to add a search option to search by the name of the point. I already searched for solutions. I think I have to bring all my points into one layer. So the here (Putting multiple markers in Layer Group )presented solution seems to be a good idea (create markers, add to layer, and then add the layer to the map and not the single markers).
However how I get the popup content and my custom symbol into the list?
Or do you have another solution to make my markers searchable?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
