Commit f89a92e7 authored by Sp3r4z's avatar Sp3r4z
Browse files

[JS] Add circle on click + remove autozoom

parent 8c85546f
var theMap = L.map('map').setView([46.415,1.461], 6);
var theMap = L.map('map').setView([46.415,1.461], 6),
circle = null;
L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
attribution: '© OpenStreetMap contributors',
maxZoom: 19,
}).addTo(theMap)
//L.circle([47.4739884, -0.5515588], {radius: 100000}).addTo(theMap);
L.Control.geocoder({
defaultMarkGeocode: false
})
.on('markgeocode', function(e) {
var center = e.geocode.center
L.circle([center.lat, center.lng], {radius: 100000}).addTo(theMap);
theMap.setView(new L.LatLng(center.lat, center.lng), 9);
if(circle != null) circle.removeFrom(theMap)
circle = L.circle([center.lat, center.lng], {radius: 100000})
circle.addTo(theMap);
})
.addTo(theMap)
theMap.on('click', function(e) {
if(circle != null) circle.removeFrom(theMap)
circle = L.circle([e.latlng.lat, e.latlng.lng], {radius: 100000})
circle.addTo(theMap);
});
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment