function addMarkers()
{
mySelect = document.getElementById('selection');
Waterville = [];Albion = [];Belgrade = [];Benton = [];Augusta = [];Litchfield = [];Chelsea = [];S_China = [];Clinton = [];Fayette = [];Gardiner = [];Hallowell = [];Farmingdale = [];West_Gardiner = [];Monmouth = [];Sidney = [];Manchester = [];Readfield = [];Oakland = [];Mount_Vernon = [];S_Gardiner = [];Randolph = [];Vassalboro = [];Wayne = [];Windsor = [];Winslow = [];Winthrop = [];mySelect.options[mySelect.options.length] = new Option("Albion schools",'all=Albion');
mySelect.options[mySelect.options.length] = new Option("Augusta schools",'all=Augusta');
mySelect.options[mySelect.options.length] = new Option("Belgrade schools",'all=Belgrade');
mySelect.options[mySelect.options.length] = new Option("Benton schools",'all=Benton');
mySelect.options[mySelect.options.length] = new Option("Chelsea schools",'all=Chelsea');
mySelect.options[mySelect.options.length] = new Option("Clinton schools",'all=Clinton');
mySelect.options[mySelect.options.length] = new Option("Farmingdale schools",'all=Farmingdale');
mySelect.options[mySelect.options.length] = new Option("Fayette schools",'all=Fayette');
mySelect.options[mySelect.options.length] = new Option("Gardiner schools",'all=Gardiner');
mySelect.options[mySelect.options.length] = new Option("Hallowell schools",'all=Hallowell');
mySelect.options[mySelect.options.length] = new Option("Litchfield schools",'all=Litchfield');
mySelect.options[mySelect.options.length] = new Option("Manchester schools",'all=Manchester');
mySelect.options[mySelect.options.length] = new Option("Monmouth schools",'all=Monmouth');
mySelect.options[mySelect.options.length] = new Option("Mount Vernon schools",'all=Mount_Vernon');
mySelect.options[mySelect.options.length] = new Option("Oakland schools",'all=Oakland');
mySelect.options[mySelect.options.length] = new Option("Randolph schools",'all=Randolph');
mySelect.options[mySelect.options.length] = new Option("Readfield schools",'all=Readfield');
mySelect.options[mySelect.options.length] = new Option("S China schools",'all=S_China');
mySelect.options[mySelect.options.length] = new Option("S Gardiner schools",'all=S_Gardiner');
mySelect.options[mySelect.options.length] = new Option("Sidney schools",'all=Sidney');
mySelect.options[mySelect.options.length] = new Option("Vassalboro schools",'all=Vassalboro');
mySelect.options[mySelect.options.length] = new Option("Waterville schools",'all=Waterville');
mySelect.options[mySelect.options.length] = new Option("Wayne schools",'all=Wayne');
mySelect.options[mySelect.options.length] = new Option("West Gardiner schools",'all=West_Gardiner');
mySelect.options[mySelect.options.length] = new Option("Windsor schools",'all=Windsor');
mySelect.options[mySelect.options.length] = new Option("Winslow schools",'all=Winslow');
mySelect.options[mySelect.options.length] = new Option("Winthrop schools",'all=Winthrop');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Waterville[Waterville.length] = createMarker(new GPoint(-69.63597107,44.55012131),"
",iconBl);
mySelect.options[mySelect.options.length] = new Option("Albert S Hall School",'Waterville=' + Waterville.length);
Albion[Albion.length] = createMarker(new GPoint(-69.43910217,44.51839828),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Albion Elementary School",'Albion=' + Albion.length);
Belgrade[Belgrade.length] = createMarker(new GPoint(-69.83212280,44.44670105),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Belgrade Central School",'Belgrade=' + Belgrade.length);
Benton[Benton.length] = createMarker(new GPoint(-69.65003204,44.54824448),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Benton Elementary School",'Benton=' + Benton.length);
Augusta[Augusta.length] = createMarker(new GPoint(-69.77976227,44.31053162),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Capital Area Technology Center",'Augusta=' + Augusta.length);
Litchfield[Litchfield.length] = createMarker(new GPoint(-69.97326660,44.13420486),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Carrie Ricker Middle School",'Litchfield=' + Litchfield.length);
Chelsea[Chelsea.length] = createMarker(new GPoint(-69.69895172,44.26752853),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Chelsea Elementary School",'Chelsea=' + Chelsea.length);
S_China[S_China.length] = createMarker(new GPoint(-69.52749634,44.43857956),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("China Middle School",'S_China=' + S_China.length);
S_China[S_China.length] = createMarker(new GPoint(-69.52754211,44.43844604),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("China Primary School",'S_China=' + S_China.length);
Clinton[Clinton.length] = createMarker(new GPoint(-69.50222015,44.64120102),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Clinton Elementary School",'Clinton=' + Clinton.length);
Augusta[Augusta.length] = createMarker(new GPoint(-69.76576996,44.31619263),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Cony High School",'Augusta=' + Augusta.length);
Augusta[Augusta.length] = createMarker(new GPoint(-69.75775909,44.31644058),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Ella R Hodgkins School",'Augusta=' + Augusta.length);
Augusta[Augusta.length] = createMarker(new GPoint(-69.74858093,44.30619431),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Farrington School",'Augusta=' + Augusta.length);
Fayette[Fayette.length] = createMarker(new GPoint(-70.00051117,44.40488815),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Fayette Central School",'Fayette=' + Fayette.length);
Gardiner[Gardiner.length] = createMarker(new GPoint(-69.79061127,44.22517776),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Gardiner Area High School",'Gardiner=' + Gardiner.length);
Gardiner[Gardiner.length] = createMarker(new GPoint(-69.79946899,44.21723175),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Gardiner Regional Middle School",'Gardiner=' + Gardiner.length);
Waterville[Waterville.length] = createMarker(new GPoint(-69.62898254,44.56818390),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("George J Mitchell School",'Waterville=' + Waterville.length);
Hallowell[Hallowell.length] = createMarker(new GPoint(-69.79052734,44.28892899),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Hall-dale Elementary School",'Hallowell=' + Hallowell.length);
Farmingdale[Farmingdale.length] = createMarker(new GPoint(-69.81364441,44.26479340),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Hall-dale High School",'Farmingdale=' + Farmingdale.length);
Farmingdale[Farmingdale.length] = createMarker(new GPoint(-69.81049347,44.26443863),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Hall-dale Middle School",'Farmingdale=' + Farmingdale.length);
West_Gardiner[West_Gardiner.length] = createMarker(new GPoint(-69.88195801,44.20690155),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Helen Thompson School",'West_Gardiner=' + West_Gardiner.length);
Monmouth[Monmouth.length] = createMarker(new GPoint(-70.03788757,44.25514603),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Henry L Cottrell School",'Monmouth=' + Monmouth.length);
Sidney[Sidney.length] = createMarker(new GPoint(-69.74195099,44.44334793),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("James H Bean School",'Sidney=' + Sidney.length);
Gardiner[Gardiner.length] = createMarker(new GPoint(-69.78058624,44.21889496),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Laura E Richards School",'Gardiner=' + Gardiner.length);
Litchfield[Litchfield.length] = createMarker(new GPoint(-69.97028351,44.12178040),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Libby-tozier School",'Litchfield=' + Litchfield.length);
Augusta[Augusta.length] = createMarker(new GPoint(-69.76251984,44.32096100),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Lillian Parks Hussey School",'Augusta=' + Augusta.length);
Augusta[Augusta.length] = createMarker(new GPoint(-69.78644562,44.31301880),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Lincoln School",'Augusta=' + Augusta.length);
Manchester[Manchester.length] = createMarker(new GPoint(-69.86064148,44.32466888),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Manchester Elementary School",'Manchester=' + Manchester.length);
Readfield[Readfield.length] = createMarker(new GPoint(-69.95368195,44.39664078),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Maranacook Community High School",'Readfield=' + Readfield.length);
Readfield[Readfield.length] = createMarker(new GPoint(-69.95368195,44.39664078),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Maranacook Community Middle School",'Readfield=' + Readfield.length);
Oakland[Oakland.length] = createMarker(new GPoint(-69.71572876,44.55744934),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Messalonskee High School",'Oakland=' + Oakland.length);
Oakland[Oakland.length] = createMarker(new GPoint(-69.71723938,44.55003738),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Messalonskee Middle School",'Oakland=' + Oakland.length);
Waterville[Waterville.length] = createMarker(new GPoint(-69.64225769,44.55096054),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Mid-maine Technical Center",'Waterville=' + Waterville.length);
Monmouth[Monmouth.length] = createMarker(new GPoint(-70.03742981,44.24963379),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Monmouth Academy",'Monmouth=' + Monmouth.length);
Monmouth[Monmouth.length] = createMarker(new GPoint(-70.00370026,44.22999954),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Monmouth Middle School",'Monmouth=' + Monmouth.length);
Mount_Vernon[Mount_Vernon.length] = createMarker(new GPoint(-69.98390198,44.50067902),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Mt Vernon Elementary School",'Mount_Vernon=' + Mount_Vernon.length);
Gardiner[Gardiner.length] = createMarker(new GPoint(-69.73970032,44.19739914),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Pittston Consolidated School",'Gardiner=' + Gardiner.length);
Gardiner[Gardiner.length] = createMarker(new GPoint(-69.78524017,44.23072052),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Pray Street School",'Gardiner=' + Gardiner.length);
Oakland[Oakland.length] = createMarker(new GPoint(-69.72057343,44.54946899),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Ralph M Atwood School",'Oakland=' + Oakland.length);
Readfield[Readfield.length] = createMarker(new GPoint(-69.94058228,44.37363052),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Readfield Elementary School",'Readfield=' + Readfield.length);
S_Gardiner[S_Gardiner.length] = createMarker(new GPoint(-69.75637817,44.17977905),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("River View Community School",'S_Gardiner=' + S_Gardiner.length);
Augusta[Augusta.length] = createMarker(new GPoint(-69.78054047,44.33295822),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Sylvio J Gilbert School",'Augusta=' + Augusta.length);
Randolph[Randolph.length] = createMarker(new GPoint(-69.76712036,44.23428726),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Teresa C Hamlin Elementary School",'Randolph=' + Randolph.length);
Vassalboro[Vassalboro.length] = createMarker(new GPoint(-69.65417480,44.43299484),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Vassalboro Community School",'Vassalboro=' + Vassalboro.length);
Waterville[Waterville.length] = createMarker(new GPoint(-69.64225769,44.55096054),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Waterville High School",'Waterville=' + Waterville.length);
Waterville[Waterville.length] = createMarker(new GPoint(-69.66580963,44.52679825),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Waterville Junior High School",'Waterville=' + Waterville.length);
Wayne[Wayne.length] = createMarker(new GPoint(-70.05719757,44.34669876),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Wayne Elementary School",'Wayne=' + Wayne.length);
Oakland[Oakland.length] = createMarker(new GPoint(-69.72143555,44.54965973),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Williams Elementary School",'Oakland=' + Oakland.length);
Windsor[Windsor.length] = createMarker(new GPoint(-69.58106995,44.31050110),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Windsor Elementary School",'Windsor=' + Windsor.length);
Winslow[Winslow.length] = createMarker(new GPoint(-69.62459564,44.54964066),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Winslow Elementary School",'Winslow=' + Winslow.length);
Winslow[Winslow.length] = createMarker(new GPoint(-69.62220001,44.55121994),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Winslow High School",'Winslow=' + Winslow.length);
Winslow[Winslow.length] = createMarker(new GPoint(-69.62223816,44.55124664),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Winslow Junior High School",'Winslow=' + Winslow.length);
Winthrop[Winthrop.length] = createMarker(new GPoint(-69.96779633,44.30591965),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Winthrop Grade School",'Winthrop=' + Winthrop.length);
Winthrop[Winthrop.length] = createMarker(new GPoint(-69.96733093,44.30503082),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Winthrop High School",'Winthrop=' + Winthrop.length);
Winthrop[Winthrop.length] = createMarker(new GPoint(-69.98459625,44.30146408),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Winthrop Middle School",'Winthrop=' + Winthrop.length);
} // 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,10);
/*
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(Albion);
map.removeOverlays(Augusta);
map.removeOverlays(Belgrade);
map.removeOverlays(Benton);
map.removeOverlays(Chelsea);
map.removeOverlays(Clinton);
map.removeOverlays(Farmingdale);
map.removeOverlays(Fayette);
map.removeOverlays(Gardiner);
map.removeOverlays(Hallowell);
map.removeOverlays(Litchfield);
map.removeOverlays(Manchester);
map.removeOverlays(Monmouth);
map.removeOverlays(Mount_Vernon);
map.removeOverlays(Oakland);
map.removeOverlays(Randolph);
map.removeOverlays(Readfield);
map.removeOverlays(S_China);
map.removeOverlays(S_Gardiner);
map.removeOverlays(Sidney);
map.removeOverlays(Vassalboro);
map.removeOverlays(Waterville);
map.removeOverlays(Wayne);
map.removeOverlays(West_Gardiner);
map.removeOverlays(Windsor);
map.removeOverlays(Winslow);
map.removeOverlays(Winthrop);
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(Waterville);map.removeOverlays(Albion);
map.removeOverlays(Augusta);
map.removeOverlays(Belgrade);
map.removeOverlays(Benton);
map.removeOverlays(Chelsea);
map.removeOverlays(Clinton);
map.removeOverlays(Farmingdale);
map.removeOverlays(Fayette);
map.removeOverlays(Gardiner);
map.removeOverlays(Hallowell);
map.removeOverlays(Litchfield);
map.removeOverlays(Manchester);
map.removeOverlays(Monmouth);
map.removeOverlays(Mount_Vernon);
map.removeOverlays(Oakland);
map.removeOverlays(Randolph);
map.removeOverlays(Readfield);
map.removeOverlays(S_China);
map.removeOverlays(S_Gardiner);
map.removeOverlays(Sidney);
map.removeOverlays(Vassalboro);
map.removeOverlays(Waterville);
map.removeOverlays(Wayne);
map.removeOverlays(West_Gardiner);
map.removeOverlays(Windsor);
map.removeOverlays(Winslow);
map.removeOverlays(Winthrop);
map.addOverlays(Albion);
centerByArray(Albion, false, false);
cntMarker += Albion.length;
map.addOverlays(Augusta);
centerByArray(Augusta, false, false);
cntMarker += Augusta.length;
map.addOverlays(Belgrade);
centerByArray(Belgrade, false, false);
cntMarker += Belgrade.length;
map.addOverlays(Benton);
centerByArray(Benton, false, false);
cntMarker += Benton.length;
map.addOverlays(Chelsea);
centerByArray(Chelsea, false, false);
cntMarker += Chelsea.length;
map.addOverlays(Clinton);
centerByArray(Clinton, false, false);
cntMarker += Clinton.length;
map.addOverlays(Farmingdale);
centerByArray(Farmingdale, false, false);
cntMarker += Farmingdale.length;
map.addOverlays(Fayette);
centerByArray(Fayette, false, false);
cntMarker += Fayette.length;
map.addOverlays(Gardiner);
centerByArray(Gardiner, false, false);
cntMarker += Gardiner.length;
map.addOverlays(Hallowell);
centerByArray(Hallowell, false, false);
cntMarker += Hallowell.length;
map.addOverlays(Litchfield);
centerByArray(Litchfield, false, false);
cntMarker += Litchfield.length;
map.addOverlays(Manchester);
centerByArray(Manchester, false, false);
cntMarker += Manchester.length;
map.addOverlays(Monmouth);
centerByArray(Monmouth, false, false);
cntMarker += Monmouth.length;
map.addOverlays(Mount_Vernon);
centerByArray(Mount_Vernon, false, false);
cntMarker += Mount_Vernon.length;
map.addOverlays(Oakland);
centerByArray(Oakland, false, false);
cntMarker += Oakland.length;
map.addOverlays(Randolph);
centerByArray(Randolph, false, false);
cntMarker += Randolph.length;
map.addOverlays(Readfield);
centerByArray(Readfield, false, false);
cntMarker += Readfield.length;
map.addOverlays(S_China);
centerByArray(S_China, false, false);
cntMarker += S_China.length;
map.addOverlays(S_Gardiner);
centerByArray(S_Gardiner, false, false);
cntMarker += S_Gardiner.length;
map.addOverlays(Sidney);
centerByArray(Sidney, false, false);
cntMarker += Sidney.length;
map.addOverlays(Vassalboro);
centerByArray(Vassalboro, false, false);
cntMarker += Vassalboro.length;
map.addOverlays(Waterville);
centerByArray(Waterville, false, false);
cntMarker += Waterville.length;
map.addOverlays(Wayne);
centerByArray(Wayne, false, false);
cntMarker += Wayne.length;
map.addOverlays(West_Gardiner);
centerByArray(West_Gardiner, false, false);
cntMarker += West_Gardiner.length;
map.addOverlays(Windsor);
centerByArray(Windsor, false, false);
cntMarker += Windsor.length;
map.addOverlays(Winslow);
centerByArray(Winslow, false, false);
cntMarker += Winslow.length;
map.addOverlays(Winthrop);
centerByArray(Winthrop, false, false);
cntMarker += Winthrop.length;
centerByArray(Waterville,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////all');
}
}