當前的位置請求在我的應用程序地圖工作正常,我使用android和我需要在狀態欄上手動打開'本地'工作。我想在地圖中輸入時顯示請求。貝婁是我的代碼,我正在使用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)
});
任何人都可以幫助我嗎? – Sobucki