function addMarkers(){ mySelect = document.getElementById('selection'); Edgecomb = [];Poland = [];South_China = [];Bryant_Pond = [];Fryeburg = [];Bangor = [];Glen_Cove = [];Auburn = [];Wiscasset = [];Saco = [];mySelect.options[mySelect.options.length] = new Option("Auburn schools",'all=Auburn'); mySelect.options[mySelect.options.length] = new Option("Bangor schools",'all=Bangor'); mySelect.options[mySelect.options.length] = new Option("Bryant Pond schools",'all=Bryant_Pond'); mySelect.options[mySelect.options.length] = new Option("Edgecomb schools",'all=Edgecomb'); mySelect.options[mySelect.options.length] = new Option("Fryeburg schools",'all=Fryeburg'); mySelect.options[mySelect.options.length] = new Option("Glen Cove schools",'all=Glen_Cove'); mySelect.options[mySelect.options.length] = new Option("Poland schools",'all=Poland'); mySelect.options[mySelect.options.length] = new Option("Saco schools",'all=Saco'); mySelect.options[mySelect.options.length] = new Option("South China schools",'all=South_China'); mySelect.options[mySelect.options.length] = new Option("Wiscasset schools",'all=Wiscasset'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Edgecomb[Edgecomb.length] = createMarker(new GPoint(-69.66449600,43.95234100),"
The Deck House School
124 Deckhouse Road
Edgecomb, ME 04556
All-boys school, 10-12
[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("The Deck House School",'Edgecomb=' + Edgecomb.length); Poland[Poland.length] = createMarker(new GPoint(-70.43919900,44.04436000),"
Elan School
PO Box 578
Poland, ME 04274
Co-ed school, 8-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Elan School",'Poland=' + Poland.length); South_China[South_China.length] = createMarker(new GPoint(-69.57421000,44.37268200),"
Erskine Academy
309 Windsor Road
South China, ME 04358
Co-ed school, 9-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Erskine Academy",'South_China=' + South_China.length); Bryant_Pond[Bryant_Pond.length] = createMarker(new GPoint(-70.56259900,44.38341800),"
Forestdale Sda School
27 Perkins Valley Road
Bryant Pond, ME 04219
Co-ed school, K-9
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Forestdale Sda School",'Bryant_Pond=' + Bryant_Pond.length); Fryeburg[Fryeburg.length] = createMarker(new GPoint(-70.97646600,44.01982200),"
Fryeburg Academy
745 Main Street
Fryeburg, ME 04037
Co-ed school, 9-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Fryeburg Academy",'Fryeburg=' + Fryeburg.length); Bangor[Bangor.length] = createMarker(new GPoint(-68.76839300,44.80542500),"
John Bapst Memorial High School
100 Broadway
Bangor, ME 04401
Co-ed school, 9-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("John Bapst Memorial High School",'Bangor=' + Bangor.length); Poland[Poland.length] = createMarker(new GPoint(-70.34936400,44.07233500),"
Poland Spring Academy
14 Hope Springs Drive
Poland, ME 04274
Co-ed school, PK-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Poland Spring Academy",'Poland=' + Poland.length); Glen_Cove[Glen_Cove.length] = createMarker(new GPoint(-69.09501600,44.13095300),"
Riley School
P.o. Box 300
Glen Cove, ME 04846
Co-ed school, PK-9
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Riley School",'Glen_Cove=' + Glen_Cove.length); Auburn[Auburn.length] = createMarker(new GPoint(-70.25684200,44.03594100),"
Spurwink School--auburn
220 Danville Corner Road
Auburn, ME 04210
Co-ed school, 5-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Spurwink School--auburn",'Auburn=' + Auburn.length); Wiscasset[Wiscasset.length] = createMarker(new GPoint(-69.68590000,43.97010000),"
Svch
Po Box 449
Wiscasset, ME 04578
Co-ed school, PK-3
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Svch",'Wiscasset=' + Wiscasset.length); Saco[Saco.length] = createMarker(new GPoint(-70.43910900,43.50512400),"
Thornton Academy
438 Main Street
Saco, ME 04072
Co-ed school, 9-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Thornton Academy",'Saco=' + Saco.length); map.removeOverlays(Auburn); map.removeOverlays(Bangor); map.removeOverlays(Bryant_Pond); map.removeOverlays(Edgecomb); map.removeOverlays(Fryeburg); map.removeOverlays(Glen_Cove); map.removeOverlays(Poland); map.removeOverlays(Saco); map.removeOverlays(South_China); map.removeOverlays(Wiscasset); setTimeout(function(){map.addOverlays(Auburn)},1000); setTimeout(function(){map.addOverlays(Bangor)},1000); setTimeout(function(){map.addOverlays(Bryant_Pond)},1000); setTimeout(function(){map.addOverlays(Edgecomb)},1000); setTimeout(function(){map.addOverlays(Fryeburg)},1000); setTimeout(function(){map.addOverlays(Glen_Cove)},1000); setTimeout(function(){map.addOverlays(Poland)},1000); setTimeout(function(){map.addOverlays(Saco)},1000); setTimeout(function(){map.addOverlays(South_China)},1000); setTimeout(function(){map.addOverlays(Wiscasset)},1000); maxLng = -68.76839300; maxLat = 44.80542500; minLng = -70.97646600; minLat = 43.50512400; reCenterMap(); } // End addStateMarkers JavaScript Function // Takes an array of markers and centers/zooms map based on marker range function centerByArray(myArray, recenter, newMaxMin) { if (newMaxMin == true) reMaxMin(myArray); for (var i = 0; i < myArray.length; i++) { var markLng = myArray[i].getPoint().x; var markLat = myArray[i].getPoint().y; if (markLat > maxLat) maxLat = markLat; if (markLng > maxLng) maxLng = markLng; if (markLat < minLat) minLat = markLat; if (markLng < minLng) minLng = markLng; } if (recenter) reCenterMap(); } // Reinit max/mins function reMaxMin(myArray) { maxLng = myArray[0].getPoint().x; maxLat = myArray[0].getPoint().y; minLng = myArray[0].getPoint().x; minLat = myArray[0].getPoint().y; } // Recenter map based on global max/mins function reCenterMap() { var bounds = new GLatLngBounds(); bounds.extend(new GLatLng(minLat, minLng)); bounds.extend(new GLatLng(maxLat, maxLng)); var center_lat = (bounds.getNorthEast().lat() + bounds.getSouthWest().lat()) / 2.0; var center_lng = (bounds.getNorthEast().lng() + bounds.getSouthWest().lng()) / 2.0; var center = new GLatLng(center_lat, center_lng); var zoom = map.getBoundsZoomLevel(bounds); map.setCenter(center,zoom); //map.setCenter(center,11); /* var center = new GPoint( (maxLng + minLng)/2, (maxLat+minLat)/2 ); var delta = new GSize(maxLng - minLng, maxLat - minLat); var minZoom = map.spec.getLowestZoomLevel(center, delta, map.viewSize); if (minZoom < 4) minZoom = 4; // Lowest possible zoom is 4 map.centerAndZoom(center, minZoom); */ } // Fires when drop down list of schools changes function selectChange(selection) { var myVal = selection.options[selection.selectedIndex].value; map.closeInfoWindow(); // Add entire array based on variable type if (myVal.indexOf('all') != -1 && myVal != 'all') { var temp = myVal.split('='); var showArray = temp[1]; // If Array is > X amount of markers, then open in a new page if (eval(showArray).length > 20) // New window depends on whether or not we're on the search page if (location.href.indexOf('nearby_schools.php') == -1) window.open(location.href + '/map/' + showArray); else window.open('/search//////' + showArray); map.removeOverlays(Auburn); map.removeOverlays(Bangor); map.removeOverlays(Bryant_Pond); map.removeOverlays(Edgecomb); map.removeOverlays(Fryeburg); map.removeOverlays(Glen_Cove); map.removeOverlays(Poland); map.removeOverlays(Saco); map.removeOverlays(South_China); map.removeOverlays(Wiscasset); map.addOverlays(eval(showArray)); centerByArray(eval(showArray), true, true); // Center and zoom on set of markers } // Add individual markers if (myVal.indexOf('all') == -1 && myVal != 'all' && myVal.length) { var temp = myVal.split('='); var myArray = temp[0]; var myIndex = parseInt(temp[1]) - 1; document.getElementById('map').width = "750"; map.removeOverlay(eval(myArray)[myIndex]); map.addOverlay(eval(myArray)[myIndex]); GEvent.trigger(eval(myArray)[myIndex],'click'); } // Show all markers if (myVal == 'all') { cntMarker = 0; reMaxMin(Edgecomb);map.removeOverlays(Auburn); map.removeOverlays(Bangor); map.removeOverlays(Bryant_Pond); map.removeOverlays(Edgecomb); map.removeOverlays(Fryeburg); map.removeOverlays(Glen_Cove); map.removeOverlays(Poland); map.removeOverlays(Saco); map.removeOverlays(South_China); map.removeOverlays(Wiscasset); map.addOverlays(Auburn); centerByArray(Auburn, false, false); cntMarker += Auburn.length; map.addOverlays(Bangor); centerByArray(Bangor, false, false); cntMarker += Bangor.length; map.addOverlays(Bryant_Pond); centerByArray(Bryant_Pond, false, false); cntMarker += Bryant_Pond.length; map.addOverlays(Edgecomb); centerByArray(Edgecomb, false, false); cntMarker += Edgecomb.length; map.addOverlays(Fryeburg); centerByArray(Fryeburg, false, false); cntMarker += Fryeburg.length; map.addOverlays(Glen_Cove); centerByArray(Glen_Cove, false, false); cntMarker += Glen_Cove.length; map.addOverlays(Poland); centerByArray(Poland, false, false); cntMarker += Poland.length; map.addOverlays(Saco); centerByArray(Saco, false, false); cntMarker += Saco.length; map.addOverlays(South_China); centerByArray(South_China, false, false); cntMarker += South_China.length; map.addOverlays(Wiscasset); centerByArray(Wiscasset, false, false); cntMarker += Wiscasset.length; centerByArray(Edgecomb,true, false); if (cntMarker > 20) // New window depends on whether or not we're on the search page if (location.href.indexOf('schools-by-distance') == -1) window.open(location.href + '/map/all'); else window.open('/search///11948,11933,12009,11934,11981,35973,12014,11930,35974,11933,11981,11928,35973,11987,/all'); //window.open('/map.php?type=2&schools=11948,11933,12009,11934,11981,35973,12014,11930,35974,11933,11981,11928,35973,11987,&school_level=&radius=&zipcode=&school_type_search=&school_type_code='); } } function createMarker(point, label, icon) { var marker = new GMarker(point, icon); var html = label; GEvent.addListener(marker, "click", function() { marker.openInfoWindowHtml(html); }); return marker; }