function addMarkers()
{
mySelect = document.getElementById('selection');
Vineland = [];Millville = [];Bridgeton = [];Seabrook = [];Rosenhayn = [];Newport = [];Port_Norris = [];Port_Elizabeth = [];Greenwich = [];Cedarville = [];Shiloh = [];mySelect.options[mySelect.options.length] = new Option("Bridgeton schools",'all=Bridgeton');
mySelect.options[mySelect.options.length] = new Option("Cedarville schools",'all=Cedarville');
mySelect.options[mySelect.options.length] = new Option("Greenwich schools",'all=Greenwich');
mySelect.options[mySelect.options.length] = new Option("Millville schools",'all=Millville');
mySelect.options[mySelect.options.length] = new Option("Newport schools",'all=Newport');
mySelect.options[mySelect.options.length] = new Option("Port Elizabeth schools",'all=Port_Elizabeth');
mySelect.options[mySelect.options.length] = new Option("Port Norris schools",'all=Port_Norris');
mySelect.options[mySelect.options.length] = new Option("Rosenhayn schools",'all=Rosenhayn');
mySelect.options[mySelect.options.length] = new Option("Seabrook schools",'all=Seabrook');
mySelect.options[mySelect.options.length] = new Option("Shiloh schools",'all=Shiloh');
mySelect.options[mySelect.options.length] = new Option("Vineland schools",'all=Vineland');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Vineland[Vineland.length] = createMarker(new GPoint(-74.98135376,39.44786072),"
",iconBl);
mySelect.options[mySelect.options.length] = new Option("Anthony Rossi Inter. School",'Vineland=' + Vineland.length);
Millville[Millville.length] = createMarker(new GPoint(-75.03299713,39.36220169),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Bacon Elementary School",'Millville=' + Millville.length);
Bridgeton[Bridgeton.length] = createMarker(new GPoint(-75.24623108,39.43795395),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bridgeton High School",'Bridgeton=' + Bridgeton.length);
Bridgeton[Bridgeton.length] = createMarker(new GPoint(-75.24542236,39.42969513),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Bridgeton Middle School",'Bridgeton=' + Bridgeton.length);
Bridgeton[Bridgeton.length] = createMarker(new GPoint(-75.23406400,39.42947500),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Broad Street Elementary School",'Bridgeton=' + Bridgeton.length);
Bridgeton[Bridgeton.length] = createMarker(new GPoint(-75.21455383,39.42436600),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Buckshutem Road Elementary School",'Bridgeton=' + Bridgeton.length);
Vineland[Vineland.length] = createMarker(new GPoint(-75.02764893,39.43962479),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Butler Ave Elementary School",'Vineland=' + Vineland.length);
Seabrook[Seabrook.length] = createMarker(new GPoint(-75.24019623,39.44580078),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Charles F Seabrook School",'Seabrook=' + Seabrook.length);
Bridgeton[Bridgeton.length] = createMarker(new GPoint(-75.22352600,39.41935349),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Cherry Street Elementary School",'Bridgeton=' + Bridgeton.length);
Millville[Millville.length] = createMarker(new GPoint(-74.99531000,39.38812400),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Child Family Center",'Millville=' + Millville.length);
Bridgeton[Bridgeton.length] = createMarker(new GPoint(-75.15757751,39.46087265),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Cumberland Co Technical Ed Ct High School",'Bridgeton=' + Bridgeton.length);
Seabrook[Seabrook.length] = createMarker(new GPoint(-75.23459625,39.44419861),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Cumberland Regional High School",'Seabrook=' + Seabrook.length);
Vineland[Vineland.length] = createMarker(new GPoint(-75.01671600,39.48255920),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Cunningham Elementary School",'Vineland=' + Vineland.length);
Vineland[Vineland.length] = createMarker(new GPoint(-75.02610900,39.48619500),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("D'ippolito Intermediate",'Vineland=' + Vineland.length);
Vineland[Vineland.length] = createMarker(new GPoint(-75.05258942,39.48392868),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Dane Barse Elementary School",'Vineland=' + Vineland.length);
Rosenhayn[Rosenhayn.length] = createMarker(new GPoint(-75.13159943,39.47800064),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Deerfield Elementary School",'Rosenhayn=' + Rosenhayn.length);
Newport[Newport.length] = createMarker(new GPoint(-75.16469574,39.29682922),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Downe Township Elementary School",'Newport=' + Newport.length);
Vineland[Vineland.length] = createMarker(new GPoint(-75.02204132,39.45213318),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Dr. William Mennies Elementary School",'Vineland=' + Vineland.length);
Vineland[Vineland.length] = createMarker(new GPoint(-74.94649506,39.45458984),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("East Vineland High School",'Vineland=' + Vineland.length);
Seabrook[Seabrook.length] = createMarker(new GPoint(-75.24019623,39.44580078),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Elizabeth F Moore School",'Seabrook=' + Seabrook.length);
Bridgeton[Bridgeton.length] = createMarker(new GPoint(-75.24019623,39.44580078),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Fairfield T Middle Gouldt",'Bridgeton=' + Bridgeton.length);
Bridgeton[Bridgeton.length] = createMarker(new GPoint(-75.21952820,39.38091278),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Fairfield T Prim Fairton Elementary School",'Bridgeton=' + Bridgeton.length);
Port_Norris[Port_Norris.length] = createMarker(new GPoint(-75.05609894,39.26089859),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Haleyville-mauricetown Elementary School",'Port_Norris=' + Port_Norris.length);
Millville[Millville.length] = createMarker(new GPoint(-74.99313354,39.38733673),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Holly Heights Elementary School",'Millville=' + Millville.length);
Bridgeton[Bridgeton.length] = createMarker(new GPoint(-75.26148224,39.45535660),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Hopewell Crest Elementary School",'Bridgeton=' + Bridgeton.length);
Bridgeton[Bridgeton.length] = createMarker(new GPoint(-75.21842194,39.43963623),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Indian Ave Elementary School",'Bridgeton=' + Bridgeton.length);
Vineland[Vineland.length] = createMarker(new GPoint(-75.02010345,39.48949814),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("John H Winslow Elementary School",'Vineland=' + Vineland.length);
Vineland[Vineland.length] = createMarker(new GPoint(-75.02010345,39.48949814),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Johnstone Elementary School",'Vineland=' + Vineland.length);
Millville[Millville.length] = createMarker(new GPoint(-75.05692291,39.39751434),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Lakeside Middle School",'Millville=' + Millville.length);
Vineland[Vineland.length] = createMarker(new GPoint(-75.03828430,39.48665237),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Landis Intermediate School",'Vineland=' + Vineland.length);
Vineland[Vineland.length] = createMarker(new GPoint(-95.94256592,41.25243759),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Liberty Elementary School",'Vineland=' + Vineland.length);
Vineland[Vineland.length] = createMarker(new GPoint(-75.02971649,39.52651596),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Marie Durand Elementary School",'Vineland=' + Vineland.length);
Vineland[Vineland.length] = createMarker(new GPoint(-75.02095795,39.48461151),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Maurice Fels Middle School",'Vineland=' + Vineland.length);
Port_Elizabeth[Port_Elizabeth.length] = createMarker(new GPoint(-74.88950348,39.39319992),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Maurice River Township Elementary School",'Port_Elizabeth=' + Port_Elizabeth.length);
Vineland[Vineland.length] = createMarker(new GPoint(-75.03470612,39.49456024),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Max Leuchter Elementary School",'Vineland=' + Vineland.length);
Millville[Millville.length] = createMarker(new GPoint(-75.03286743,39.40201950),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Memorial High School",'Millville=' + Millville.length);
Millville[Millville.length] = createMarker(new GPoint(-75.01853180,39.39184952),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Millville Senior High School",'Millville=' + Millville.length);
Greenwich[Greenwich.length] = createMarker(new GPoint(-75.34255219,39.40021515),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Morris Goodwin Elementary School",'Greenwich=' + Greenwich.length);
Millville[Millville.length] = createMarker(new GPoint(-75.06227875,39.39934540),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Mount Pleasant Elementary School",'Millville=' + Millville.length);
Cedarville[Cedarville.length] = createMarker(new GPoint(-75.20372772,39.33899689),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Myron L Powell Elementary School",'Cedarville=' + Cedarville.length);
Vineland[Vineland.length] = createMarker(new GPoint(-74.99725342,39.48472977),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Nash Education Center",'Vineland=' + Vineland.length);
Vineland[Vineland.length] = createMarker(new GPoint(-74.99547577,39.49940109),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Oak And Main Elementary School",'Vineland=' + Vineland.length);
Port_Norris[Port_Norris.length] = createMarker(new GPoint(-75.05609894,39.26089859),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Port Norris Middle School",'Port_Norris=' + Port_Norris.length);
Bridgeton[Bridgeton.length] = createMarker(new GPoint(-75.24830627,39.42028427),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Quarter Mile Lane Elementary School",'Bridgeton=' + Bridgeton.length);
Millville[Millville.length] = createMarker(new GPoint(-75.04202271,39.40321350),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("R D Wood Elementary School",'Millville=' + Millville.length);
Millville[Millville.length] = createMarker(new GPoint(-75.07536316,39.39016342),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Rieck Ave Elementary School",'Millville=' + Millville.length);
Newport[Newport.length] = createMarker(new GPoint(-75.17240143,39.27299881),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("School On Wheels High School",'Newport=' + Newport.length);
Shiloh[Shiloh.length] = createMarker(new GPoint(-75.29979706,39.45890045),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Shiloh Elementary School",'Shiloh=' + Shiloh.length);
Millville[Millville.length] = createMarker(new GPoint(-75.04339600,39.38642120),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Silver Run School",'Millville=' + Millville.length);
Vineland[Vineland.length] = createMarker(new GPoint(-75.02456665,39.54662704),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("South Vineland Elementary School",'Vineland=' + Vineland.length);
Bridgeton[Bridgeton.length] = createMarker(new GPoint(-75.34358978,39.45254898),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Stow Creek Township Elementary School",'Bridgeton=' + Bridgeton.length);
Vineland[Vineland.length] = createMarker(new GPoint(-75.00099945,39.47885132),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Veterans Memorial Intermediate School",'Vineland=' + Vineland.length);
Vineland[Vineland.length] = createMarker(new GPoint(-75.00752258,39.47801590),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Vineland Senior High-north",'Vineland=' + Vineland.length);
Vineland[Vineland.length] = createMarker(new GPoint(-75.00752258,39.47801590),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Vineland Senior High-south High School",'Vineland=' + Vineland.length);
Bridgeton[Bridgeton.length] = createMarker(new GPoint(-75.24642181,39.43467712),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("West Ave Elementary School",'Bridgeton=' + Bridgeton.length);
Seabrook[Seabrook.length] = createMarker(new GPoint(-75.24019623,39.44580078),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Woodruff School",'Seabrook=' + Seabrook.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(Bridgeton);
map.removeOverlays(Cedarville);
map.removeOverlays(Greenwich);
map.removeOverlays(Millville);
map.removeOverlays(Newport);
map.removeOverlays(Port_Elizabeth);
map.removeOverlays(Port_Norris);
map.removeOverlays(Rosenhayn);
map.removeOverlays(Seabrook);
map.removeOverlays(Shiloh);
map.removeOverlays(Vineland);
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(Vineland);map.removeOverlays(Bridgeton);
map.removeOverlays(Cedarville);
map.removeOverlays(Greenwich);
map.removeOverlays(Millville);
map.removeOverlays(Newport);
map.removeOverlays(Port_Elizabeth);
map.removeOverlays(Port_Norris);
map.removeOverlays(Rosenhayn);
map.removeOverlays(Seabrook);
map.removeOverlays(Shiloh);
map.removeOverlays(Vineland);
map.addOverlays(Bridgeton);
centerByArray(Bridgeton, false, false);
cntMarker += Bridgeton.length;
map.addOverlays(Cedarville);
centerByArray(Cedarville, false, false);
cntMarker += Cedarville.length;
map.addOverlays(Greenwich);
centerByArray(Greenwich, false, false);
cntMarker += Greenwich.length;
map.addOverlays(Millville);
centerByArray(Millville, false, false);
cntMarker += Millville.length;
map.addOverlays(Newport);
centerByArray(Newport, false, false);
cntMarker += Newport.length;
map.addOverlays(Port_Elizabeth);
centerByArray(Port_Elizabeth, false, false);
cntMarker += Port_Elizabeth.length;
map.addOverlays(Port_Norris);
centerByArray(Port_Norris, false, false);
cntMarker += Port_Norris.length;
map.addOverlays(Rosenhayn);
centerByArray(Rosenhayn, false, false);
cntMarker += Rosenhayn.length;
map.addOverlays(Seabrook);
centerByArray(Seabrook, false, false);
cntMarker += Seabrook.length;
map.addOverlays(Shiloh);
centerByArray(Shiloh, false, false);
cntMarker += Shiloh.length;
map.addOverlays(Vineland);
centerByArray(Vineland, false, false);
cntMarker += Vineland.length;
centerByArray(Vineland,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');
}
}