I have an issue to access at some variables outside an anonymous function called in another function as parameter. This is the code :
clicked(){
var lat;
var lng;
this.map.on('click',function(e) {
var coordonneesDiv = document.getElementById("coordonnees");
lat = e.latlng.lat;
lng = e.latlng.lng;
//var zoom = 18;
coordonneesDiv.innerHTML = "lat : " + lat + "<br/>" + "long : "+ lng;
//Zoom lors d'un click
//
//this.map.setView([lat, lng], zoom);
});
this.getData(lat,lng);
}
Is it possible to modify the lat and lng variables inside the anonymous function to use them after (in getData).
Thanks for you answers
Aucun commentaire:
Enregistrer un commentaire