Advertisement
datisaac

Untitled

Jul 22nd, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.52 KB | None | 0 0
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6.  
  7.  
  8. /* global google */
  9. var map;
  10. // Creating icon links to iterate through randomly
  11. var icons = [
  12. 'http://maps.google.com/mapfiles/ms/icons/red-dot.png',
  13. 'http://maps.google.com/mapfiles/ms/icons/green-dot.png',
  14. 'http://maps.google.com/mapfiles/ms/icons/blue-dot.png',
  15. 'http://maps.google.com/mapfiles/ms/icons/orange-dot.png',
  16. 'http://maps.google.com/mapfiles/ms/icons/purple-dot.png',
  17. 'http://maps.google.com/mapfiles/ms/icons/pink-dot.png',
  18. 'http://maps.google.com/mapfiles/ms/icons/yellow-dot.png'
  19. ];
  20. var infoWindows =[
  21. "<b> testing one two three </b> <br> <img src = 'http://maps.google.com/mapfiles/ms/icons/yellow-dot.png'>"
  22. ];
  23. // Initialising The map with settings
  24.  
  25. function initialise() {
  26. var mapOptions = {
  27. center: new google.maps.LatLng(0, 0),
  28. zoom: 4,
  29. mapTypeId: google.maps.MapTypeId.SATELLITE,
  30. zoomControlOptions: {
  31. position: google.maps.ControlPosition.LEFT_BOTTOM
  32. }
  33. };
  34. map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
  35. }
  36. google.maps.event.addDomListener(window, 'load', initialise);
  37.  
  38. // **********************************start of button 1 ***********************************
  39.  
  40.  
  41. function newCenter() {
  42. var prompt1 = prompt('enter lat');
  43. var prompt2 = prompt ('enter long');
  44.  
  45. var relocate = new google.maps.LatLng(prompt1, prompt2)
  46. map.panTo(relocate);
  47.  
  48. new google.maps.Marker({
  49. position: relocate,
  50. icon: icons[Math.floor(Math.random()*icons.length)],
  51. map: map,
  52. infoWindow : infoWindows[0]
  53. });
  54. }
  55.  
  56.  
  57. // **********************************start of button 2***********************************
  58. function button2(){
  59. var random1 = Math.round((Math.random()*180 - 180)* 1000)/1000;
  60. var random2 = Math.round((Math.random()*180 - 180)*1000)/1000;
  61. var relocate2 = new google.maps.LatLng(random1, random2)
  62. map.setCenter(relocate2);
  63. }
  64. // **********************************start of button 3***********************************
  65. var markON = false;
  66.  
  67. function button3(){
  68. if(!markON){
  69. markON=true;
  70. mapsListener = google.maps.event.addListener(map, 'click', function(e) {
  71. placeMarker(e.latLng, map);
  72. });
  73.  
  74. function placeMarker(position, map) {
  75. var marker = new google.maps.Marker({
  76. position: position,
  77. map: map,
  78. icon: icons[Math.floor(Math.random()*icons.length)]
  79. });
  80. map.panTo(position);
  81. }
  82. }
  83. else {
  84. markON = false;
  85. google.maps.event.removeListener(mapsListener);
  86. }
  87. }
  88.  
  89. // **********************************start of button 4***********************************
  90. var countPoly = 0;
  91. var area = new google.maps.MVCArray();
  92. var polygon = new google.maps.Polygon({
  93. path: area,
  94. map:map,
  95. strokeOpacity: 0.5,
  96. strokeWeight: 6,
  97. strokeColor: "#0000FF",
  98. fillOpacity: 0.5,
  99. fillColor: "#00000F",
  100. clickable:false
  101. });
  102.  
  103. var listenON=false;
  104.  
  105.  
  106. function button4()
  107. {
  108. if(!listenON){
  109. listenON=true;
  110.  
  111. polygon.setMap(map);
  112. drawListener = google.maps.event.addListener(map, 'click', function (x) {
  113. countPoly++;
  114. var path = polygon.getPath();
  115. path.push(x.latLng)
  116. var marker = new google.maps.Marker({
  117. position: x.latLng,
  118. map: map,
  119. icon: icons[Math.floor(Math.random()*icons.length)]
  120.  
  121. });
  122.  
  123.  
  124. google.maps.event.trigger(marker, 'click');
  125.  
  126. });
  127. }
  128. else
  129. {
  130. listenON=false;
  131.  
  132. google.maps.event.removeListener(drawListener);
  133.  
  134. }
  135.  
  136.  
  137.  
  138. }
  139.  
  140. // **********************************start of button 4***********************************
  141.  
  142. var highlightListenON = false;
  143.  
  144.  
  145. function button5(){
  146.  
  147. var countPoly = 0;
  148. var area = new google.maps.MVCArray();
  149. var polygon = new google.maps.Polygon({
  150. path: area,
  151. map:map,
  152. strokeOpacity: 0.5,
  153. strokeWeight: 6,
  154. strokeColor: "#0000FF",
  155. fillOpacity: 0.5,
  156. fillColor: "#00000F",
  157. clickable:false
  158. });
  159.  
  160.  
  161.  
  162. if(!highlightListenON){
  163. highlightListenON = true;
  164.  
  165. drawListener = google.maps.event.addListener(map, 'click', function(e){
  166. countPoly++;
  167. })
  168.  
  169. }
  170. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement