[英]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.