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();
});
任何人都可以修復此代碼以更新緯度和經度嗎?
uj5u.com熱心網友回復:
正如 Pi 和 Mash 在評論中所寫,您的變數超出了范圍。
您必須將mymap.on回呼轉換為使用箭頭函式:
mymap.on("geosearch/showlocation", (result) => {
// Now this.longitudeNow points valid variable
this.longitudeNow = result.location.x;
// ...
});
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/476122.html
下一篇:如何更改復選框值的顏色
