The problem is getCurrentPosition runs asynchronously.
Try it like this
moduloMapa.service('mapService', function() {
this.localizar = function() {
var coords = { lat: 0, lon: 0 };
navigator.geolocation.getCurrentPosition(function(posicion) {
cords.lat = posicion.coords.latitude;
cords.lon = posicion.coords.longitude;
});
return coords;
};
});
And as soon as the browser gets the coords they will be available to the controller's scope.
$scope.latitud = mapService.localizar().lat;
Update:
Sorry for the typo, I've created a working plunker here