Would like to start my leaflet map without any features displayed on start. The feature should not be displayed before a location is found via my search.control.
I started with
// first "invisible" icon
var smallIcon = new L.Icon({
iconUrl: 'mypicture',
iconRetinaUrl: 'mypicture',
iconSize: [0.00, 0.00],
iconAnchor: [0, 0],
popupAnchor: [1, -34],
shadowSize: [0, 0]
});
// second "visible" icon
var smallIcon2 = new L.Icon({
iconUrl: 'mypicture',
iconRetinaUrl: 'mypicture',
iconSize: [25, 41],
iconAnchor: [12, 41],
popupAnchor: [1, -34],
shadowUrl: 'mypicture',
shadowSize: [41, 41]
});
// adding geojson and display feautures with "invisible" marker
var marker;
var json_AlleJSON = new L.geoJson(myjson, {
onEachFeature: pop_All,
pointToLayer: function (feature, latlng) {
marker = new L.marker(latlng, {icon: smallIcon});
return marker;
}
});
And to change the icon when location is found:
// changing the icon to "visible"
searchControl.on('search_locationfound', function(e) {
sidebar.hide();
e.layer.setIcon(smallIcon2);
});
This actually works BUT the problem I got: even by reducing the iconSize to 0.0, the map interacting gets so slow because of loading an image for every feature (my json contains about 100 entries).
I tried to solve this by leaving the iconUrl empty but this didn't work.
Any ideas?