Guest User

Untitled

a guest
Jun 20th, 2018
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 2.49 KB | None | 0 0
  1. function initialize() {
  2.   var myOptions = {
  3.     zoom: 10,
  4.     center: new google.maps.LatLng(-33.9, 151.2),
  5.     mapTypeId: google.maps.MapTypeId.ROADMAP
  6.   }
  7.   var map = new google.maps.Map(document.getElementById("map_canvas"),
  8.                                 myOptions);
  9.  
  10.   setMarkers(map, beaches);
  11. }
  12.  
  13. /**
  14.  * Data for the markers consisting of a name, a LatLng and a zIndex for
  15.  * the order in which these markers should display on top of each
  16.  * other.
  17.  */
  18. var beaches = [[]
  19.   [[]'Bondi Beach', -33.890542, 151.274856, 4],
  20.   [[]'Coogee Beach', -33.923036, 151.259052, 5],
  21.   [[]'Cronulla Beach', -34.028249, 151.157507, 3],
  22.   [[]'Manly Beach', -33.80010128657071, 151.28747820854187, 2],
  23.   [[]'Maroubra Beach', -33.950198, 151.259302, 1]
  24. ];
  25.  
  26. function setMarkers(map, locations) {
  27.   // Add markers to the map
  28.  
  29.   // Marker sizes are expressed as a Size of X,Y
  30.   // where the origin of the image (0,0) is located
  31.   // in the top left of the image.
  32.  
  33.   // Origins, anchor positions and coordinates of the marker
  34.   // increase in the X direction to the right and in
  35.   // the Y direction down.
  36.   var image = new google.maps.MarkerImage('images/beachflag.png',
  37.       // This marker is 20 pixels wide by 32 pixels tall.
  38.       new google.maps.Size(20, 32),
  39.       // The origin for this image is 0,0.
  40.       new google.maps.Point(0,0),
  41.       // The anchor for this image is the base of the flagpole at 0,32.
  42.       new google.maps.Point(0, 32));
  43.   var shadow = new google.maps.MarkerImage('images/beachflag_shadow.png',
  44.       // The shadow image is larger in the horizontal dimension
  45.       // while the position and offset are the same as for the main image.
  46.       new google.maps.Size(37, 32),
  47.       new google.maps.Point(0,0),
  48.       new google.maps.Point(0, 32));
  49.       // Shapes define the clickable region of the icon.
  50.       // The type defines an HTML <area> element 'poly' which
  51.       // traces out a polygon as a series of X,Y points. The final
  52.       // coordinate closes the poly by connecting to the first
  53.       // coordinate.
  54.   var shape = {
  55.       coord: [[]1, 1, 1, 20, 18, 20, 18 , 1],
  56.       type: 'poly'
  57.   };
  58.   for (var i = 0; i < locations.length; i++) {
  59.    var beach = locations[[]i];
  60.    var myLatLng = new google.maps.LatLng(beach[[]1], beach[[]2]);
  61.    var marker = new google.maps.Marker({
  62.        position: myLatLng,
  63.        map: map,
  64.        shadow: shadow,
  65.        icon: image,
  66.        shape: shape,
  67.        title: beach[[]0],
  68.        zIndex: beach[[]3]
  69.    });
  70.  }
  71. }
Add Comment
Please, Sign In to add comment