Advertisement
Guest User

Untitled

a guest
May 4th, 2015
296
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.48 KB | None | 0 0
  1. // This file contains some delegate classes for you to extend.
  2.  
  3. function NewRoutePageControllerDelegate()
  4. {
  5. // Save 'this' so we can refer to public attributes and methods.
  6. var self = this;
  7.  
  8.  
  9. mapOptions = {
  10.  
  11. enableHighAccuracy: true,
  12. timeout: 6000,
  13. maximumAge: 0,
  14. }
  15.  
  16. mapError = function(err) {
  17.  
  18. console.warn('ERROR(' + err.code + '): ' + err.message);
  19. }
  20.  
  21. // The MapPageController class controls the 'New Route' page.
  22. // This class provides a couple of useful methods:
  23. // displayMessage(message):
  24. // Causes a short message string to be displayed on the
  25. // page for a brief period. Useful for showing quick
  26. // notifications to the user.
  27. // panToLocation(latitude, longitude):
  28. // Pans the map to the given latitude and longitude.
  29. // repaintOverlay():
  30. // Causes the map overlay to be redrawn, triggering a
  31. // call to our mapPageDrawOverlay() method. You might
  32. // wish to call this when you update information that
  33. // is displayed on the canvas overlay.
  34. // canvasPointFromLocation(latitude, longitude):
  35. // Given a latitude and longitude, returns the
  36. // corresponding point on the canvas overlay.
  37. // The return value is an object with an 'x' and a 'y'
  38. // property.
  39. var newRoutePageController = null;
  40.  
  41. // NOTE: You should not remove any of the five public methods below.
  42.  
  43. // This method is called by the MapPageController when the user
  44. // has switched to the page and it has been intialised.
  45.  
  46.  
  47.  
  48. this.mapPageInitialisedWithOptions = function(controller, options)
  49. {
  50. console.log("Record Route - mapPageInitialisedWithOptions");
  51.  
  52. newRoutePageController = controller;
  53.  
  54. //calling this function will pan to the location only once
  55.  
  56. findUser = function(position){
  57.  
  58. var latitude = position.coords.latitude
  59.  
  60. var longitude= position.coords.longitude
  61.  
  62. newRoutePageController.panToLocation(latitude, longitude)
  63.  
  64. }
  65.  
  66. navigator.geolocation.getCurrentPosition(findUser,mapError,mapOptions)
  67.  
  68.  
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement