0

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

1
  • please format your question better Commented Feb 4, 2016 at 11:43

1 Answer 1

1

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...

Sign up to request clarification or add additional context in comments.

2 Comments

It is not my objective
it is...: posted(Shown)the map without activated the GPS. that is what the code will do, yet you have to show some place on the map...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.