Advertisement
Guest User

new map

a guest
Jul 29th, 2016
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.40 KB | None | 0 0
  1. <script>
  2.  
  3. // The following example creates complex markers to indicate beaches near
  4. // Sydney, NSW, Australia. Note that the anchor is set to (0,32) to correspond
  5. // to the base of the flagpole.
  6.  
  7. function initMap() {
  8. var map = new google.maps.Map(document.getElementById('map'), {
  9. zoom: 12,
  10. center: {lat:-7.717594, lng: 110.329764}
  11. });
  12.  
  13. setMarkers(map);
  14. }
  15.  
  16. // Data for the markers consisting of a name, a LatLng and a zIndex for the
  17. // order in which these markers should display on top of each other.
  18. var beaches = [
  19. ['Bondi Beach', -7.716233 , 110.33869, 1 ],
  20.  
  21. ];
  22.  
  23. function setMarkers(map) {
  24. // Adds markers to the map.
  25.  
  26. // Marker sizes are expressed as a Size of X,Y where the origin of the image
  27. // (0,0) is located in the top left of the image.
  28.  
  29. // Origins, anchor positions and coordinates of the marker increase in the X
  30. // direction to the right and in the Y direction down.
  31. var image = {
  32. url: 'https://developers.google.com/maps/documentation/javascript/examples/full/images/beachflag.png',
  33. // This marker is 20 pixels wide by 32 pixels high.
  34. size: new google.maps.Size(20, 32),
  35. // The origin for this image is (0, 0).
  36. origin: new google.maps.Point(0, 0),
  37. // The anchor for this image is the base of the flagpole at (0, 32).
  38. anchor: new google.maps.Point(0, 32)
  39. };
  40. // Shapes define the clickable region of the icon. The type defines an HTML
  41. // <area> element 'poly' which traces out a polygon as a series of X,Y points.
  42. // The final coordinate closes the poly by connecting to the first coordinate.
  43. var shape = {
  44. coords: [1, 1, 1, 20, 18, 20, 18, 1],
  45. type: 'poly'
  46. };
  47. for (var i = 0; i < beaches.length; i++) {
  48. var beach = beaches[i];
  49. var marker = new google.maps.Marker({
  50. position: {lat: beach[1], lng: beach[2]},
  51. map: map,
  52. icon: image,
  53. shape: shape,
  54. title: beach[0],
  55. zIndex: beach[3]
  56. });
  57. }
  58. }
  59. </script>
  60. <script async defer
  61. src="https://maps.googleapis.com/maps/api/js?key=AIzaSyA8V020aIxzsnq7PlhFS0a0z50wgIgW7rM&callback=initMap">
  62. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement