//
// 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('
');
}
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('');
});
}
};
};
//
// 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.47255, -122.42912, 1],[38.359606, -122.310852, 2],[38.276346, -122.354918, 3],[38.4291, -122.3928, 4],[38.584149, -122.568217, 5],[38.414969, -122.336321, 6],[38.576436, -122.535149, 7],[38.325732, -122.274167, 8],[38.46894, -122.42915, 9],[38.54911, -122.505856, 10],[38.594662, -122.614892, 11],[38.510259, -122.478852, 12],[38.222434, -122.331092, 13],[38.557641, -122.472717, 14],[38.496472, -122.540233, 15],[38.447656, -122.41261, 16],[38.4291, -122.3928, 17],[38.545129, -122.490168, 18],[38.561442, -122.538947, 19],[38.470266, -122.398947, 20],[38.235129, -122.314132, 21],[38.483206, -122.356907, 22],[38.601452, -122.598013, 23],[38.394338, -122.447373, 24],[38.393581, -122.321233, 25],[38.423234, -122.346172, 26],[38.381391, -122.310917, 27],[38.569102, -122.555222, 28],[38.486954, -122.404688, 29],[38.485572, -122.446123, 30],[38.574246, -122.547392, 31],[38.360617, -122.290259, 32],[38.338897, -122.262117, 33],[38.31524, -122.273384, 34],[38.251422, -122.35676, 35],[38.397362, -122.359618, 36],[38.528582, -122.488856, 37],[38.576121, -122.526631, 38],[38.604543, -122.402555, 39],[38.247076, -122.318941, 40],[38.5132, -122.4366, 41],[38.48334, -122.42445, 42],[38.488432, -122.449543, 43],[38.517199, -122.487286, 44],[38.422145, -122.390003, 45],[38.473299, -122.431962, 46],[38.563119, -122.520866, 47],[38.309793, -122.247409, 48],[38.51772, -122.48804, 49],[38.467546, -122.398295, 50],[38.454151, -122.36797, 51],[38.489115, -122.348869, 52],[38.431676, -122.355852, 53],[38.47255, -122.42912, 55],[38.447847, -122.3796, 56],[38.490434, -122.451847, 57],[38.324947, -122.284788, 58],[38.49068, -122.4519, 59],[38.598668, -122.622173, 60],[38.334285, -122.378058, 61],[38.403212, -122.363124, 62],[38.4688, -122.40163, 63],[38.354402, -122.216058, 64],[38.521424, -122.473317, 65],[38.51998, -122.535855, 66],[38.490158, -122.432414, 67],[38.491652, -122.344592, 68],[38.56943, -122.456585, 69],[38.355887, -122.33364, 70],[38.562246, -122.521307, 71],[38.491704, -122.453377, 72],[38.344223, -122.282831, 73],[38.51719, -122.48727, 74],[38.502275, -122.465495, 75],[38.484684, -122.445081, 76],[38.46143, -122.36961, 77],[38.360032, -122.311097, 78],[38.47957, -122.39238, 79],[38.44722, -122.41098, 80],[38.435183, -122.401313, 81],[38.574412, -122.540729, 82],[38.421682, -122.393567, 83],[-122.35598, 38.44693, 84],[38.45352, -122.417883, 85],[38.466446, -122.377356, 86],[38.405805, -122.329754, 87],[38.45285, -122.370403, 88],[38.4878427, -122.4070603, 89],[38.484999, -122.439401, 90],[38.43636, -122.4019, 91],[38.424336, -122.337744, 92],[38.548363, -122.491945, 93],[38.46894, -122.42915, 94],[38.47617, -122.43368, 95],[38.49406, -122.40601, 96],[38.557174, -122.532718, 97],[38.506844, -122.491204, 98],[38.51723, -122.487343, 99],[38.45448, -122.42009, 100],[38.413224, -122.335223, 101],[38.410842, -122.333813, 102],[38.570167, -122.554811, 103],[38.47615, -122.42909, 104],[38.595806, -122.601771, 105],[38.4957406, -122.4579986, 106],[38.354233, -122.327942, 107],[38.285558, -122.321029, 108],[38.490674, -122.447098, 109],[38.564089, -122.576072, 110],[38.477565, -122.436672, 111],[38.353544, -122.267263, 112],[38.592, -122.579066, 113],[38.47962, -122.39471, 114],];
// 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);
}
}