1

I Update the position of the marker through the localization function.

However, the user might wish to zoom to a differed level, but when the position maker gets updated the map always zooms back to the value set in the locate maxZoom option.

Is there a way to change the maxZoom value dynamically depending on the zoom level the user has chosen?

var gpsMarker = null;
    var gpsCircleMarker;

    function onLocationFound(e) {
        var radius = e.accuracy / 2;
        var popupContent = "You are within " + radius + " meters from this point";

    if (gpsMarker == null) {
        gpsMarker = L.marker(e.latlng, {icon: IsyUserIcon}).addTo(map);
        gpsMarker.bindPopup(popupContent).openPopup();
        gpsCircleMarker = L.circle(e.latlng, radius).addTo(map);
    }
    else {
        gpsMarker.getPopup().setContent(popupContent);   
        gpsMarker.setLatLng(e.latlng);
        gpsCircleMarker.setLatLng(e.latlng);
        gpsCircleMarker.setRadius(radius);
        }
    }

map.on('locationfound', onLocationFound);

map.locate({setView: true, watch: true, maxZoom: 16});
  • How can you expect somebody will answer your question if you don't even bother to comment, much less upvote or accept the answer to your previous question gis.stackexchange.com/questions/342071/…, the result of which you are obviously using. – TomazicM Nov 18 at 7:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.