2016-07-09 3 views
1

Ionic AppのGoogleマップでGPS検出に問題があります。 GPSをオフにしてアプリケーションを起動した後、設定デバイスからGPSに移動し、Find Meボタン - centerOnMe()機能をクリックすると、GPSは機能しません。機能の応答は常にGPSをオフにしてアプリケーションを起動し、後でGPSを有効にすると、場所が検出されません。

`Error: GPS Timeout! ERROR = 3` 

初めに私はそれがキャッシュの問題だと思ったが、それはそれではないから私が発見しました。ビューから$ state.reloadを使用しても問題ありません。誰も同じ問題を抱えていますか?ご支援ありがとうございます。私は、以下の機能を付ける:

$scope.centerOnMe = function() { 

     $ionicPlatform.ready(function() { 
     console.log('Click on Find Me'); 

     if(!map) { 
      return; 
     } 

     $ionicLoading.show({ 
      content: 'Getting current location...', 
      showBackdrop: false 
     }); 

     //$state.reload('app.map'); 
     watchPositionId = navigator.geolocation.watchPosition(function(position) {      
       navigator.geolocation.clearWatch(watchPositionId); 
       var latitude  = position.coords.latitude; 
       var longitude = position.coords.longitude; 
       $scope.latitude = latitude; 
       $scope.longitude = longitude; 
       var geolocpoint = new google.maps.LatLng(latitude, longitude); 
       map.setCenter(geolocpoint);  
     }); 
     navigator.geolocation.getCurrentPosition(function (position) { 
        var lat = position.coords.latitude 
        var long = position.coords.longitude     
        $scope.center = new google.maps.LatLng(lat, long); 
        $ionicLoading.hide(); 
        console.log("GPS is enabled" + $scope.center); 
     }, function(err) { 
        // error 
        if (err.code == 1)  { console.log('GPS disabled! ERROR = '  + err.code); } 
        else if(err.code == 2) { console.log('GPS is unavailable! ERROR = ' + err.code); } 
        else if(err.code == 3) { console.log('Error: GPS Timeout! ERROR = ' + err.code); } 
        $ionicLoading.hide(); 
     }, { 
        enableHighAccuracy: true, timeout: 20000 
      } 
     ); 

     });  
    }; 

答えて

0

thisプラグインを使用するには、より良い、

cordova plugin add cordova.plugins.diagnostic 

それは直接GPSが有効になっているかどうかをチェックしたりしません。

フォアの詳細は、これはあなたを助ける

  1. Geo location timeout vs location permission error
  2. Get Current Position not working after turning the GPS off on the device even if it turned on again?

希望、イオンフォーラムの問題以下をチェック!

関連する問題