function addMarkers()
{
mySelect = document.getElementById('selection');
Alexander = [];Cutler = [];Beals = [];Perry = [];Calais = [];Charlotte = [];Cherryfield = [];Machias = [];Columbia_Falls = [];Addison = [];Danforth = [];Topsfield = [];Eastport = [];Edmonds = [];Steuben = [];East_Machias = [];Machiasport = [];Harrington = [];Princeton = [];Jonesboro = [];Jonesport = [];Lubec = [];Milbridge = [];Pembroke = [];Robbinston = [];Vanceboro = [];Wesley = [];Whiting = [];Baileyville = [];mySelect.options[mySelect.options.length] = new Option("Addison schools",'all=Addison');
mySelect.options[mySelect.options.length] = new Option("Alexander schools",'all=Alexander');
mySelect.options[mySelect.options.length] = new Option("Baileyville schools",'all=Baileyville');
mySelect.options[mySelect.options.length] = new Option("Beals schools",'all=Beals');
mySelect.options[mySelect.options.length] = new Option("Calais schools",'all=Calais');
mySelect.options[mySelect.options.length] = new Option("Charlotte schools",'all=Charlotte');
mySelect.options[mySelect.options.length] = new Option("Cherryfield schools",'all=Cherryfield');
mySelect.options[mySelect.options.length] = new Option("Columbia Falls schools",'all=Columbia_Falls');
mySelect.options[mySelect.options.length] = new Option("Cutler schools",'all=Cutler');
mySelect.options[mySelect.options.length] = new Option("Danforth schools",'all=Danforth');
mySelect.options[mySelect.options.length] = new Option("East Machias schools",'all=East_Machias');
mySelect.options[mySelect.options.length] = new Option("Eastport schools",'all=Eastport');
mySelect.options[mySelect.options.length] = new Option("Edmonds schools",'all=Edmonds');
mySelect.options[mySelect.options.length] = new Option("Harrington schools",'all=Harrington');
mySelect.options[mySelect.options.length] = new Option("Jonesboro schools",'all=Jonesboro');
mySelect.options[mySelect.options.length] = new Option("Jonesport schools",'all=Jonesport');
mySelect.options[mySelect.options.length] = new Option("Lubec schools",'all=Lubec');
mySelect.options[mySelect.options.length] = new Option("Machias schools",'all=Machias');
mySelect.options[mySelect.options.length] = new Option("Machiasport schools",'all=Machiasport');
mySelect.options[mySelect.options.length] = new Option("Milbridge schools",'all=Milbridge');
mySelect.options[mySelect.options.length] = new Option("Pembroke schools",'all=Pembroke');
mySelect.options[mySelect.options.length] = new Option("Perry schools",'all=Perry');
mySelect.options[mySelect.options.length] = new Option("Princeton schools",'all=Princeton');
mySelect.options[mySelect.options.length] = new Option("Robbinston schools",'all=Robbinston');
mySelect.options[mySelect.options.length] = new Option("Steuben schools",'all=Steuben');
mySelect.options[mySelect.options.length] = new Option("Topsfield schools",'all=Topsfield');
mySelect.options[mySelect.options.length] = new Option("Vanceboro schools",'all=Vanceboro');
mySelect.options[mySelect.options.length] = new Option("Wesley schools",'all=Wesley');
mySelect.options[mySelect.options.length] = new Option("Whiting schools",'all=Whiting');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Alexander[Alexander.length] = createMarker(new GPoint(-67.43305969,45.10735703),"
",iconRd);
mySelect.options[mySelect.options.length] = new Option("Alexander Elementary School",'Alexander=' + Alexander.length);
Cutler[Cutler.length] = createMarker(new GPoint(-67.29949951,44.69779968),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Bay Ridge Elementary School",'Cutler=' + Cutler.length);
Beals[Beals.length] = createMarker(new GPoint(-67.61720276,44.51644135),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Beals Elementary School",'Beals=' + Beals.length);
Perry[Perry.length] = createMarker(new GPoint(-67.08319855,44.97480011),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Beatrice Rafferty School",'Perry=' + Perry.length);
Calais[Calais.length] = createMarker(new GPoint(-67.28204346,45.17992020),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Calais Elementary School",'Calais=' + Calais.length);
Calais[Calais.length] = createMarker(new GPoint(-67.26560211,45.17010117),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Calais High School",'Calais=' + Calais.length);
Calais[Calais.length] = createMarker(new GPoint(-67.27815247,45.18651199),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Calais Middle School",'Calais=' + Calais.length);
Charlotte[Charlotte.length] = createMarker(new GPoint(-67.23930359,44.98789978),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Charlotte Elementary School",'Charlotte=' + Charlotte.length);
Cherryfield[Cherryfield.length] = createMarker(new GPoint(-67.95890045,44.70880127),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Cherryfield Elementary School",'Cherryfield=' + Cherryfield.length);
Machias[Machias.length] = createMarker(new GPoint(-67.46330261,44.70579910),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Coastal Wash City Institutional Of Technical High School",'Machias=' + Machias.length);
Columbia_Falls[Columbia_Falls.length] = createMarker(new GPoint(-67.72811890,44.65362930),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Columbia Falls Elementary School",'Columbia_Falls=' + Columbia_Falls.length);
Addison[Addison.length] = createMarker(new GPoint(-67.69916534,44.61925125),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Daniel W Merritt School",'Addison=' + Addison.length);
Danforth[Danforth.length] = createMarker(new GPoint(-67.68195343,45.31465149),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("East Grand School",'Danforth=' + Danforth.length);
Topsfield[Topsfield.length] = createMarker(new GPoint(-67.73589325,45.41899109),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("East Range Ii Csd School",'Topsfield=' + Topsfield.length);
Eastport[Eastport.length] = createMarker(new GPoint(-66.99174500,44.91128540),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Eastport Elementary School",'Eastport=' + Eastport.length);
Edmonds[Edmonds.length] = createMarker(new GPoint(-67.22698212,44.88980103),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Edmunds Consolidated School",'Edmonds=' + Edmonds.length);
Steuben[Steuben.length] = createMarker(new GPoint(-67.96566010,44.51041031),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Ella Lewis School",'Steuben=' + Steuben.length);
East_Machias[East_Machias.length] = createMarker(new GPoint(-67.33139801,44.75849915),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Elm Street School",'East_Machias=' + East_Machias.length);
Machiasport[Machiasport.length] = createMarker(new GPoint(-67.39160156,44.65850067),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Fort O'brien School",'Machiasport=' + Machiasport.length);
Harrington[Harrington.length] = createMarker(new GPoint(-67.80870300,44.61997400),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Harrington Elementary School",'Harrington=' + Harrington.length);
Princeton[Princeton.length] = createMarker(new GPoint(-67.69750214,45.18429947),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Indian Township School",'Princeton=' + Princeton.length);
Jonesboro[Jonesboro.length] = createMarker(new GPoint(-67.57730103,44.66030121),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Jonesboro Elementary School",'Jonesboro=' + Jonesboro.length);
Jonesport[Jonesport.length] = createMarker(new GPoint(-67.59850311,44.53287125),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Jonesport Elementary School",'Jonesport=' + Jonesport.length);
Jonesport[Jonesport.length] = createMarker(new GPoint(-67.59850311,44.53287125),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Jonesport-beals High School",'Jonesport=' + Jonesport.length);
Lubec[Lubec.length] = createMarker(new GPoint(-66.98542786,44.86030960),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Lubec Consolidated School",'Lubec=' + Lubec.length);
Machias[Machias.length] = createMarker(new GPoint(-67.46726227,44.71359634),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Machias Memorial High School",'Machias=' + Machias.length);
East_Machias[East_Machias.length] = createMarker(new GPoint(-67.37064362,44.75727844),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Mary C Burns School",'East_Machias=' + East_Machias.length);
Milbridge[Milbridge.length] = createMarker(new GPoint(-67.88663483,44.53637314),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Milbridge Elementary School",'Milbridge=' + Milbridge.length);
Harrington[Harrington.length] = createMarker(new GPoint(-67.81140137,44.59920120),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Narraguagus High School",'Harrington=' + Harrington.length);
Pembroke[Pembroke.length] = createMarker(new GPoint(-67.16750336,44.91059875),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Pembroke Elementary School",'Pembroke=' + Pembroke.length);
Perry[Perry.length] = createMarker(new GPoint(-67.12339783,45.01029968),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Perry Elementary School",'Perry=' + Perry.length);
Princeton[Princeton.length] = createMarker(new GPoint(-67.55193329,45.21499252),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Princeton Elementary School",'Princeton=' + Princeton.length);
Robbinston[Robbinston.length] = createMarker(new GPoint(-67.10842896,45.07707977),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Robbinston Grade School",'Robbinston=' + Robbinston.length);
Machias[Machias.length] = createMarker(new GPoint(-67.46675873,44.71366501),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Rose M Gaffney School",'Machias=' + Machias.length);
Eastport[Eastport.length] = createMarker(new GPoint(-66.98994446,44.90703201),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Shead High School",'Eastport=' + Eastport.length);
Calais[Calais.length] = createMarker(new GPoint(-67.26560211,45.17010117),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Croix Regional Technology Center",'Calais=' + Calais.length);
Vanceboro[Vanceboro.length] = createMarker(new GPoint(-67.43289948,45.56613922),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Vanceboro Elementary School",'Vanceboro=' + Vanceboro.length);
Wesley[Wesley.length] = createMarker(new GPoint(-67.61170197,44.82180023),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Wesley Elementary School",'Wesley=' + Wesley.length);
Whiting[Whiting.length] = createMarker(new GPoint(-67.16929626,44.85036087),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Whiting Village School",'Whiting=' + Whiting.length);
Baileyville[Baileyville.length] = createMarker(new GPoint(-67.40923309,45.15748215),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Woodland Elementary School",'Baileyville=' + Baileyville.length);
Baileyville[Baileyville.length] = createMarker(new GPoint(-67.40730286,45.15193176),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Woodland Junior Senior High School",'Baileyville=' + Baileyville.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(Addison);
map.removeOverlays(Alexander);
map.removeOverlays(Baileyville);
map.removeOverlays(Beals);
map.removeOverlays(Calais);
map.removeOverlays(Charlotte);
map.removeOverlays(Cherryfield);
map.removeOverlays(Columbia_Falls);
map.removeOverlays(Cutler);
map.removeOverlays(Danforth);
map.removeOverlays(East_Machias);
map.removeOverlays(Eastport);
map.removeOverlays(Edmonds);
map.removeOverlays(Harrington);
map.removeOverlays(Jonesboro);
map.removeOverlays(Jonesport);
map.removeOverlays(Lubec);
map.removeOverlays(Machias);
map.removeOverlays(Machiasport);
map.removeOverlays(Milbridge);
map.removeOverlays(Pembroke);
map.removeOverlays(Perry);
map.removeOverlays(Princeton);
map.removeOverlays(Robbinston);
map.removeOverlays(Steuben);
map.removeOverlays(Topsfield);
map.removeOverlays(Vanceboro);
map.removeOverlays(Wesley);
map.removeOverlays(Whiting);
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(Alexander);map.removeOverlays(Addison);
map.removeOverlays(Alexander);
map.removeOverlays(Baileyville);
map.removeOverlays(Beals);
map.removeOverlays(Calais);
map.removeOverlays(Charlotte);
map.removeOverlays(Cherryfield);
map.removeOverlays(Columbia_Falls);
map.removeOverlays(Cutler);
map.removeOverlays(Danforth);
map.removeOverlays(East_Machias);
map.removeOverlays(Eastport);
map.removeOverlays(Edmonds);
map.removeOverlays(Harrington);
map.removeOverlays(Jonesboro);
map.removeOverlays(Jonesport);
map.removeOverlays(Lubec);
map.removeOverlays(Machias);
map.removeOverlays(Machiasport);
map.removeOverlays(Milbridge);
map.removeOverlays(Pembroke);
map.removeOverlays(Perry);
map.removeOverlays(Princeton);
map.removeOverlays(Robbinston);
map.removeOverlays(Steuben);
map.removeOverlays(Topsfield);
map.removeOverlays(Vanceboro);
map.removeOverlays(Wesley);
map.removeOverlays(Whiting);
map.addOverlays(Addison);
centerByArray(Addison, false, false);
cntMarker += Addison.length;
map.addOverlays(Alexander);
centerByArray(Alexander, false, false);
cntMarker += Alexander.length;
map.addOverlays(Baileyville);
centerByArray(Baileyville, false, false);
cntMarker += Baileyville.length;
map.addOverlays(Beals);
centerByArray(Beals, false, false);
cntMarker += Beals.length;
map.addOverlays(Calais);
centerByArray(Calais, false, false);
cntMarker += Calais.length;
map.addOverlays(Charlotte);
centerByArray(Charlotte, false, false);
cntMarker += Charlotte.length;
map.addOverlays(Cherryfield);
centerByArray(Cherryfield, false, false);
cntMarker += Cherryfield.length;
map.addOverlays(Columbia_Falls);
centerByArray(Columbia_Falls, false, false);
cntMarker += Columbia_Falls.length;
map.addOverlays(Cutler);
centerByArray(Cutler, false, false);
cntMarker += Cutler.length;
map.addOverlays(Danforth);
centerByArray(Danforth, false, false);
cntMarker += Danforth.length;
map.addOverlays(East_Machias);
centerByArray(East_Machias, false, false);
cntMarker += East_Machias.length;
map.addOverlays(Eastport);
centerByArray(Eastport, false, false);
cntMarker += Eastport.length;
map.addOverlays(Edmonds);
centerByArray(Edmonds, false, false);
cntMarker += Edmonds.length;
map.addOverlays(Harrington);
centerByArray(Harrington, false, false);
cntMarker += Harrington.length;
map.addOverlays(Jonesboro);
centerByArray(Jonesboro, false, false);
cntMarker += Jonesboro.length;
map.addOverlays(Jonesport);
centerByArray(Jonesport, false, false);
cntMarker += Jonesport.length;
map.addOverlays(Lubec);
centerByArray(Lubec, false, false);
cntMarker += Lubec.length;
map.addOverlays(Machias);
centerByArray(Machias, false, false);
cntMarker += Machias.length;
map.addOverlays(Machiasport);
centerByArray(Machiasport, false, false);
cntMarker += Machiasport.length;
map.addOverlays(Milbridge);
centerByArray(Milbridge, false, false);
cntMarker += Milbridge.length;
map.addOverlays(Pembroke);
centerByArray(Pembroke, false, false);
cntMarker += Pembroke.length;
map.addOverlays(Perry);
centerByArray(Perry, false, false);
cntMarker += Perry.length;
map.addOverlays(Princeton);
centerByArray(Princeton, false, false);
cntMarker += Princeton.length;
map.addOverlays(Robbinston);
centerByArray(Robbinston, false, false);
cntMarker += Robbinston.length;
map.addOverlays(Steuben);
centerByArray(Steuben, false, false);
cntMarker += Steuben.length;
map.addOverlays(Topsfield);
centerByArray(Topsfield, false, false);
cntMarker += Topsfield.length;
map.addOverlays(Vanceboro);
centerByArray(Vanceboro, false, false);
cntMarker += Vanceboro.length;
map.addOverlays(Wesley);
centerByArray(Wesley, false, false);
cntMarker += Wesley.length;
map.addOverlays(Whiting);
centerByArray(Whiting, false, false);
cntMarker += Whiting.length;
centerByArray(Alexander,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');
}
}