Advertisement
Guest User

Gmaps break

a guest
Mar 3rd, 2013
258
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function initialize() {
  2.  
  3. var styles =   [
  4.   {
  5.     stylers: [
  6.       { hue: '#F2846A' },
  7.       { saturation: 80 }
  8.     ]
  9.   },{
  10.     featureType: 'road',
  11.     elementType: 'geometry',
  12.     stylers: [
  13.       { lightness: 100 },
  14.       { visibility: 'simplified' }
  15.     ]
  16.   },{
  17.     featureType: 'road',
  18.     elementType: 'labels',
  19.     stylers: [
  20.       { visibility: 'off' }
  21.     ]
  22.   }
  23. ];
  24.  
  25. var mapOptions = {
  26.   zoom: 12,
  27.   center: new google.maps.LatLng(52.204872,0.120163),
  28.   mapTypeId: google.maps.MapTypeId.ROADMAP,
  29.   styles: styles,
  30.   scrollwheel: false
  31. };
  32. var map = new google.maps.Map(document.getElementById('map_canvas'),mapOptions);
  33.  
  34. setMarkers(map, sites);
  35.     infowindow = new google.maps.InfoWindow({
  36.     content: "loading..."
  37. });
  38. }
  39.  
  40. var sites = [
  41.     ['The Frontroom', 52.202977,0.138938, 1, '<p>The Frontroom. <br/>23-25 Gwydir Street, Cambridge, CB1 2LG <br/>01223 305 600</p>'],
  42.     ['Fitzwilliam Museum',52.199678,0.119931, 2, 'Fitzwilliam Museum'],
  43.     ['Wysing Arts centre', 52.182077,-0.06977, 3, 'Wysing Arts Centre'],
  44.     ['Cambridge School of Art', 52.203825,0.134808, 4, 'Cambridge School of Art'],
  45.     ['Kettles yard', 52.210851,0.114637, 5, 'Kettles Yard'],
  46.     ['Changing Spaces',52.199678,0.119931, 6, 'Changing Spaces'],
  47.     ['Aid & Abet', 52.195218,0.136578, 7, 'Aid & Abet'],
  48.     ['The Junction', 52.190756,0.136522, 8, 'The Junction']
  49. ];
  50.  
  51. function setMarkers(map, markers) {
  52.  
  53. for (var i = 0; i < markers.length; i++) {
  54.     var sites = markers[i];
  55.     var siteLatLng = new google.maps.LatLng(sites[1], sites[2]);
  56.     var marker = new google.maps.Marker({
  57.         position: siteLatLng,
  58.         map: map,
  59.         title: sites[0],
  60.         zIndex: sites[3],
  61.         html: sites[4],
  62.         icon: "http://visualartscambridge.org/wp-content/uploads/2013/03/map-pin.png"
  63.     });
  64.     // Begin example code to get custom infobox
  65.     var boxText = document.createElement("div");
  66.     boxText.style.cssText = "border: 1px solid black; margin-top: 8px; background: yellow; padding: 5px;";
  67.     boxText.innerHTML = marker.html;
  68.  
  69.     var myOptions = {
  70.          content: boxText
  71.         ,disableAutoPan: false
  72.         ,maxWidth: 0
  73.         ,pixelOffset: new google.maps.Size(-140, 0)
  74.         ,zIndex: null
  75.         ,boxStyle: {
  76.           background: "url('http://google-maps-utility-library-v3.googlecode.com/svn/tags/infobox/1.1.12/examples/tipbox.gif') no-repeat"
  77.           ,opacity: 0.75
  78.           ,width: "280px"
  79.          }
  80.         ,closeBoxMargin: "10px 2px 2px 2px"
  81.         ,closeBoxURL: "http://www.google.com/intl/en_us/mapfiles/close.gif"
  82.         ,infoBoxClearance: new google.maps.Size(1, 1)
  83.         ,isHidden: false
  84.         ,pane: "floatPane"
  85.         ,enableEventPropagation: false
  86.     };
  87.     // end example code for custom infobox
  88.     var ib = new InfoBox(myOptions);
  89.  
  90.     google.maps.event.addListener(marker, "click", function (e) {
  91.      // Added this extra line to call in content but now styles on infobox don't work????
  92.      ib.setContent(this.html);
  93.      ib.open(map, this);
  94.     });
  95.  
  96. }
  97. }
  98.  
  99. google.maps.event.addDomListener(window, 'load', initialize);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement