Make markers layer permanent leaflet

151 views Asked by At

Simple enough to add markers to leaflet map using onClick but every time I refresh the markers have been removed and I have to start over. How do I make the markers permanent so that on subsequent refresh I can add to them? Here is the current code:

map.on('click', onMapClick);  
    
var layerGroup= new L.layerGroup().addTo(map);
    
function onMapClick(e){
    var layer = L.marker(e.latlng).addTo(layerGroup); 
}
    
    
var layerGroup=L.layerGroup().addTo(map);
0

There are 0 answers