function addMarkers()
{
mySelect = document.getElementById('selection');
Pittstown = [];Flemington = [];Bloomsbury = [];Califon = [];Clinton = [];Ringoes = [];Sergeantsville = [];Frenchtown = [];Lambertville = [];Lebanon = [];Asbury = [];Quakertown = [];Hampton = [];High_Bridge = [];Whitehouse_Station = [];Milford = [];Annandale = [];Stockton = [];Three_Bridges = [];Glen_Gardner = [];mySelect.options[mySelect.options.length] = new Option("Annandale schools",'all=Annandale');
mySelect.options[mySelect.options.length] = new Option("Asbury schools",'all=Asbury');
mySelect.options[mySelect.options.length] = new Option("Bloomsbury schools",'all=Bloomsbury');
mySelect.options[mySelect.options.length] = new Option("Califon schools",'all=Califon');
mySelect.options[mySelect.options.length] = new Option("Clinton schools",'all=Clinton');
mySelect.options[mySelect.options.length] = new Option("Flemington schools",'all=Flemington');
mySelect.options[mySelect.options.length] = new Option("Frenchtown schools",'all=Frenchtown');
mySelect.options[mySelect.options.length] = new Option("Glen Gardner schools",'all=Glen_Gardner');
mySelect.options[mySelect.options.length] = new Option("Hampton schools",'all=Hampton');
mySelect.options[mySelect.options.length] = new Option("High Bridge schools",'all=High_Bridge');
mySelect.options[mySelect.options.length] = new Option("Lambertville schools",'all=Lambertville');
mySelect.options[mySelect.options.length] = new Option("Lebanon schools",'all=Lebanon');
mySelect.options[mySelect.options.length] = new Option("Milford schools",'all=Milford');
mySelect.options[mySelect.options.length] = new Option("Pittstown schools",'all=Pittstown');
mySelect.options[mySelect.options.length] = new Option("Quakertown schools",'all=Quakertown');
mySelect.options[mySelect.options.length] = new Option("Ringoes schools",'all=Ringoes');
mySelect.options[mySelect.options.length] = new Option("Sergeantsville schools",'all=Sergeantsville');
mySelect.options[mySelect.options.length] = new Option("Stockton schools",'all=Stockton');
mySelect.options[mySelect.options.length] = new Option("Three Bridges schools",'all=Three_Bridges');
mySelect.options[mySelect.options.length] = new Option("Whitehouse Station schools",'all=Whitehouse_Station');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Pittstown[Pittstown.length] = createMarker(new GPoint(-75.01696014,40.56974030),"
",iconBl);
mySelect.options[mySelect.options.length] = new Option("Alexandria School",'Pittstown=' + Pittstown.length);
Flemington[Flemington.length] = createMarker(new GPoint(-74.82430267,40.49413300),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Barley Sheaf Elementary School",'Flemington=' + Flemington.length);
Flemington[Flemington.length] = createMarker(new GPoint(-74.85441900,40.53574100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bartels Corner",'Flemington=' + Flemington.length);
Bloomsbury[Bloomsbury.length] = createMarker(new GPoint(-75.08570862,40.65467072),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Bloomsbury Borough Elementary School",'Bloomsbury=' + Bloomsbury.length);
Califon[Califon.length] = createMarker(new GPoint(-74.84007263,40.72442627),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Califon Borough Elementary School",'Califon=' + Califon.length);
Flemington[Flemington.length] = createMarker(new GPoint(-74.86380300,40.48146800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Central",'Flemington=' + Flemington.length);
Clinton[Clinton.length] = createMarker(new GPoint(-74.90764618,40.63514709),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Clinton Town Elementary School",'Clinton=' + Clinton.length);
Ringoes[Ringoes.length] = createMarker(new GPoint(-74.84950256,40.44729996),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Copper Hill School",'Ringoes=' + Ringoes.length);
Sergeantsville[Sergeantsville.length] = createMarker(new GPoint(-74.93666077,40.44653702),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Delaware Township No 1 Elementary School",'Sergeantsville=' + Sergeantsville.length);
Frenchtown[Frenchtown.length] = createMarker(new GPoint(-75.01096344,40.56160736),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Delaware Valley Regional High School",'Frenchtown=' + Frenchtown.length);
Lambertville[Lambertville.length] = createMarker(new GPoint(-74.92420197,40.37340164),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("E S C School",'Lambertville=' + Lambertville.length);
Lebanon[Lebanon.length] = createMarker(new GPoint(-74.78184400,40.70379500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("E S C Tewksbury",'Lebanon=' + Lebanon.length);
Ringoes[Ringoes.length] = createMarker(new GPoint(-74.85874176,40.42838287),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("East Amwell Township Elementary School",'Ringoes=' + Ringoes.length);
Frenchtown[Frenchtown.length] = createMarker(new GPoint(-75.06272888,40.53404236),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Edith Ort Thomas Elementary School",'Frenchtown=' + Frenchtown.length);
Asbury[Asbury.length] = createMarker(new GPoint(-75.03255463,40.66645432),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Ethel Hoppock Elementary School",'Asbury=' + Asbury.length);
Flemington[Flemington.length] = createMarker(new GPoint(-74.86381531,40.54049683),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("F A Desmares Elementary School",'Flemington=' + Flemington.length);
Quakertown[Quakertown.length] = createMarker(new GPoint(-74.94190216,40.56549835),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Franklin Township Elementary School",'Quakertown=' + Quakertown.length);
Hampton[Hampton.length] = createMarker(new GPoint(-74.95568848,40.70599365),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Hampton Boro Elementary School",'Hampton=' + Hampton.length);
High_Bridge[High_Bridge.length] = createMarker(new GPoint(-74.89161682,40.66878891),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("High Bridge Elementary School",'High_Bridge=' + High_Bridge.length);
High_Bridge[High_Bridge.length] = createMarker(new GPoint(-74.89161682,40.66878891),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("High Bridge Middle School",'High_Bridge=' + High_Bridge.length);
Whitehouse_Station[Whitehouse_Station.length] = createMarker(new GPoint(-74.76000977,40.58851624),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Holland Brook School",'Whitehouse_Station=' + Whitehouse_Station.length);
Milford[Milford.length] = createMarker(new GPoint(-75.10030365,40.59069824),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Holland Township Elementary School",'Milford=' + Milford.length);
Milford[Milford.length] = createMarker(new GPoint(-75.10030365,40.59069824),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Holland Township Middle School",'Milford=' + Milford.length);
Milford[Milford.length] = createMarker(new GPoint(-75.09479400,40.56932000),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Holland Twp Elementary School",'Milford=' + Milford.length);
Flemington[Flemington.length] = createMarker(new GPoint(-74.85119629,40.51530075),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Hunterdon Central High School",'Flemington=' + Flemington.length);
Flemington[Flemington.length] = createMarker(new GPoint(-74.83219600,40.50114400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("J.p. Case Middle School",'Flemington=' + Flemington.length);
Frenchtown[Frenchtown.length] = createMarker(new GPoint(-75.01276398,40.50675201),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Kingwood Township Elementary School",'Frenchtown=' + Frenchtown.length);
Lambertville[Lambertville.length] = createMarker(new GPoint(-74.94492340,40.37317657),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Lambertville Elementary School",'Lambertville=' + Lambertville.length);
Lebanon[Lebanon.length] = createMarker(new GPoint(-74.83625031,40.63991547),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Lebanon Borough Elementary School",'Lebanon=' + Lebanon.length);
Pittstown[Pittstown.length] = createMarker(new GPoint(-75.01696014,40.56974030),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Lester D Wilson Elementary School",'Pittstown=' + Pittstown.length);
Milford[Milford.length] = createMarker(new GPoint(-75.09294891,40.56889343),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Milford Boro Elementary School",'Milford=' + Milford.length);
Annandale[Annandale.length] = createMarker(new GPoint(-74.89218200,40.63948600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("North Hunterdon",'Annandale=' + Annandale.length);
Annandale[Annandale.length] = createMarker(new GPoint(-74.88327789,40.63065720),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("North Hunterdon Regional High School",'Annandale=' + Annandale.length);
Califon[Califon.length] = createMarker(new GPoint(-74.77389526,40.70489883),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Old Turnpike School",'Califon=' + Califon.length);
Lebanon[Lebanon.length] = createMarker(new GPoint(-74.87408447,40.61135483),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Patrick Mcgaheran Elementary School",'Lebanon=' + Lebanon.length);
Flemington[Flemington.length] = createMarker(new GPoint(-74.86353302,40.51023483),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Reading-fleming Middle School",'Flemington=' + Flemington.length);
Whitehouse_Station[Whitehouse_Station.length] = createMarker(new GPoint(-74.76121521,40.58897018),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Readington Middle School",'Whitehouse_Station=' + Whitehouse_Station.length);
Flemington[Flemington.length] = createMarker(new GPoint(-74.87412262,40.50483322),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Robert Hunter Elementary School",'Flemington=' + Flemington.length);
Lebanon[Lebanon.length] = createMarker(new GPoint(-74.83020782,40.65372086),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Round Valley Middle School",'Lebanon=' + Lebanon.length);
Lambertville[Lambertville.length] = createMarker(new GPoint(-74.92420197,40.37340164),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("S Hunterdon Regional High School",'Lambertville=' + Lambertville.length);
Flemington[Flemington.length] = createMarker(new GPoint(-74.85119629,40.51530075),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Sandhill School",'Flemington=' + Flemington.length);
Lebanon[Lebanon.length] = createMarker(new GPoint(-74.78218079,40.70335007),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Sawmill Elementary School",'Lebanon=' + Lebanon.length);
Clinton[Clinton.length] = createMarker(new GPoint(-74.89213562,40.64087296),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Spruce Run Elementary School",'Clinton=' + Clinton.length);
Stockton[Stockton.length] = createMarker(new GPoint(-74.97603607,40.40537643),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Stockton Boro Elementary School",'Stockton=' + Stockton.length);
Califon[Califon.length] = createMarker(new GPoint(-74.76092100,40.72595400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Tewksbury Elementary School",'Califon=' + Califon.length);
Asbury[Asbury.length] = createMarker(new GPoint(-74.99309540,40.68217468),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Thomas B. Conley Elementary School",'Asbury=' + Asbury.length);
Three_Bridges[Three_Bridges.length] = createMarker(new GPoint(-74.79656982,40.52462006),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Three Bridges Elementary School",'Three_Bridges=' + Three_Bridges.length);
Hampton[Hampton.length] = createMarker(new GPoint(-74.96926880,40.62993622),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Union Township Elementary School",'Hampton=' + Hampton.length);
Califon[Califon.length] = createMarker(new GPoint(-74.80419922,40.71889877),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Valley View Elementary School",'Califon=' + Califon.length);
Glen_Gardner[Glen_Gardner.length] = createMarker(new GPoint(-74.88693900,40.69593200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Voorhees",'Glen_Gardner=' + Glen_Gardner.length);
Glen_Gardner[Glen_Gardner.length] = createMarker(new GPoint(-74.88695526,40.69542694),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Voorhees High School",'Glen_Gardner=' + Glen_Gardner.length);
Lambertville[Lambertville.length] = createMarker(new GPoint(-74.92420197,40.37340164),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("West Amwell Township Elementary School",'Lambertville=' + Lambertville.length);
Whitehouse_Station[Whitehouse_Station.length] = createMarker(new GPoint(-74.76165009,40.61484528),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Whitehouse Elementary School",'Whitehouse_Station=' + Whitehouse_Station.length);
Califon[Califon.length] = createMarker(new GPoint(-74.88472748,40.71144867),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Woodglen Middle School",'Califon=' + Califon.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(Annandale);
map.removeOverlays(Asbury);
map.removeOverlays(Bloomsbury);
map.removeOverlays(Califon);
map.removeOverlays(Clinton);
map.removeOverlays(Flemington);
map.removeOverlays(Frenchtown);
map.removeOverlays(Glen_Gardner);
map.removeOverlays(Hampton);
map.removeOverlays(High_Bridge);
map.removeOverlays(Lambertville);
map.removeOverlays(Lebanon);
map.removeOverlays(Milford);
map.removeOverlays(Pittstown);
map.removeOverlays(Quakertown);
map.removeOverlays(Ringoes);
map.removeOverlays(Sergeantsville);
map.removeOverlays(Stockton);
map.removeOverlays(Three_Bridges);
map.removeOverlays(Whitehouse_Station);
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(Pittstown);map.removeOverlays(Annandale);
map.removeOverlays(Asbury);
map.removeOverlays(Bloomsbury);
map.removeOverlays(Califon);
map.removeOverlays(Clinton);
map.removeOverlays(Flemington);
map.removeOverlays(Frenchtown);
map.removeOverlays(Glen_Gardner);
map.removeOverlays(Hampton);
map.removeOverlays(High_Bridge);
map.removeOverlays(Lambertville);
map.removeOverlays(Lebanon);
map.removeOverlays(Milford);
map.removeOverlays(Pittstown);
map.removeOverlays(Quakertown);
map.removeOverlays(Ringoes);
map.removeOverlays(Sergeantsville);
map.removeOverlays(Stockton);
map.removeOverlays(Three_Bridges);
map.removeOverlays(Whitehouse_Station);
map.addOverlays(Annandale);
centerByArray(Annandale, false, false);
cntMarker += Annandale.length;
map.addOverlays(Asbury);
centerByArray(Asbury, false, false);
cntMarker += Asbury.length;
map.addOverlays(Bloomsbury);
centerByArray(Bloomsbury, false, false);
cntMarker += Bloomsbury.length;
map.addOverlays(Califon);
centerByArray(Califon, false, false);
cntMarker += Califon.length;
map.addOverlays(Clinton);
centerByArray(Clinton, false, false);
cntMarker += Clinton.length;
map.addOverlays(Flemington);
centerByArray(Flemington, false, false);
cntMarker += Flemington.length;
map.addOverlays(Frenchtown);
centerByArray(Frenchtown, false, false);
cntMarker += Frenchtown.length;
map.addOverlays(Glen_Gardner);
centerByArray(Glen_Gardner, false, false);
cntMarker += Glen_Gardner.length;
map.addOverlays(Hampton);
centerByArray(Hampton, false, false);
cntMarker += Hampton.length;
map.addOverlays(High_Bridge);
centerByArray(High_Bridge, false, false);
cntMarker += High_Bridge.length;
map.addOverlays(Lambertville);
centerByArray(Lambertville, false, false);
cntMarker += Lambertville.length;
map.addOverlays(Lebanon);
centerByArray(Lebanon, false, false);
cntMarker += Lebanon.length;
map.addOverlays(Milford);
centerByArray(Milford, false, false);
cntMarker += Milford.length;
map.addOverlays(Pittstown);
centerByArray(Pittstown, false, false);
cntMarker += Pittstown.length;
map.addOverlays(Quakertown);
centerByArray(Quakertown, false, false);
cntMarker += Quakertown.length;
map.addOverlays(Ringoes);
centerByArray(Ringoes, false, false);
cntMarker += Ringoes.length;
map.addOverlays(Sergeantsville);
centerByArray(Sergeantsville, false, false);
cntMarker += Sergeantsville.length;
map.addOverlays(Stockton);
centerByArray(Stockton, false, false);
cntMarker += Stockton.length;
map.addOverlays(Three_Bridges);
centerByArray(Three_Bridges, false, false);
cntMarker += Three_Bridges.length;
map.addOverlays(Whitehouse_Station);
centerByArray(Whitehouse_Station, false, false);
cntMarker += Whitehouse_Station.length;
centerByArray(Pittstown,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');
}
}