Advertisement
Guest User

Untitled

a guest
Sep 19th, 2014
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. // Google Map
  2. .controller('MapCtrl', function($scope, $ionicLoading, $compile) {
  3. function initialise() {
  4. var myLatlng = new google.maps.LatLng(53.068165,-4.076803);
  5. var mapOptions = {
  6. zoom: 15,
  7. center: myLatlng,
  8. mapTypeId: google.maps.MapTypeId.ROADMAP,
  9. }
  10. var map = new google.maps.Map(document.getElementById('map'), mapOptions);
  11. var marker = new google.maps.Marker({
  12. position: myLatlng,
  13. map: map,
  14. title: 'Hello World!'
  15. });
  16.  
  17. $scope.map = map;
  18.  
  19. }
  20. google.maps.event.addDomListener(window, 'load', initialise);
  21.  
  22. $scope.centerOnMe = function() {
  23. if(!$scope.map) {
  24. return;
  25. }
  26. $scope.loading = $ionicLoading.show({
  27. showBackdrop: true
  28. });
  29. navigator.geolocation.getCurrentPosition(function(pos) {
  30. $scope.map.setCenter(new google.maps.LatLng(pos.coords.latitude, pos.coords.longitude));
  31.  
  32.  
  33. $scope.loading.hide();
  34. }, function(error) {
  35. alert('Unable to get location: ' + error.message);
  36. });
  37. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement