Advertisement
Guest User

Untitled

a guest
Oct 30th, 2014
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.65 KB | None | 0 0
  1. function initialize() {
  2. directionsDisplay = new google.maps.DirectionsRenderer();
  3. var node = new google.maps.LatLng(-7.276442,112.791174);
  4. var mapOptions = {
  5. zoom: 15,
  6. mapTypeId: google.maps.MapTypeId.ROADMAP
  7. };
  8. map = new google.maps.Map(document.getElementById('map'),
  9. mapOptions);
  10. directionsDisplay.setMap(map);
  11.  
  12. navigator.geolocation.getCurrentPosition(function(position) {
  13. pos = new google.maps.LatLng(position.coords.latitude,
  14. position.coords.longitude);
  15.  
  16. var marker = new google.maps.Marker({
  17. position : pos,
  18. map: map,
  19. title:'Lokasi Anda'
  20. });
  21. var marker1 = new google.maps.Marker({
  22. position : node,
  23. map: map,
  24. title:'Lokasi Anda'
  25. });
  26.  
  27. map.setCenter(pos);
  28. }, function() {
  29. handleNoGeolocation(true);
  30. });
  31.  
  32. }
  33.  
  34. function calcRoute() {
  35.  
  36. var request = {
  37. origin:pos,
  38. destination:node,
  39. travelMode: google.maps.DirectionsTravelMode.DRIVING
  40. };
  41.  
  42. directionsService.route(request, function(response, status) {
  43. if (status == google.maps.DirectionsStatus.OK) {
  44. directionsDisplay.setDirections(response);
  45. }
  46. });
  47. }
  48.  
  49. function calcRoute(pos,node) {
  50. var directionsService = new google.maps.DirectionsService();
  51. var request = {
  52. origin:pos,
  53. destination:node,
  54. travelMode: google.maps.DirectionsTravelMode.DRIVING
  55. };
  56.  
  57. directionsService.route(request, function(response, status) {
  58. if (status == google.maps.DirectionsStatus.OK) {
  59. directionsDisplay.setDirections(response);
  60. } else { alert("Directions failed: "+status); }
  61. });
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement