![](/img/trans.png)
[英]Android Studio WebView Unable to ask user for their geolocation
[英]Ask user to activate Geolocation in an IONIC 3 application
我正在使用Ionic 3本机Geolocation插件通过功能"getCurrentPosition()"
获取用户位置。 但是当我的设备上的地理定位未激活时,我得到了最后保存的位置...
如何在应用程序开始时要求用户激活其android / ios地理位置?
我遇到了同样的问题,因此我按如下方式使用了Toast:
import { ToastController } from 'ionic-angular'; ... constructor(private geolocation: Geolocation, private toastCtrl: ToastController) { ... let toast = this.toastCtrl.create({ message: 'Your device location is not available. Please turn on your GPS.', position: 'middle', showCloseButton: true, closeButtonText: 'OK' }); this.geolocation.getCurrentPosition().then((resp) => { //if location available - do whatever you need }).catch((error) => { toast.present(); console.log('Error getting location', error); }); }
我找到了一种更精确的方法: https : //forum.ionicframework.com/t/how-to-check-if-geolocation-is-enable-or-not-with-native-gps/88762/4
使用2个离子本机插件:@ ionic-native / diagnostic @ ionic-native / location-accuracy
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.