function addMarkers()
{
mySelect = document.getElementById('selection');
Camp_Hill = [];Carlisle = [];Newville = [];Boiling_Springs = [];Mechanicsburg = [];Enola = [];Shippensburg = [];New_Cumberland = [];Lemoyne = [];Shiremanstown = [];Mount_Holly_Springs = [];mySelect.options[mySelect.options.length] = new Option("Boiling Springs schools",'all=Boiling_Springs');
mySelect.options[mySelect.options.length] = new Option("Camp Hill schools",'all=Camp_Hill');
mySelect.options[mySelect.options.length] = new Option("Carlisle schools",'all=Carlisle');
mySelect.options[mySelect.options.length] = new Option("Enola schools",'all=Enola');
mySelect.options[mySelect.options.length] = new Option("Lemoyne schools",'all=Lemoyne');
mySelect.options[mySelect.options.length] = new Option("Mechanicsburg schools",'all=Mechanicsburg');
mySelect.options[mySelect.options.length] = new Option("Mount Holly Springs schools",'all=Mount_Holly_Springs');
mySelect.options[mySelect.options.length] = new Option("New Cumberland schools",'all=New_Cumberland');
mySelect.options[mySelect.options.length] = new Option("Newville schools",'all=Newville');
mySelect.options[mySelect.options.length] = new Option("Shippensburg schools",'all=Shippensburg');
mySelect.options[mySelect.options.length] = new Option("Shiremanstown schools",'all=Shiremanstown');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Camp_Hill[Camp_Hill.length] = createMarker(new GPoint(-76.95114899,40.21650314),"
",iconBl);
mySelect.options[mySelect.options.length] = new Option("Allen Middle School",'Camp_Hill=' + Camp_Hill.length);
Carlisle[Carlisle.length] = createMarker(new GPoint(-77.20339966,40.20677948),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Bellaire Elementary School",'Carlisle=' + Carlisle.length);
Newville[Newville.length] = createMarker(new GPoint(-77.38427734,40.17431641),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Big Spring High School",'Newville=' + Newville.length);
Newville[Newville.length] = createMarker(new GPoint(-77.38413239,40.17427826),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Big Spring Middle School",'Newville=' + Newville.length);
Boiling_Springs[Boiling_Springs.length] = createMarker(new GPoint(-77.13197327,40.15198517),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Boiling Springs High School",'Boiling_Springs=' + Boiling_Springs.length);
Mechanicsburg[Mechanicsburg.length] = createMarker(new GPoint(-77.01651001,40.20822525),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Broad Street Elementary School",'Mechanicsburg=' + Mechanicsburg.length);
Camp_Hill[Camp_Hill.length] = createMarker(new GPoint(-76.92547607,40.23876190),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Camp Hill Middle School",'Camp_Hill=' + Camp_Hill.length);
Camp_Hill[Camp_Hill.length] = createMarker(new GPoint(-76.92547607,40.23876190),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Camp Hill Senior High School",'Camp_Hill=' + Camp_Hill.length);
Carlisle[Carlisle.length] = createMarker(new GPoint(-77.20339966,40.20677948),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Carlisle Area High School",'Carlisle=' + Carlisle.length);
Camp_Hill[Camp_Hill.length] = createMarker(new GPoint(-76.89994049,40.23128128),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Cedar Cliff High School",'Camp_Hill=' + Camp_Hill.length);
Mechanicsburg[Mechanicsburg.length] = createMarker(new GPoint(-76.87516022,40.25551987),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Commonwealth Connections Academy",'Mechanicsburg=' + Mechanicsburg.length);
Carlisle[Carlisle.length] = createMarker(new GPoint(-77.20339966,40.20677948),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Crestview Elementary School",'Carlisle=' + Carlisle.length);
Mechanicsburg[Mechanicsburg.length] = createMarker(new GPoint(-77.06110382,40.23792648),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Cumberland Valley High School",'Mechanicsburg=' + Mechanicsburg.length);
Mechanicsburg[Mechanicsburg.length] = createMarker(new GPoint(-77.03915405,40.25778961),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Cumberland-perry Avts",'Mechanicsburg=' + Mechanicsburg.length);
Mechanicsburg[Mechanicsburg.length] = createMarker(new GPoint(-77.06110382,40.23792648),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Eagle View Middle School",'Mechanicsburg=' + Mechanicsburg.length);
Enola[Enola.length] = createMarker(new GPoint(-76.94049072,40.30118942),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("East Pennsboro Area Middle School",'Enola=' + Enola.length);
Enola[Enola.length] = createMarker(new GPoint(-76.94033051,40.29544830),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("East Pennsboro Area Senior High School",'Enola=' + Enola.length);
Enola[Enola.length] = createMarker(new GPoint(-76.94441986,40.30033112),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("East Pennsboro Elementary School",'Enola=' + Enola.length);
Camp_Hill[Camp_Hill.length] = createMarker(new GPoint(-76.92253113,40.24803162),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Eisenhower Elementary School",'Camp_Hill=' + Camp_Hill.length);
Mechanicsburg[Mechanicsburg.length] = createMarker(new GPoint(-76.99644470,40.21089554),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Filbert Street Elementary School",'Mechanicsburg=' + Mechanicsburg.length);
Newville[Newville.length] = createMarker(new GPoint(-77.35973358,40.24911499),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Frankford Elementary School",'Newville=' + Newville.length);
Mechanicsburg[Mechanicsburg.length] = createMarker(new GPoint(-76.98219299,40.25139236),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Good Hope Middle School",'Mechanicsburg=' + Mechanicsburg.length);
Shippensburg[Shippensburg.length] = createMarker(new GPoint(-77.52056885,40.05057907),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Grace B Luhrs Univ Elementary School",'Shippensburg=' + Shippensburg.length);
Mechanicsburg[Mechanicsburg.length] = createMarker(new GPoint(-77.05297852,40.26860428),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Green Ridge Elementary School",'Mechanicsburg=' + Mechanicsburg.length);
Carlisle[Carlisle.length] = createMarker(new GPoint(-77.20339966,40.20677948),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Hamilton Elementary School",'Carlisle=' + Carlisle.length);
Mechanicsburg[Mechanicsburg.length] = createMarker(new GPoint(-76.98268127,40.25133514),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Hampden Elementary School",'Mechanicsburg=' + Mechanicsburg.length);
Camp_Hill[Camp_Hill.length] = createMarker(new GPoint(-76.89767456,40.23096466),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Highland Elementary School",'Camp_Hill=' + Camp_Hill.length);
New_Cumberland[New_Cumberland.length] = createMarker(new GPoint(-76.87422943,40.22750854),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Hillside Elementary School",'New_Cumberland=' + New_Cumberland.length);
Camp_Hill[Camp_Hill.length] = createMarker(new GPoint(-76.92472076,40.23541641),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Hoover Elementary School",'Camp_Hill=' + Camp_Hill.length);
Boiling_Springs[Boiling_Springs.length] = createMarker(new GPoint(-77.13197327,40.15198517),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Iron Forge Educnl Center",'Boiling_Springs=' + Boiling_Springs.length);
Shippensburg[Shippensburg.length] = createMarker(new GPoint(-77.50404358,40.05279922),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("James Burd Elementary School",'Shippensburg=' + Shippensburg.length);
Carlisle[Carlisle.length] = createMarker(new GPoint(-77.20339966,40.20677948),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Lamberton Middle School",'Carlisle=' + Carlisle.length);
Lemoyne[Lemoyne.length] = createMarker(new GPoint(-76.90014648,40.24466705),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Lemoyne Middle School",'Lemoyne=' + Lemoyne.length);
Carlisle[Carlisle.length] = createMarker(new GPoint(-77.20339966,40.20677948),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Letort Elementary School",'Carlisle=' + Carlisle.length);
Camp_Hill[Camp_Hill.length] = createMarker(new GPoint(-76.94644928,40.21943665),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Lower Allen Elementary School",'Camp_Hill=' + Camp_Hill.length);
Mechanicsburg[Mechanicsburg.length] = createMarker(new GPoint(-77.01490784,40.20502472),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Mechanicsburg Area Senior High School",'Mechanicsburg=' + Mechanicsburg.length);
Mechanicsburg[Mechanicsburg.length] = createMarker(new GPoint(-76.99247742,40.18339920),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Mechanicsburg Middle School",'Mechanicsburg=' + Mechanicsburg.length);
Carlisle[Carlisle.length] = createMarker(new GPoint(-77.13969421,40.25696182),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Middlesex Elementary School",'Carlisle=' + Carlisle.length);
Newville[Newville.length] = createMarker(new GPoint(-77.47129059,40.21262741),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Mifflin Elementary School",'Newville=' + Newville.length);
Boiling_Springs[Boiling_Springs.length] = createMarker(new GPoint(-77.08085632,40.16636658),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Monroe Elementary School",'Boiling_Springs=' + Boiling_Springs.length);
Carlisle[Carlisle.length] = createMarker(new GPoint(-77.20339966,40.20677948),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Mooreland Elementary School",'Carlisle=' + Carlisle.length);
Carlisle[Carlisle.length] = createMarker(new GPoint(-77.20339966,40.20677948),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Mt Holly Springs Elementary School",'Carlisle=' + Carlisle.length);
New_Cumberland[New_Cumberland.length] = createMarker(new GPoint(-76.87142944,40.23049545),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("New Cumberland Middle School",'New_Cumberland=' + New_Cumberland.length);
Newville[Newville.length] = createMarker(new GPoint(-77.40217590,40.17486191),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Newville Elementary School",'Newville=' + Newville.length);
Carlisle[Carlisle.length] = createMarker(new GPoint(-77.20339966,40.20677948),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("North Dickinson Elementary School",'Carlisle=' + Carlisle.length);
Mechanicsburg[Mechanicsburg.length] = createMarker(new GPoint(-77.00560760,40.21898651),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Northside Elementary School",'Mechanicsburg=' + Mechanicsburg.length);
Newville[Newville.length] = createMarker(new GPoint(-77.38481140,40.15822983),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Oak Flat Elementary School",'Newville=' + Newville.length);
Carlisle[Carlisle.length] = createMarker(new GPoint(-77.29320526,40.19832611),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Plainfield Elementary School",'Carlisle=' + Carlisle.length);
Mechanicsburg[Mechanicsburg.length] = createMarker(new GPoint(-76.95146942,40.20144272),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Rossmoyne Elementary School",'Mechanicsburg=' + Mechanicsburg.length);
Camp_Hill[Camp_Hill.length] = createMarker(new GPoint(-76.92969513,40.24162292),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Schaeffer Elementary School",'Camp_Hill=' + Camp_Hill.length);
Enola[Enola.length] = createMarker(new GPoint(-76.98623657,40.28489685),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Shaull Elementary School",'Enola=' + Enola.length);
Mechanicsburg[Mechanicsburg.length] = createMarker(new GPoint(-76.99323273,40.18035889),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Shepherdstown Elementary School",'Mechanicsburg=' + Mechanicsburg.length);
Shippensburg[Shippensburg.length] = createMarker(new GPoint(-77.54339600,40.04061890),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Shippensburg Area Senior High School",'Shippensburg=' + Shippensburg.length);
Shiremanstown[Shiremanstown.length] = createMarker(new GPoint(-76.95323181,40.22286606),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Shiremanstown Elementary School",'Shiremanstown=' + Shiremanstown.length);
Mechanicsburg[Mechanicsburg.length] = createMarker(new GPoint(-77.06110382,40.23792648),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Silver Spring Elementary School",'Mechanicsburg=' + Mechanicsburg.length);
Mechanicsburg[Mechanicsburg.length] = createMarker(new GPoint(-76.97200775,40.23434448),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Sporting Hill Elementary School",'Mechanicsburg=' + Mechanicsburg.length);
Mechanicsburg[Mechanicsburg.length] = createMarker(new GPoint(-76.99213409,40.18230057),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Upper Allen Elementary School",'Mechanicsburg=' + Mechanicsburg.length);
Mount_Holly_Springs[Mount_Holly_Springs.length] = createMarker(new GPoint(-77.19203949,40.12960434),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("W.g. Rice Elementary School",'Mount_Holly_Springs=' + Mount_Holly_Springs.length);
Lemoyne[Lemoyne.length] = createMarker(new GPoint(-76.89844513,40.24628448),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Washington Heights Elementary School",'Lemoyne=' + Lemoyne.length);
Camp_Hill[Camp_Hill.length] = createMarker(new GPoint(-76.92661285,40.27098083),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("West Creek Hills Elementary School",'Camp_Hill=' + Camp_Hill.length);
Carlisle[Carlisle.length] = createMarker(new GPoint(-77.20339966,40.20677948),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Wilson Middle School",'Carlisle=' + Carlisle.length);
Boiling_Springs[Boiling_Springs.length] = createMarker(new GPoint(-77.13197327,40.15198517),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Yellow Breeches Middle School",'Boiling_Springs=' + Boiling_Springs.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(Boiling_Springs);
map.removeOverlays(Camp_Hill);
map.removeOverlays(Carlisle);
map.removeOverlays(Enola);
map.removeOverlays(Lemoyne);
map.removeOverlays(Mechanicsburg);
map.removeOverlays(Mount_Holly_Springs);
map.removeOverlays(New_Cumberland);
map.removeOverlays(Newville);
map.removeOverlays(Shippensburg);
map.removeOverlays(Shiremanstown);
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(Camp_Hill);map.removeOverlays(Boiling_Springs);
map.removeOverlays(Camp_Hill);
map.removeOverlays(Carlisle);
map.removeOverlays(Enola);
map.removeOverlays(Lemoyne);
map.removeOverlays(Mechanicsburg);
map.removeOverlays(Mount_Holly_Springs);
map.removeOverlays(New_Cumberland);
map.removeOverlays(Newville);
map.removeOverlays(Shippensburg);
map.removeOverlays(Shiremanstown);
map.addOverlays(Boiling_Springs);
centerByArray(Boiling_Springs, false, false);
cntMarker += Boiling_Springs.length;
map.addOverlays(Camp_Hill);
centerByArray(Camp_Hill, false, false);
cntMarker += Camp_Hill.length;
map.addOverlays(Carlisle);
centerByArray(Carlisle, false, false);
cntMarker += Carlisle.length;
map.addOverlays(Enola);
centerByArray(Enola, false, false);
cntMarker += Enola.length;
map.addOverlays(Lemoyne);
centerByArray(Lemoyne, false, false);
cntMarker += Lemoyne.length;
map.addOverlays(Mechanicsburg);
centerByArray(Mechanicsburg, false, false);
cntMarker += Mechanicsburg.length;
map.addOverlays(Mount_Holly_Springs);
centerByArray(Mount_Holly_Springs, false, false);
cntMarker += Mount_Holly_Springs.length;
map.addOverlays(New_Cumberland);
centerByArray(New_Cumberland, false, false);
cntMarker += New_Cumberland.length;
map.addOverlays(Newville);
centerByArray(Newville, false, false);
cntMarker += Newville.length;
map.addOverlays(Shippensburg);
centerByArray(Shippensburg, false, false);
cntMarker += Shippensburg.length;
map.addOverlays(Shiremanstown);
centerByArray(Shiremanstown, false, false);
cntMarker += Shiremanstown.length;
centerByArray(Camp_Hill,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');
}
}