Get started with leaflet-locatecontrol CDN
MIT licensed
Plugin The Leaflet.locatecontrol adds locate button for user location in Leaflet maps.
Tags:- leaflet
- maps
- mobile
Stable version
Copied!
How to start using leaflet-locatecontrol CDN
// Include Leaflet and LocateControl libraries
L.Icon.Default.imagePath = 'https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.7.1/images/';
// Create a map in the 'mapid' element
const map = L.map('mapid').setView([51.505, -0.09], 13);
// Include LocateControl library from CDN
L.control.locate({
position: 'topright',
flyTo: false,
watchUserLocation: false
}).addTo(map);
// Add a marker at the user's location
map.on('locationfound', function(e) {
const marker = L.marker(e.latlng).addTo(map);
marker.bindPopup('You are here').openPopup();
});
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
All versions
0.33.0
0.33.1
0.34.0
0.35.0
0.37.0
0.39.0
0.40.0
0.41.0
0.42.0
0.43.0
0.44.0
0.45.0
0.45.1
0.46.0
0.47.0
0.48.0
0.50.1
0.51.0
0.52.0
0.53.0
0.55.0
0.56.0
0.57.0
0.58.0
0.59.0
0.60.0
0.61.0
0.62.0
0.63.0
0.64.0
0.65.0
0.65.1
0.65.2
0.66.0
0.66.1
0.66.2
0.67.0
0.68.0
0.69.0
0.70.0
0.71.0
0.71.1
0.72.0
0.72.2
0.73.0
0.74.0
0.74.1
0.75.0
0.76.0
0.76.1
0.77.0
0.78.0
0.79.0
0.80.0
0.81.0
0.81.1
*** 0.82.0