【发布时间】:2019-01-16 09:39:55
【问题描述】:
我遇到了一个地理定位问题,我需要在 iOS 上为用户显示geolocation 提示并且他们点击“接受”之后运行一个函数。
目前我正在ngOnInit上检查用户位置,但如果他们还没有接受,我在检查用户位置后运行的功能不起作用。
这是我目前拥有的:
this.geolocation.getCurrentPosition({enableHighAccuracy: false, timeout: 3000, maximumAge: 100000})
.then((resp) => {
this.userLocation.lat = resp.coords.latitude;
this.userLocation.lng = resp.coords.longitude;
this.getLocation();
}).catch((error) => {
console.log(error)
});
所以this.getLocation();函数在geolocation找到位置后运行,但是在用户接受“允许此应用程序使用您的位置”提示后我将如何运行此代码?
谢谢!
【问题讨论】:
标签: javascript cordova ionic-framework ionic2 geolocation