Advertisement
Guest User

Untitled

a guest
Mar 20th, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.73 KB | None | 0 0
  1. <script src="http://maps.googleapis.com/maps/api/js?key=AIzaSyDFCC20hYUuTYKSxaE_y7B3cv55XF5rrXw&js?sensor=false&extn=.js"></script>
  2.  
  3.  
  4. <div id="mapCanvas" style="min-height: 320px;"></div>
  5. <script>
  6. var beaches = [['dd',-6.135801,106.639000,1],['dddd',-6.131222,106.601900,2]];
  7. var NewLocation = [['dd',-6.139801,106.638000,1],['dddd',-6.134222,106.641900,2]];
  8.  
  9.  
  10. function initialize() {
  11. var latlng = new google.maps.LatLng(-6.1322135, 106.6431465);
  12. var myOptions = {
  13. zoom: 16,
  14. center: latlng,
  15. mapTypeId: google.maps.MapTypeId.ROADMAP
  16. };
  17. map = new google.maps.Map(document.getElementById("mapCanvas"), myOptions);
  18.  
  19. var image = {
  20. url: "{{ url('/') }}/img/car.png",
  21. size: new google.maps.Size(20, 32),
  22. origin: new google.maps.Point(0, 0),
  23. anchor: new google.maps.Point(0, 32)
  24. };
  25.  
  26. var shape = {
  27. coords: [1, 1, 1, 20, 18, 20, 18, 1],
  28. type: 'poly'
  29. };
  30. for (var i = 0; i < beaches.length; i++) {
  31. var beach = beaches[i];
  32. marker = new google.maps.Marker({
  33. position: {lat: beach[1], lng: beach[2]},
  34. map: map,
  35. //icon: image,
  36. shape: shape,
  37. title: beach[0],
  38. zIndex: beach[3]
  39. });
  40. }
  41.  
  42. google.maps.event.addListener(map, 'click', function(event) {
  43. udateMarker();
  44. });
  45. }
  46.  
  47. //Load google map
  48. google.maps.event.addDomListener(window, 'load', initialize);
  49.  
  50. setInterval(function(){
  51. udateMarker();
  52. }, 10000);
  53.  
  54.  
  55. function udateMarker(){
  56.  
  57. for (var i = 0; i < NewLocation.length; i++) {
  58. var numDeltas = 100;
  59. var delay = 10;
  60. /*var deltaLat;
  61. var deltaLng;
  62.  
  63. deltaLat = (NewLocation[i][1] - beaches[i][1])/numDeltas;
  64. deltaLng = (NewLocation[i][2] - beaches[i][2])/numDeltas;
  65. alert(beaches[i][3]+"|"+beaches[i][1]+"|"+beaches[i][2]);
  66. beaches[i][1] += deltaLat;
  67. beaches[i][2] += deltaLng;*/
  68.  
  69. var shape = {
  70. coords: [1, 1, 1, 20, 18, 20, 18, 1],
  71. type: 'poly'
  72. };
  73. for (var i = 0; i < beaches.length; i++) {
  74. var beach = beaches[i];
  75. marker = new google.maps.setPosition({
  76. position: {lat: beach[1], lng: beach[2]},
  77. map: map,
  78. //icon: image,
  79. shape: shape,
  80. title: beach[0],
  81. zIndex: beach[3]
  82. });
  83. }
  84.  
  85. /*var latlng = new google.maps.LatLng(NewLocation[i][1], NewLocation[i][2]);
  86. marker.setTitle(beaches[i][0]);
  87. marker.setPosition(latlng);
  88. marker.setZIndex(beaches[i][3]);
  89. if(n!=numDeltas){
  90. n++;
  91. setTimeout(udateMarker, delay);
  92. }*/
  93.  
  94. }
  95. }
  96.  
  97.  
  98. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement