Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.57 KB | None | 0 0
  1. cordova plugin add cordova-plugin-geolocation
  2. cordova plugin add cordova-plugin-whitelist
  3.  
  4. <!-- cordova script (this will be a 404 during development) -->
  5. <script src="js/ng-cordova.min.js"></script>
  6. <script src="cordova.js"></script>
  7.  
  8. angular.module('starter', ['ionic', 'ngCordova', 'firebase', 'starter.controllers', 'starter.configs', ])
  9.  
  10. .run(function($ionicPlatform, $timeout) {
  11. $ionicPlatform.ready(function() {
  12.  
  13. console.log('Platform ready!');
  14.  
  15. if(window.StatusBar) {
  16. // org.apache.cordova.statusbar required
  17. StatusBar.styleDefault();
  18. }
  19. });
  20. })
  21.  
  22. $ionicPlatform.ready(function() {
  23.  
  24. $ionicLoading.show({
  25. template: '<ion-spinner icon="bubbles"></ion-spinner><br/>Acquiring location!'
  26. });
  27.  
  28. var posOptions = {
  29. enableHighAccuracy: true,
  30. timeout: 20000,
  31. maximumAge: 0
  32. };
  33.  
  34. $cordovaGeolocation.getCurrentPosition(posOptions).then(function (position) {
  35. var lat = position.coords.latitude;
  36. var long = position.coords.longitude;
  37.  
  38. var myLatlng = new google.maps.LatLng(lat, long);
  39.  
  40. var mapOptions = {
  41. center: myLatlng,
  42. zoom: 16,
  43. mapTypeId: google.maps.MapTypeId.ROADMAP
  44. };
  45.  
  46. var map = new google.maps.Map(document.getElementById("map"), mapOptions);
  47.  
  48. $scope.map = map;
  49. $ionicLoading.hide();
  50.  
  51. }, function(err) {
  52. $ionicLoading.hide();
  53. console.log(err);
  54. });
  55. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement