function addMarkers(){
mySelect = document.getElementById('selection');
York = [];Dover = [];Seven_Valleys = [];Delta = [];Dallastown = [];Spring_Grove = [];Hanover = [];Shrewsbury = [];Red_Lion = [];New_Freedom = [];Thomasville = [];Glen_Rock = [];Airville = [];mySelect.options[mySelect.options.length] = new Option("Airville schools",'all=Airville');
mySelect.options[mySelect.options.length] = new Option("Dallastown schools",'all=Dallastown');
mySelect.options[mySelect.options.length] = new Option("Delta schools",'all=Delta');
mySelect.options[mySelect.options.length] = new Option("Dover schools",'all=Dover');
mySelect.options[mySelect.options.length] = new Option("Glen Rock schools",'all=Glen_Rock');
mySelect.options[mySelect.options.length] = new Option("Hanover schools",'all=Hanover');
mySelect.options[mySelect.options.length] = new Option("New Freedom schools",'all=New_Freedom');
mySelect.options[mySelect.options.length] = new Option("Red Lion schools",'all=Red_Lion');
mySelect.options[mySelect.options.length] = new Option("Seven Valleys schools",'all=Seven_Valleys');
mySelect.options[mySelect.options.length] = new Option("Shrewsbury schools",'all=Shrewsbury');
mySelect.options[mySelect.options.length] = new Option("Spring Grove schools",'all=Spring_Grove');
mySelect.options[mySelect.options.length] = new Option("Thomasville schools",'all=Thomasville');
mySelect.options[mySelect.options.length] = new Option("York schools",'all=York');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
York[York.length] = createMarker(new GPoint(-76.67130500,39.96964800),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("1st Church Of Brethren Cdc",'York=' + York.length);
Dover[Dover.length] = createMarker(new GPoint(-76.88171400,39.97367200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bairs Codorus Mennonite School",'Dover=' + Dover.length);
Seven_Valleys[Seven_Valleys.length] = createMarker(new GPoint(-76.79280400,39.83963200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bairs Codorus Mennonite School",'Seven_Valleys=' + Seven_Valleys.length);
York[York.length] = createMarker(new GPoint(-76.69961300,39.98115000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bethel Christian Academy",'York=' + York.length);
York[York.length] = createMarker(new GPoint(-76.76728000,40.05067000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bible Baptist Christian Academy",'York=' + York.length);
Delta[Delta.length] = createMarker(new GPoint(-76.33850000,39.75230000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Blue Bird Meadow School",'Delta=' + Delta.length);
Delta[Delta.length] = createMarker(new GPoint(-76.29604100,39.77281100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Cherry Ridge School",'Delta=' + Delta.length);
Dallastown[Dallastown.length] = createMarker(new GPoint(-76.64726200,39.90141400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Christ Lutheran Child Development Center",'Dallastown=' + Dallastown.length);
York[York.length] = createMarker(new GPoint(-76.76994100,39.99450100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Christian School Of York",'York=' + York.length);
York[York.length] = createMarker(new GPoint(-76.73822100,39.98830300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Early Learning Center",'York=' + York.length);
Spring_Grove[Spring_Grove.length] = createMarker(new GPoint(-76.89678600,39.85735600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Garbers Mennonite School",'Spring_Grove=' + Spring_Grove.length);
York[York.length] = createMarker(new GPoint(-76.63713300,39.96604600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Grace Academy For Christian Discipleship",'York=' + York.length);
Hanover[Hanover.length] = createMarker(new GPoint(-76.97440500,39.81888100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Hanover Christian Academy",'Hanover=' + Hanover.length);
Hanover[Hanover.length] = createMarker(new GPoint(-77.02304800,39.72186300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Hanover Mennonite School",'Hanover=' + Hanover.length);
York[York.length] = createMarker(new GPoint(-76.69760300,39.96157000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Jack & Jill Nursery & Kindergarten",'York=' + York.length);
Shrewsbury[Shrewsbury.length] = createMarker(new GPoint(-76.67594200,39.76967800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Kiddie Academy Child Care",'Shrewsbury=' + Shrewsbury.length);
York[York.length] = createMarker(new GPoint(-76.76275200,39.97740300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Kinder Care Learning Center 1284",'York=' + York.length);
York[York.length] = createMarker(new GPoint(-76.67304200,39.97440800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Kindercare Learning Center",'York=' + York.length);
Red_Lion[Red_Lion.length] = createMarker(new GPoint(-76.59890000,39.90270000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Light House",'Red_Lion=' + Red_Lion.length);
York[York.length] = createMarker(new GPoint(-76.72428900,39.96453500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Logos Academy",'York=' + York.length);
York[York.length] = createMarker(new GPoint(-76.77306100,39.97736500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Magic Years",'York=' + York.length);
Hanover[Hanover.length] = createMarker(new GPoint(-76.98354100,39.79251000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Magic Years Child Care And Lrn",'Hanover=' + Hanover.length);
Hanover[Hanover.length] = createMarker(new GPoint(-76.98232700,39.77351700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Missionary Bible Baptist Academy",'Hanover=' + Hanover.length);
York[York.length] = createMarker(new GPoint(-76.65730100,39.98031600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Montessori Chldrn High Schoole York",'York=' + York.length);
New_Freedom[New_Freedom.length] = createMarker(new GPoint(-76.68190000,39.75050000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("New Freedom Christian School",'New_Freedom=' + New_Freedom.length);
Spring_Grove[Spring_Grove.length] = createMarker(new GPoint(-76.91833100,39.88388800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Pleasant Hill Christian School",'Spring_Grove=' + Spring_Grove.length);
Red_Lion[Red_Lion.length] = createMarker(new GPoint(-76.59429900,39.89018300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Red Lion Christian School",'Red_Lion=' + Red_Lion.length);
Dover[Dover.length] = createMarker(new GPoint(-76.82135500,39.98443200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Robins Nest Daycare & Preschool",'Dover=' + Dover.length);
York[York.length] = createMarker(new GPoint(-76.66700400,39.97008300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Joseph School",'York=' + York.length);
Dallastown[Dallastown.length] = createMarker(new GPoint(-76.63844700,39.90013400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Joseph School",'Dallastown=' + Dallastown.length);
York[York.length] = createMarker(new GPoint(-76.72786300,39.95861600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Patrick School",'York=' + York.length);
Thomasville[Thomasville.length] = createMarker(new GPoint(-76.85875700,39.93157900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Rose Of Lima School",'Thomasville=' + Thomasville.length);
Hanover[Hanover.length] = createMarker(new GPoint(-76.96676100,39.81729100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Shepherd's Fold",'Hanover=' + Hanover.length);
New_Freedom[New_Freedom.length] = createMarker(new GPoint(-76.66437500,39.74685300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Shrewsbury Christian Academy",'New_Freedom=' + New_Freedom.length);
Glen_Rock[Glen_Rock.length] = createMarker(new GPoint(-76.66895200,39.81926900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Shrewsbury Dunkard Breth School",'Glen_Rock=' + Glen_Rock.length);
Airville[Airville.length] = createMarker(new GPoint(-76.37737400,39.79625600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Singing Meadow Amish School",'Airville=' + Airville.length);
York[York.length] = createMarker(new GPoint(-76.66657500,39.95943900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Small Steps Day Care School",'York=' + York.length);
York[York.length] = createMarker(new GPoint(-76.68070300,39.90886000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Small Steps Daycare School South",'York=' + York.length);
Spring_Grove[Spring_Grove.length] = createMarker(new GPoint(-76.86493300,39.88437400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Small World Day Care Center",'Spring_Grove=' + Spring_Grove.length);
York[York.length] = createMarker(new GPoint(-76.67630300,39.95878800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St John Lutheran School",'York=' + York.length);
Hanover[Hanover.length] = createMarker(new GPoint(-76.98015100,39.79785500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Joseph School",'Hanover=' + Hanover.length);
Hanover[Hanover.length] = createMarker(new GPoint(-76.99551100,39.80463200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Vincent De Paul School",'Hanover=' + Hanover.length);
York[York.length] = createMarker(new GPoint(-76.74974300,40.00304000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Stillmeadow Nazarene Ccc",'York=' + York.length);
Airville[Airville.length] = createMarker(new GPoint(-76.40850000,39.80740000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Sunnyburn School",'Airville=' + Airville.length);
York[York.length] = createMarker(new GPoint(-76.71987500,39.96255300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Tidings of Peace Christian School",'York=' + York.length);
York[York.length] = createMarker(new GPoint(-76.70923400,39.87584000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Tlc Montessori",'York=' + York.length);
Hanover[Hanover.length] = createMarker(new GPoint(-76.96039900,39.75959200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("West Manheim Little People Day",'Hanover=' + Hanover.length);
York[York.length] = createMarker(new GPoint(-76.73548700,39.96147100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Ymca Of York Learning Center",'York=' + York.length);
York[York.length] = createMarker(new GPoint(-76.74312600,39.94000400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("York Country Day School",'York=' + York.length);
York[York.length] = createMarker(new GPoint(-76.71822900,39.96737100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("York Day Nursery And Kindergar",'York=' + York.length);
York[York.length] = createMarker(new GPoint(-76.66434500,39.96046000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("York Little People Day Care School",'York=' + York.length);
York[York.length] = createMarker(new GPoint(-76.78394900,39.98683700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("York Sda Church School",'York=' + York.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,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/////1/' + showArray);
map.removeOverlays(Airville);
map.removeOverlays(Dallastown);
map.removeOverlays(Delta);
map.removeOverlays(Dover);
map.removeOverlays(Glen_Rock);
map.removeOverlays(Hanover);
map.removeOverlays(New_Freedom);
map.removeOverlays(Red_Lion);
map.removeOverlays(Seven_Valleys);
map.removeOverlays(Shrewsbury);
map.removeOverlays(Spring_Grove);
map.removeOverlays(Thomasville);
map.removeOverlays(York);
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(York);map.removeOverlays(Airville);
map.removeOverlays(Dallastown);
map.removeOverlays(Delta);
map.removeOverlays(Dover);
map.removeOverlays(Glen_Rock);
map.removeOverlays(Hanover);
map.removeOverlays(New_Freedom);
map.removeOverlays(Red_Lion);
map.removeOverlays(Seven_Valleys);
map.removeOverlays(Shrewsbury);
map.removeOverlays(Spring_Grove);
map.removeOverlays(Thomasville);
map.removeOverlays(York);
map.addOverlays(Airville);
centerByArray(Airville, false, false);
cntMarker += Airville.length;
map.addOverlays(Dallastown);
centerByArray(Dallastown, false, false);
cntMarker += Dallastown.length;
map.addOverlays(Delta);
centerByArray(Delta, false, false);
cntMarker += Delta.length;
map.addOverlays(Dover);
centerByArray(Dover, false, false);
cntMarker += Dover.length;
map.addOverlays(Glen_Rock);
centerByArray(Glen_Rock, false, false);
cntMarker += Glen_Rock.length;
map.addOverlays(Hanover);
centerByArray(Hanover, false, false);
cntMarker += Hanover.length;
map.addOverlays(New_Freedom);
centerByArray(New_Freedom, false, false);
cntMarker += New_Freedom.length;
map.addOverlays(Red_Lion);
centerByArray(Red_Lion, false, false);
cntMarker += Red_Lion.length;
map.addOverlays(Seven_Valleys);
centerByArray(Seven_Valleys, false, false);
cntMarker += Seven_Valleys.length;
map.addOverlays(Shrewsbury);
centerByArray(Shrewsbury, false, false);
cntMarker += Shrewsbury.length;
map.addOverlays(Spring_Grove);
centerByArray(Spring_Grove, false, false);
cntMarker += Spring_Grove.length;
map.addOverlays(Thomasville);
centerByArray(Thomasville, false, false);
cntMarker += Thomasville.length;
map.addOverlays(York);
centerByArray(York, false, false);
cntMarker += York.length;
centerByArray(York,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');
//window.open('/map.php?type=1&schools=&school_level=1&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;
}