1
我用離子地理位置跟蹤客戶的地方,但標記不會改變她的地方,請任何一個能幫助我,這是我的控制器代碼:離子地理位置變化標記的地方
控制器
app.controller('mapCtrl', function($scope, $ionicPlatform, $state, $http, $cordovaGeolocation, $interval, $ionicPopup, $ionicLoading) {
$scope.positions = [{
lat: 43.07493,
lng: -89.381388
}];
$scope.$on('mapInitialized', function(event, map) {
$scope.map = map;
$scope.positions = [];
$ionicLoading.show({
template: 'Loading...'
});
$scope.map = map;
var getLocation = function() {
marker.setVisible(false);
navigator.geolocation.getCurrentPosition(function(position) {
var pos = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
var marker = new google.maps.Marker({
position: pos,
map: map,
animation: google.maps.Animation.DROP,
'icon': 'img/marker2.png'
});
marker.setVisible(true);
marker.setIcon('http://maps.gstatic.com/mapfiles/ridefinder-images/mm_20_gray.png');
$scope.positions.push({
lat: pos.k,
lng: pos.B
});
console.log(pos);
$scope.map.setCenter(pos);
$ionicLoading.hide();
});
};
$interval(getLocation, 5000);
});
});