【发布时间】:2019-01-08 17:55:05
【问题描述】:
我在服务中创建了以下函数,以获取当前位置的坐标并将它们存储在 2 个变量中:
getCurrentLocation() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(position => {
this.currLat = position.coords.latitude;
this.currLng = position.coords.longitude;
});
}
else {
alert("Geolocation is not supported by this browser.");
}
}
如何通过此函数返回坐标以便在组件中使用它们?
【问题讨论】:
标签: angular google-maps geolocation