Guest User

Google Maps

a guest
Apr 29th, 2016
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <script
  5. src="http://maps.googleapis.com/maps/api/js">
  6. </script>
  7.  
  8. <script>
  9. var routes = [{
  10. "lat": 37.3335423,
  11. "lng": -121.9132912,
  12. "billing_id": 31
  13. },
  14. {
  15. "lat": 37.3358189,
  16. "lng": -121.8877351,
  17. "billing_id": 32
  18. }];
  19. var myCenter = new google.maps.LatLng(routes[routes.length / 2].lat, routes[routes.length / 2].lng);
  20. var index = 0;
  21. var directionsDisplay;
  22. var directionsService = new google.maps.DirectionsService();
  23. var map;
  24.  
  25. function initialize() {
  26. directionsDisplay = new google.maps.DirectionsRenderer();
  27. var mapProp = {
  28. center: myCenter,
  29. zoom: 14,
  30. mapTypeId: google.maps.MapTypeId.ROADMAP
  31. };
  32.  
  33. var map = new google.maps.Map(document.getElementById("googleMap"), mapProp);
  34. var markers = [];
  35.  
  36. var intervalID = setInterval(function() {
  37. if(markers.length !== 0) {
  38. //markers[0].setMap(null);
  39. //markers.pop();
  40. }
  41. if (index === routes.length-1) {
  42. console.log("done with traversal;")
  43. clearInterval(intervalID);
  44. }
  45. myCenter = new google.maps.LatLng(routes[index].lat, routes[index].lng);
  46. index++;
  47. console.log("hello");
  48. var marker = new google.maps.Marker({
  49. position: myCenter,
  50. animation:google.maps.Animation.BOUNCE,
  51. map: map
  52. });
  53. markers.push(marker);
  54. //marker.setMap(map);
  55. }, 2007);
  56. }
  57. google.maps.event.addDomListener(window, 'load', initialize);
  58. </script>
  59. </head>
  60.  
  61. <body>
  62. <div id="googleMap" style="width:1800px;height:1000px;"></div>
  63. </body>
  64. </html>
Add Comment
Please, Sign In to add comment