This is a static archive of our old OpenStreetMap Help Site. Please post any new questions and answers at community.osm.org.

custom marker in map

0

hi i use web map and i need to show current location like https://www.openstreetmap.org/ blue svg icon can help me ? thanks.

my script:

    <script>
    var map = L.map('map').fitWorld();
    L.tileLayer('https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token=token', {
        maxZoom: 18,

        id: 'mapbox.streets'
    }).addTo(map);

    function onLocationFound(e) {
        var radius = e.accuracy / 2;

        L.marker(e.latlng).addTo(map);              ;
        map.setZoom( 18 );
        L.circle(e.latlng, radius).addTo(map);
    }

    function onLocationError(e) {
        alert(e.message);
    }

    map.on('locationfound', onLocationFound);
    map.on('locationerror', onLocationError);

    map.locate({setView: true, maxZoom: 16});

</script>

asked 07 Dec '19, 13:15

eurus's gravatar image

eurus
11335
accept rate: 0%

edited 08 Dec '19, 06:50

Source code available on GitHub .