gmaps does not geolocate when I generate my ionic apk

1

friends with this code center the map and geolocalize, in the browser everything works ok, but at the general the .apk only focuses me the map does not geolocate me even having the gps activated

.controller('MapCtrl', function($scope, $ionicLoading, $ionicPopup) {
    var zocalo = { lat: 11.0041072, lng: -74.80698129999996 }

    var miubicacion = {}
    initMap = function() {
        var mapDiv = document.getElementById('map');
        var mapOptions = {
            center: zocalo,
            zoom: 16
        }
        $scope.map = new google.maps.Map(mapDiv, mapOptions)
        $scope.locateme();
    }
    $scope.locateme = function() {
        $ionicLoading.show({});
        navigator.geolocation.getCurrentPosition(function(pos) {

                miubicacion.lat = pos.coords.latitude;
                miubicacion.lng = pos.coords.longitude;
                $scope.map.setCenter(miubicacion);
                $ionicLoading.hide();
                addMarker();
            },
            function(error) {
                $ionicLoading.hide();
                console.log("errror");
            })
    }
    addMarker = function() {
        var marker = new google.maps.Marker({
            map: $scope.map,
            position: miubicacion,
            title: 'aqui estas ubicado',
            animation: google.maps.Animation.DROP

        })
    }

    if (document.readyState == "complete") {
        initMap()
    } else {
        google.maps.event.addDomListener(window, 'load', initMap);
    }
})
    
asked by frd 04.10.2016 в 03:31
source

1 answer

0

Try adding to your config.xml

<access origin="http://google.com" />
<access origin="https://google.com" />

<!-- Access to the subdomain maps.google.com -->
<access origin="http://maps.google.com" />

<!-- Access to all the subdomains on google.com -->
<access origin="http://*.google.com" />

EDIT

Add this plugin geolocation cordova

EDIT 2

Add this also to AndroidManifest, check my code and I have it

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
    
answered by 17.10.2016 в 18:01