Friday, April 29, 2022

note to self: leaflet

this post explains how to get leaflet to show your current location:

function onLocationFound(e) {

  var radius = e.accuracy / 2;

  L.marker(e.latlng).addTo(map)

    .bindPopup("You are within " + radius + " meters from this point").openPopup();

  L.circle(e.latlng, radius).addTo(map);

}


map.on('locationfound', onLocationFound);

map.locate({setView: true, watch: true, maxZoom: 8})

No comments:

Post a Comment