2016-03-27 6 views
0

のイオンの現在の位置情報要求を表示していませんマップはうまくいきます、私はアンドロイドを使用しており、私は手動でステータスバーの 'ローカル'を有効にする必要があります。私は地図に入力するときにその要求を表示したい。ぼくは私のコードです、私はcordova geolocationプラグインを使用しています。マップは私のアプリでイオン性の

angular.module('myApp.controllers', ['ionic']) 
 

 

 
.controller('NavCtrl', function($scope, $ionicLoading, $compile, $ionicModal, $timeout) { 
 
    var myLatLng; 
 
    var latCS; 
 

 
    
 
    function initialize() { 
 

 
    
 
    navigator.geolocation.getCurrentPosition(function(position) { 
 
     myLatLng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude); 
 
\t \t latCS = new google.maps.LatLng(-27.465559, -48.378426); 
 
\t \t 
 
    
 
     var mapOptions = { 
 
      center: myLatLng, 
 
      zoom: 10, 
 
      mapTypeId: google.maps.MapTypeId.ROADMAP 
 
     }; 
 
     var map = new google.maps.Map(document.getElementById("map"),mapOptions); 
 
\t \t 
 

 
     var marker = new google.maps.Marker({ 
 
      position: myLatLng, 
 
      map: map, 
 
      title: 'Your Pos' 
 
     }); 
 
\t \t 
 
\t \t var marker2 = new google.maps.Marker({ 
 
      position: latCS, 
 
      map: map, 
 
      title: 'Your Dest' 
 
     }); 
 
\t \t 
 

 
\t \t var directionsDisplay = new google.maps.DirectionsRenderer();// also, constructor can get "DirectionsRendererOptions" object 
 
\t \t directionsDisplay.setMap(map); // map should be already initialized. 
 

 
\t \t var request = { 
 
\t \t \t origin : myLatLng, 
 
\t \t \t destination : latCS, 
 
\t \t \t travelMode : google.maps.TravelMode.DRIVING 
 
\t \t }; 
 
\t \t var directionsService = new google.maps.DirectionsService(); 
 
\t \t directionsService.route(request, function(response, status) { 
 
\t \t \t if (status == google.maps.DirectionsStatus.OK) { 
 
\t \t \t \t directionsDisplay.setDirections(response); 
 
\t \t \t } 
 
\t \t }); 
 
     $scope.map = map; 
 
    }); 
 
    } 
 
    
 

 
    ionic.Platform.ready(initialize) 
 
    
 
});

+0

誰かが私を助けることができますか? – Sobucki

答えて

0

質問は、私には明確ではないが、私はあなたが直接あなたのアプリから、GPSを有効にするには、ユーザーをお願いしたいと思いますと仮定します。

もしそうなら、偉大なcordova-diagnostic-pluginを見てください。 switchToSettings(Android、iOs)、switchToLocationSettings(Android、Windows Phone)などの便利な方法があります。

は、これらのメソッドを呼び出す前に、きれい($ionicPopupを参照してください)場所/ GPSを有効にするには、彼を求めて、ユーザに確認ポップアップを表示することがあります。

+0

私はcordova-diagnostic-plugin、thanks manを使用して解決しました。 – Sobucki

+0

あなたは大歓迎です!あなたがそれを楽しむならば、GitHubでこのプロジェクトにスターを付けることを忘れないでください。私は個人的には、これがCordovaプロジェクトで利用できる最も有用なプラグインの1つだと思っています:)(プロジェクトには興味がなく、私の謙虚な意見です!) – VinceOPS

関連する問題