Reputation: 329
I used this link enter link description herefor shown Google map but always he asks me of activated for the GPS .
My objective is: posted(Shown)the map without activated the GPS
after he shows my position
my controller :
facebookExample.controller('carteController', function($scope,$ionicPopup,$ionicLoading,$location,$cordovaGeolocation,$compile,$http) {
$scope.init = function() {
var options = {timeout: 10000, enableHighAccuracy: true};
$cordovaGeolocation.getCurrentPosition(options).then(function(position){
var latLng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
console.log("langitude et latitude obtenu par google maps");
console.log(latLng);
var mapOptions = {
center: latLng,
zoom: 15,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
$scope.map = new google.maps.Map(document.getElementById("map"), mapOptions);
google.maps.event.addListenerOnce($scope.map, 'idle', function(){
var marker = new google.maps.Marker({
map: $scope.map,
animation: google.maps.Animation.DROP,
position: latLng
});
var infoWindow = new google.maps.InfoWindow({
content: "Here I am!"
});
google.maps.event.addListener(marker, 'click', function () {
infoWindow.open($scope.map, marker);
});
console.log(status);
please help me ,how to chnage my controller to reach my goal
Upvotes: 0
Views: 394
Reputation: 3011
Your controller checks if the geolocation is available and then runs the map code. It is on this line:
$cordovaGeolocation.getCurrentPosition(options).then(function(position){
//code here is only run if we got the current position
}
so you should get rid of that line if you do not want it. Problem then is: that you can not center the map on the user's position. So also change that line:
var latLng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
to
var latLng = new google.maps.LatLng(-34.397,150.644);
for example...
Upvotes: 1