更新经纬度Leaflet Vue js
Update latitude and longitude Leaflet Vue js
const getAgenApi = () => {
this.longitudeNow = parseFloat(106.105104103);
this.latitudeNow = parseFloat(-123.123);
// other code...
};
mymap.on("geosearch/showlocation", function (result) {
console.log(result);
// Remove marker
marke.forEach(function (maker) {
mymap.removeLayer(maker);
});
this.longitudeNow = result.location.x;
this.latitudeNow = result.location.y;
// Draw updated locations!
GetAgenApi();
});
任何人都可以修复此代码以更新纬度和经度吗?
正如 Pi 和 Mash 在评论中所写,您的变量超出了范围。
您必须转换 mymap.on
回调才能使用箭头函数:
mymap.on("geosearch/showlocation", (result) => {
// Now this.longitudeNow points valid variable
this.longitudeNow = result.location.x;
// ...
});
const getAgenApi = () => {
this.longitudeNow = parseFloat(106.105104103);
this.latitudeNow = parseFloat(-123.123);
// other code...
};
mymap.on("geosearch/showlocation", function (result) {
console.log(result);
// Remove marker
marke.forEach(function (maker) {
mymap.removeLayer(maker);
});
this.longitudeNow = result.location.x;
this.latitudeNow = result.location.y;
// Draw updated locations!
GetAgenApi();
});
任何人都可以修复此代码以更新纬度和经度吗?
正如 Pi 和 Mash 在评论中所写,您的变量超出了范围。
您必须转换 mymap.on
回调才能使用箭头函数:
mymap.on("geosearch/showlocation", (result) => {
// Now this.longitudeNow points valid variable
this.longitudeNow = result.location.x;
// ...
});