Created
December 15, 2016 15:19
-
-
Save samuelpordeus/1867e9331f3deec7d186b1222d4857da to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
( function () { | |
'use strict'; | |
angular | |
.module('pamin.services') | |
.factory('PaminMap', PaminMap); | |
PaminMap.$injector = ['$rootScope', 'zigmap']; | |
function PaminMap($rootScope, zigmap) { | |
var options = { | |
center: { | |
lat: -9, | |
lng: -9 | |
}, | |
zoom: 14, | |
zoomControlOptions: { | |
position: google.maps.ControlPosition.RIGHT_TOP | |
}, | |
panControlOptions: { | |
position: google.maps.ControlPosition.RIGHT_TOP | |
} | |
}; | |
var events = { | |
click: function (event) { | |
var coords = { | |
lat: event.latLng.lat(), | |
lng: event.latLng.lng() | |
}; | |
$rootScope.$broadcast('paminMap:click', coords); | |
} | |
}; | |
var map = zigmap.addMap('pamin-map', options, events); | |
return map; | |
} | |
if(navigator.geolocation) | |
{ | |
navigator.geolocation.getCurrentPosition(function(position){ | |
var center = { | |
lat: position.coords.latitude, | |
lng: position.coords.longitude | |
} | |
console.log(center); | |
PaminMap.getReference().setCenter(center); | |
}); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment