Commit ee19fd4c authored by Sp3r4z's avatar Sp3r4z
Browse files

Add location marker

parent 22ec8981
......@@ -3,11 +3,17 @@ getPostcodeByName = name => {
return departements.filter( dep => {
return dep.nom == name
})
},
createMarker = (lat,lng) => {
if(marker != null) marker.removeFrom(theMap)
marker = L.marker([lat, lng])
marker.addTo(theMap)
}
let theMap = L.map('map').setView([46.415,1.461], 6),
circle = null,
departement = null
departement = null,
marker = null
L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap contributors</a>',
......@@ -24,6 +30,8 @@ L.Control.geocoder({
circle = L.circle([center.lat, center.lng], {radius: 100000})
circle.addTo(theMap);
createMarker(center.lat,center.lng)
let postCode = e.geocode.properties.address.postcode,
departementRef = null
if(postCode != null) {
......@@ -49,5 +57,6 @@ theMap.on('click', function(e) {
if(departement != null) departement.removeFrom(theMap)
if(circle != null) circle.removeFrom(theMap)
circle = L.circle([e.latlng.lat, e.latlng.lng], {radius: 100000})
createMarker(e.latlng.lat,e.latlng.lng)
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