// // This JS file sets up the Gmap and shows all of the locations in a specific region. Its // used by the maps app for the home page. // if (GBrowserIsCompatible()) { var gmarkers = []; // // Function linked to "Map It!" button to open marker windows given a location ID. // function map_it_click(location_id) { GEvent.trigger(gmarkers[location_id], "click"); window.location.hash="map"; } // // custom icon to use on the map // var icon = new GIcon(); icon.image = "http://labs.google.com/ridefinder/images/mm_20_red.png"; icon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png"; icon.iconSize = new GSize(12, 20); icon.shadowSize = new GSize(22, 20); icon.iconAnchor = new GPoint(6, 20); icon.infoWindowAnchor = new GPoint(5, 1); // // create the map and center it on the napa valley // var map = new GMap2(document.getElementById("map")); map.addControl(new GLargeMapControl()); map.setCenter(new GLatLng(38.4,-122.45), 10); // // setup the ad unit on the map // var publisher_id = "pub-4573498472547028"; adsManagerOptions = { maxAdsOnMap : 2, style: 'adunit', channel: '6137780196' }; adsManager = new GAdsManager(map, publisher_id, adsManagerOptions); adsManager.enable(); // // Generate a "click" listener given a location ID. // var generate_listener = function(location_id){ return function(){ var marker = gmarkers[location_id]; if (marker.retrieved == true){ marker.openInfoWindowHtml('
'+marker.content+'
'); } else { // Load the location info and store it in the marker object. $.getJSON('/api/location/id/'+marker.location_id, function(json){ marker.content = json.content; marker.retrieved = true; marker.openInfoWindowHtml('
'+marker.content+'
'); }); } }; }; // // Setup all marks. // // Array of location data needed for marks. The html for the windows is loaded async when "click" action is // triggered. All location data is in a giant array to save space. var locations = [[38.578616, -122.578933, 115],[38.296216, -122.283121, 116],[38.561773, -122.539821, 117],[38.400898, -122.360015, 118],[38.401952, -122.361233, 119],[38.418019, -122.386937, 120],[38.295917, -122.282917, 121],[38.505044, -122.468689, 122],[38.300076, -122.286174, 123],[38.287772, -122.309923, 124],[38.296478, -122.292934, 125],[38.46167, -122.41888, 126],[38.503403, -122.468359, 127],[38.418892, -122.387585, 128],[38.319602, -122.298971, 129],[38.40547, -122.36618, 130],[38.399293, -122.358889, 131],[38.50399, -122.468246, 132],[38.459185, -122.421992, 133],[38.505263, -122.468914, 134],[38.404364, -122.365131, 135],[38.501669, -122.463412, 136],[38.29921, -122.285533, 137],[38.578673, -122.579219, 138],]; // Add a marker for for each location in locations array. for(key in locations){ var marker = new GMarker(new GLatLng(locations[key][0], locations[key][1]), icon); marker.location_id = locations[key][2]; marker.retrieved = false; GEvent.addListener(marker, "click", generate_listener(marker.location_id)); gmarkers[marker.location_id] = marker; map.addOverlay(marker); } }