function addMarkers()
{
mySelect = document.getElementById('selection');
Allamuchy = [];Alpha = [];Phillipsburg = [];Belvidere = [];Blairstown = [];Washington = [];Johnsonburg = [];Great_Meadows = [];Stewartsville = [];Hackettstown = [];Hope = [];Delaware = [];Port_Murray = [];Oxford = [];mySelect.options[mySelect.options.length] = new Option("Allamuchy schools",'all=Allamuchy');
mySelect.options[mySelect.options.length] = new Option("Alpha schools",'all=Alpha');
mySelect.options[mySelect.options.length] = new Option("Belvidere schools",'all=Belvidere');
mySelect.options[mySelect.options.length] = new Option("Blairstown schools",'all=Blairstown');
mySelect.options[mySelect.options.length] = new Option("Delaware schools",'all=Delaware');
mySelect.options[mySelect.options.length] = new Option("Great Meadows schools",'all=Great_Meadows');
mySelect.options[mySelect.options.length] = new Option("Hackettstown schools",'all=Hackettstown');
mySelect.options[mySelect.options.length] = new Option("Hope schools",'all=Hope');
mySelect.options[mySelect.options.length] = new Option("Johnsonburg schools",'all=Johnsonburg');
mySelect.options[mySelect.options.length] = new Option("Oxford schools",'all=Oxford');
mySelect.options[mySelect.options.length] = new Option("Phillipsburg schools",'all=Phillipsburg');
mySelect.options[mySelect.options.length] = new Option("Port Murray schools",'all=Port_Murray');
mySelect.options[mySelect.options.length] = new Option("Stewartsville schools",'all=Stewartsville');
mySelect.options[mySelect.options.length] = new Option("Washington schools",'all=Washington');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Allamuchy[Allamuchy.length] = createMarker(new GPoint(-74.81050110,40.92160034),"
",iconRd);
mySelect.options[mySelect.options.length] = new Option("Allamuchy Township Consolid Elementary School",'Allamuchy=' + Allamuchy.length);
Alpha[Alpha.length] = createMarker(new GPoint(-75.16422272,40.66413879),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Alpha Borough Elementary School",'Alpha=' + Alpha.length);
Phillipsburg[Phillipsburg.length] = createMarker(new GPoint(-75.18126678,40.68229675),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Andover Morris Elementary School",'Phillipsburg=' + Phillipsburg.length);
Phillipsburg[Phillipsburg.length] = createMarker(new GPoint(-75.16619873,40.69049835),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Barber Elementary School",'Phillipsburg=' + Phillipsburg.length);
Belvidere[Belvidere.length] = createMarker(new GPoint(-75.06562042,40.82403183),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Belvidere High School",'Belvidere=' + Belvidere.length);
Blairstown[Blairstown.length] = createMarker(new GPoint(-74.95534515,40.98270035),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Blairstown Elementary School",'Blairstown=' + Blairstown.length);
Washington[Washington.length] = createMarker(new GPoint(-75.00514984,40.75885010),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Brass Castle Elementary School",'Washington=' + Washington.length);
Phillipsburg[Phillipsburg.length] = createMarker(new GPoint(-75.16619873,40.69049835),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Delaware Park School",'Phillipsburg=' + Phillipsburg.length);
Washington[Washington.length] = createMarker(new GPoint(-74.99359894,40.75730133),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Franklin Township Consolidated Elementary School",'Washington=' + Washington.length);
Phillipsburg[Phillipsburg.length] = createMarker(new GPoint(-75.19411469,40.69151306),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Freeman Elementary School",'Phillipsburg=' + Phillipsburg.length);
Johnsonburg[Johnsonburg.length] = createMarker(new GPoint(-74.87879944,40.96440125),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Frelinghuysen Township Elementary School",'Johnsonburg=' + Johnsonburg.length);
Great_Meadows[Great_Meadows.length] = createMarker(new GPoint(-74.91181183,40.87060165),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Great Meadows Regional Mid School",'Great_Meadows=' + Great_Meadows.length);
Phillipsburg[Phillipsburg.length] = createMarker(new GPoint(-75.16761780,40.68238831),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Green Street Elementary School",'Phillipsburg=' + Phillipsburg.length);
Stewartsville[Stewartsville.length] = createMarker(new GPoint(-75.12713623,40.68538666),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Greenwich School",'Stewartsville=' + Stewartsville.length);
Hackettstown[Hackettstown.length] = createMarker(new GPoint(-74.83052063,40.84592819),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Hackettstown High School",'Hackettstown=' + Hackettstown.length);
Hackettstown[Hackettstown.length] = createMarker(new GPoint(-74.82801056,40.85089874),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Hackettstown Middle School",'Hackettstown=' + Hackettstown.length);
Phillipsburg[Phillipsburg.length] = createMarker(new GPoint(-75.13986206,40.74257278),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Harmony Township School",'Phillipsburg=' + Phillipsburg.length);
Hackettstown[Hackettstown.length] = createMarker(new GPoint(-74.82990265,40.86109924),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Hatchery Hill Elementary School",'Hackettstown=' + Hackettstown.length);
Hope[Hope.length] = createMarker(new GPoint(-74.96769714,40.91109848),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Hope Township Elementary School",'Hope=' + Hope.length);
Great_Meadows[Great_Meadows.length] = createMarker(new GPoint(-74.91181183,40.87060165),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Independence Twp. Central Elementary School",'Great_Meadows=' + Great_Meadows.length);
Delaware[Delaware.length] = createMarker(new GPoint(-75.06500244,40.89270020),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Knowlton Township Elementary School",'Delaware=' + Delaware.length);
Great_Meadows[Great_Meadows.length] = createMarker(new GPoint(-74.95472717,40.86944580),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Liberty Township Elementary School",'Great_Meadows=' + Great_Meadows.length);
Phillipsburg[Phillipsburg.length] = createMarker(new GPoint(-75.16619873,40.69049835),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Lopatcong Elementary School",'Phillipsburg=' + Phillipsburg.length);
Phillipsburg[Phillipsburg.length] = createMarker(new GPoint(-75.16609955,40.69039917),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Lopatcong Middle School",'Phillipsburg=' + Phillipsburg.length);
Port_Murray[Port_Murray.length] = createMarker(new GPoint(-74.91401672,40.77370071),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Mansfield Township Elementary School",'Port_Murray=' + Port_Murray.length);
Phillipsburg[Phillipsburg.length] = createMarker(new GPoint(-75.18199158,40.68912125),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Middle Middle School",'Phillipsburg=' + Phillipsburg.length);
Blairstown[Blairstown.length] = createMarker(new GPoint(-74.95880127,40.96870041),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("N Warren Regional High School",'Blairstown=' + Blairstown.length);
Oxford[Oxford.length] = createMarker(new GPoint(-74.99544525,40.80308151),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Oxford Central Elementary School",'Oxford=' + Oxford.length);
Belvidere[Belvidere.length] = createMarker(new GPoint(-75.06564331,40.82403564),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Oxford Street Middle School",'Belvidere=' + Belvidere.length);
Phillipsburg[Phillipsburg.length] = createMarker(new GPoint(-75.16619873,40.69049835),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Phillipsburg Alter Sec H. S. High School",'Phillipsburg=' + Phillipsburg.length);
Phillipsburg[Phillipsburg.length] = createMarker(new GPoint(-75.19112396,40.69686508),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Phillipsburg High School",'Phillipsburg=' + Phillipsburg.length);
Phillipsburg[Phillipsburg.length] = createMarker(new GPoint(-75.16619873,40.69049835),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Pohatcong Township Elementary School",'Phillipsburg=' + Phillipsburg.length);
Washington[Washington.length] = createMarker(new GPoint(-74.95507812,40.76500320),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Port Colden Elementary School",'Washington=' + Washington.length);
Blairstown[Blairstown.length] = createMarker(new GPoint(-74.96689800,40.91800200),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Ridge And Valley Charter School",'Blairstown=' + Blairstown.length);
Stewartsville[Stewartsville.length] = createMarker(new GPoint(-75.10931396,40.69200516),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Stewartsville Elementary School",'Stewartsville=' + Stewartsville.length);
Washington[Washington.length] = createMarker(new GPoint(-74.98084259,40.76201630),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Taylor Street Elementary School",'Washington=' + Washington.length);
Belvidere[Belvidere.length] = createMarker(new GPoint(-75.07900238,40.82590103),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Third Street Elementary School",'Belvidere=' + Belvidere.length);
Washington[Washington.length] = createMarker(new GPoint(-74.99359894,40.75730133),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Warren City Vocational & Technical Ins High School",'Washington=' + Washington.length);
Washington[Washington.length] = createMarker(new GPoint(-74.83650970,40.85179901),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Warren Co Spec Ser School",'Washington=' + Washington.length);
Washington[Washington.length] = createMarker(new GPoint(-74.98799133,40.76906967),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Warren Hills Regional High School",'Washington=' + Washington.length);
Washington[Washington.length] = createMarker(new GPoint(-74.99111176,40.76089859),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Warren Hills Regional Midd School",'Washington=' + Washington.length);
Washington[Washington.length] = createMarker(new GPoint(-74.99021149,40.75819778),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Washington Memorial Elementary School",'Washington=' + Washington.length);
Belvidere[Belvidere.length] = createMarker(new GPoint(-75.04660034,40.83000183),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("White Township Consolidated Elementary School",'Belvidere=' + Belvidere.length);
Hackettstown[Hackettstown.length] = createMarker(new GPoint(-74.81561279,40.86009979),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Willow Grove Street Elementary School",'Hackettstown=' + Hackettstown.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(Allamuchy);
map.removeOverlays(Alpha);
map.removeOverlays(Belvidere);
map.removeOverlays(Blairstown);
map.removeOverlays(Delaware);
map.removeOverlays(Great_Meadows);
map.removeOverlays(Hackettstown);
map.removeOverlays(Hope);
map.removeOverlays(Johnsonburg);
map.removeOverlays(Oxford);
map.removeOverlays(Phillipsburg);
map.removeOverlays(Port_Murray);
map.removeOverlays(Stewartsville);
map.removeOverlays(Washington);
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(Allamuchy);map.removeOverlays(Allamuchy);
map.removeOverlays(Alpha);
map.removeOverlays(Belvidere);
map.removeOverlays(Blairstown);
map.removeOverlays(Delaware);
map.removeOverlays(Great_Meadows);
map.removeOverlays(Hackettstown);
map.removeOverlays(Hope);
map.removeOverlays(Johnsonburg);
map.removeOverlays(Oxford);
map.removeOverlays(Phillipsburg);
map.removeOverlays(Port_Murray);
map.removeOverlays(Stewartsville);
map.removeOverlays(Washington);
map.addOverlays(Allamuchy);
centerByArray(Allamuchy, false, false);
cntMarker += Allamuchy.length;
map.addOverlays(Alpha);
centerByArray(Alpha, false, false);
cntMarker += Alpha.length;
map.addOverlays(Belvidere);
centerByArray(Belvidere, false, false);
cntMarker += Belvidere.length;
map.addOverlays(Blairstown);
centerByArray(Blairstown, false, false);
cntMarker += Blairstown.length;
map.addOverlays(Delaware);
centerByArray(Delaware, false, false);
cntMarker += Delaware.length;
map.addOverlays(Great_Meadows);
centerByArray(Great_Meadows, false, false);
cntMarker += Great_Meadows.length;
map.addOverlays(Hackettstown);
centerByArray(Hackettstown, false, false);
cntMarker += Hackettstown.length;
map.addOverlays(Hope);
centerByArray(Hope, false, false);
cntMarker += Hope.length;
map.addOverlays(Johnsonburg);
centerByArray(Johnsonburg, false, false);
cntMarker += Johnsonburg.length;
map.addOverlays(Oxford);
centerByArray(Oxford, false, false);
cntMarker += Oxford.length;
map.addOverlays(Phillipsburg);
centerByArray(Phillipsburg, false, false);
cntMarker += Phillipsburg.length;
map.addOverlays(Port_Murray);
centerByArray(Port_Murray, false, false);
cntMarker += Port_Murray.length;
map.addOverlays(Stewartsville);
centerByArray(Stewartsville, false, false);
cntMarker += Stewartsville.length;
map.addOverlays(Washington);
centerByArray(Washington, false, false);
cntMarker += Washington.length;
centerByArray(Allamuchy,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');
}
}