简体   繁体   English

ionic应用程序的地理位置错误在浏览器上有效,但在android mobile上无效

[英]Geolocation error for ionic app is work on browser but not work on android mobile

i am developing a map based project in which app tries for geolocation of user, if GPS not enable it shows an error message. 我正在开发一个基于地图的项目,如果GPS未启用,则该应用会尝试对用户进行地理位置定位,并显示错误消息。 the code will work properly on browser. 该代码将在浏览器上正常工作。 but when i use this app on phone it will not working. 但是,当我在手机上使用此应用程序时,它将无法正常工作。 在此处输入图片说明

cede is here:-
navigator.geolocation.getCurrentPosition(function(pos) {
                map.setCenter(new google.maps.LatLng(pos.coords.latitude, pos.coords.longitude));
               marker = new google.maps.Marker({
                    position: new google.maps.LatLng(pos.coords.latitude, pos.coords.longitude),
                    icon:'http://maps.google.com/mapfiles/ms/icons/green-dot.png',
                    draggable:true,
                    map: map,
                    title: "My Location"
                });
               console.log(marker.getPosition());
               console.log(marker.getPosition().A);
               console.log(marker.getPosition().F);
                infoWindow.setContent('<div><strong>'+ "You are here!!" + '</strong><br>');
         infoWindow.open(map, marker);
             },
             function onError(error){
                     $ionicPopup.alert({
                                             title: 'Alert',
                                            template: 'Please Turn on your GPS and come back'});
             });

at last i have found solution of it...i have add {maximumAge:60000,timeout:3000,enableHighAccuracy:true} to my code 最后我找到了解决方案...我在我的代码中添加了{maximumAge:60000,timeout:3000,enableHighAccuracy:true}

     function onError(error){
                              $ionicPopup.alert({
                              title: 'Alert',
                              template: 'Please Turn on your GPS and come back'});
                             }
                             {maximumAge:60000,timeout:3000,enableHighAccuracy:true});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 pdf在Ionic应用程序中的浏览器中而不是在移动设备中读取工作 - pdf read work in browser but not in mobile device in Ionic app Ionic - 应用程序可在浏览器中运行,但在移动设备中模拟时不起作用 - Ionic - app works in browser but does not work when emulated in mobile Android浏览器无法使用地理位置 - Android browser doesn't work with geolocation 后台地理定位在后台的 ionic 3 中不起作用 - Background geolocation not work in ionic 3 in background Ionic 2,cordova-plugin-geolocation在android 7.0及更高版本中不起作用 - Ionic 2 , cordova-plugin-geolocation not work in android 7.0 and higher 在Android上使用[ionic Mobile App或浏览器]打开链接 - Open Link With [ ionic Mobile App or browser ] on android 地理位置无法在android中使用 - geolocation does not work in android 地理位置离子可在浏览器测试中工作,但不能在android上工作 - geolocation ionic working in browser test but not on android GPS Geolocation应用程序在Android的Phonegap中不起作用 - GPS Geolocation app doesn't work in Phonegap for Android 为什么我的 mapbox 组件(在 Ionic 应用程序中)可以在浏览器/本地主机上运行,但当我将它带到我的 Android 模拟器时却不能? - Why does my mapbox component (in Ionic app) work on browser/localhost but not when I bring it to my Android emulator?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM