function addMarkers(){
mySelect = document.getElementById('selection');
Fairfield = [];Haddon_Heights = [];Cherry_Hill = [];Highland_Park = [];Pompton_Plains = [];Teaneck = [];Belle_Mead = [];Lanoka_Harbor = [];Lodi = [];Califon = [];Orange = [];Bellmawr = [];Rutherford = [];Peapack = [];North_Branch = [];Lakewood = [];Parlin = [];Somerset = [];Belleville = [];Paramus = [];Wall = [];Warren = [];Bloomsbury = [];Titusville = [];Sparta = [];Hackensack = [];Jersey_City = [];mySelect.options[mySelect.options.length] = new Option("Belle Mead schools",'all=Belle_Mead');
mySelect.options[mySelect.options.length] = new Option("Belleville schools",'all=Belleville');
mySelect.options[mySelect.options.length] = new Option("Bellmawr schools",'all=Bellmawr');
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("Cherry Hill schools",'all=Cherry_Hill');
mySelect.options[mySelect.options.length] = new Option("Fairfield schools",'all=Fairfield');
mySelect.options[mySelect.options.length] = new Option("Hackensack schools",'all=Hackensack');
mySelect.options[mySelect.options.length] = new Option("Haddon Heights schools",'all=Haddon_Heights');
mySelect.options[mySelect.options.length] = new Option("Highland Park schools",'all=Highland_Park');
mySelect.options[mySelect.options.length] = new Option("Jersey City schools",'all=Jersey_City');
mySelect.options[mySelect.options.length] = new Option("Lakewood schools",'all=Lakewood');
mySelect.options[mySelect.options.length] = new Option("Lanoka Harbor schools",'all=Lanoka_Harbor');
mySelect.options[mySelect.options.length] = new Option("Lodi schools",'all=Lodi');
mySelect.options[mySelect.options.length] = new Option("North Branch schools",'all=North_Branch');
mySelect.options[mySelect.options.length] = new Option("Orange schools",'all=Orange');
mySelect.options[mySelect.options.length] = new Option("Paramus schools",'all=Paramus');
mySelect.options[mySelect.options.length] = new Option("Parlin schools",'all=Parlin');
mySelect.options[mySelect.options.length] = new Option("Peapack schools",'all=Peapack');
mySelect.options[mySelect.options.length] = new Option("Pompton Plains schools",'all=Pompton_Plains');
mySelect.options[mySelect.options.length] = new Option("Rutherford schools",'all=Rutherford');
mySelect.options[mySelect.options.length] = new Option("Somerset schools",'all=Somerset');
mySelect.options[mySelect.options.length] = new Option("Sparta schools",'all=Sparta');
mySelect.options[mySelect.options.length] = new Option("Teaneck schools",'all=Teaneck');
mySelect.options[mySelect.options.length] = new Option("Titusville schools",'all=Titusville');
mySelect.options[mySelect.options.length] = new Option("Wall schools",'all=Wall');
mySelect.options[mySelect.options.length] = new Option("Warren schools",'all=Warren');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Fairfield[Fairfield.length] = createMarker(new GPoint(-74.31486700,40.87635800),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Banyan School",'Fairfield=' + Fairfield.length);
Haddon_Heights[Haddon_Heights.length] = createMarker(new GPoint(-75.06555500,39.88453000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Brookfield Elementary School",'Haddon_Heights=' + Haddon_Heights.length);
Cherry_Hill[Cherry_Hill.length] = createMarker(new GPoint(-75.01409600,39.88498600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Brookfield Schools",'Cherry_Hill=' + Cherry_Hill.length);
Highland_Park[Highland_Park.length] = createMarker(new GPoint(-74.42947700,40.50217300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Center School",'Highland_Park=' + Highland_Park.length);
Pompton_Plains[Pompton_Plains.length] = createMarker(new GPoint(-74.30270000,40.96590000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Chancellor Academy",'Pompton_Plains=' + Pompton_Plains.length);
Teaneck[Teaneck.length] = createMarker(new GPoint(-74.00213600,40.89295500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Community High School",'Teaneck=' + Teaneck.length);
Teaneck[Teaneck.length] = createMarker(new GPoint(-74.00216500,40.89416200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Community School Inc",'Teaneck=' + Teaneck.length);
Belle_Mead[Belle_Mead.length] = createMarker(new GPoint(-74.64570000,40.44930000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("East Mountain School",'Belle_Mead=' + Belle_Mead.length);
Lanoka_Harbor[Lanoka_Harbor.length] = createMarker(new GPoint(-74.20359000,39.85987500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Education Academy",'Lanoka_Harbor=' + Lanoka_Harbor.length);
Lodi[Lodi.length] = createMarker(new GPoint(-74.08533400,40.87367800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("High Point School Of Bergen County",'Lodi=' + Lodi.length);
Califon[Califon.length] = createMarker(new GPoint(-74.86472600,40.70029100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Hunterdon Learning Center",'Califon=' + Califon.length);
Orange[Orange.length] = createMarker(new GPoint(-74.22945700,40.77615900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Lakeside School",'Orange=' + Orange.length);
Bellmawr[Bellmawr.length] = createMarker(new GPoint(-75.11803700,39.87106500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Larc School",'Bellmawr=' + Bellmawr.length);
Rutherford[Rutherford.length] = createMarker(new GPoint(-74.11209200,40.83161800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Learning Center The",'Rutherford=' + Rutherford.length);
Peapack[Peapack.length] = createMarker(new GPoint(-74.66210000,40.70970000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Matheny Medical & Educational Center",'Peapack=' + Peapack.length);
North_Branch[North_Branch.length] = createMarker(new GPoint(-74.61938900,40.57070500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Midland School",'North_Branch=' + North_Branch.length);
Lakewood[Lakewood.length] = createMarker(new GPoint(-74.18901800,40.06194900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("New Road School of Ocean County",'Lakewood=' + Lakewood.length);
Parlin[Parlin.length] = createMarker(new GPoint(-74.31294300,40.45163900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("New Road School of Parlin",'Parlin=' + Parlin.length);
Somerset[Somerset.length] = createMarker(new GPoint(-74.54923400,40.53057800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("New Road School of Somerset",'Somerset=' + Somerset.length);
Belleville[Belleville.length] = createMarker(new GPoint(-74.17256900,40.79437800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Nw Essex Chn Therapeutic School & Preschool",'Belleville=' + Belleville.length);
Paramus[Paramus.length] = createMarker(new GPoint(-74.04676100,40.94403900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Palisades Learning Center",'Paramus=' + Paramus.length);
Wall[Wall.length] = createMarker(new GPoint(-74.05660000,40.17300000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Rugby School",'Wall=' + Wall.length);
Lakewood[Lakewood.length] = createMarker(new GPoint(-74.21983500,40.05783400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("School For Children W/ Hidden Intelligence",'Lakewood=' + Lakewood.length);
Warren[Warren.length] = createMarker(new GPoint(-74.50566100,40.62532800),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Somerset Hills School",'Warren=' + Warren.length);
Bloomsbury[Bloomsbury.length] = createMarker(new GPoint(-75.13522800,40.63766800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Stepping Stone School",'Bloomsbury=' + Bloomsbury.length);
Titusville[Titusville.length] = createMarker(new GPoint(-74.87665600,40.30422800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Titusville Academy",'Titusville=' + Titusville.length);
Sparta[Sparta.length] = createMarker(new GPoint(-74.66730200,41.07370300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Willowglen Academy",'Sparta=' + Sparta.length);
Hackensack[Hackensack.length] = createMarker(new GPoint(-74.03899500,40.86598800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Ycs George Washington School",'Hackensack=' + Hackensack.length);
Jersey_City[Jersey_City.length] = createMarker(new GPoint(-74.07213700,40.71959700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Ycs May Academy",'Jersey_City=' + Jersey_City.length);
map.removeOverlays(Belle_Mead);
map.removeOverlays(Belleville);
map.removeOverlays(Bellmawr);
map.removeOverlays(Bloomsbury);
map.removeOverlays(Califon);
map.removeOverlays(Cherry_Hill);
map.removeOverlays(Fairfield);
map.removeOverlays(Hackensack);
map.removeOverlays(Haddon_Heights);
map.removeOverlays(Highland_Park);
map.removeOverlays(Jersey_City);
map.removeOverlays(Lakewood);
map.removeOverlays(Lanoka_Harbor);
map.removeOverlays(Lodi);
map.removeOverlays(North_Branch);
map.removeOverlays(Orange);
map.removeOverlays(Paramus);
map.removeOverlays(Parlin);
map.removeOverlays(Peapack);
map.removeOverlays(Pompton_Plains);
map.removeOverlays(Rutherford);
map.removeOverlays(Somerset);
map.removeOverlays(Sparta);
map.removeOverlays(Teaneck);
map.removeOverlays(Titusville);
map.removeOverlays(Wall);
map.removeOverlays(Warren);
setTimeout(function(){map.addOverlays(Belle_Mead)},1000);
setTimeout(function(){map.addOverlays(Belleville)},1000);
setTimeout(function(){map.addOverlays(Bellmawr)},1000);
setTimeout(function(){map.addOverlays(Bloomsbury)},1000);
setTimeout(function(){map.addOverlays(Califon)},1000);
setTimeout(function(){map.addOverlays(Cherry_Hill)},1000);
setTimeout(function(){map.addOverlays(Fairfield)},1000);
setTimeout(function(){map.addOverlays(Hackensack)},1000);
setTimeout(function(){map.addOverlays(Haddon_Heights)},1000);
setTimeout(function(){map.addOverlays(Highland_Park)},1000);
setTimeout(function(){map.addOverlays(Jersey_City)},1000);
setTimeout(function(){map.addOverlays(Lakewood)},1000);
setTimeout(function(){map.addOverlays(Lanoka_Harbor)},1000);
setTimeout(function(){map.addOverlays(Lodi)},1000);
setTimeout(function(){map.addOverlays(North_Branch)},1000);
setTimeout(function(){map.addOverlays(Orange)},1000);
setTimeout(function(){map.addOverlays(Paramus)},1000);
setTimeout(function(){map.addOverlays(Parlin)},1000);
setTimeout(function(){map.addOverlays(Peapack)},1000);
setTimeout(function(){map.addOverlays(Pompton_Plains)},1000);
setTimeout(function(){map.addOverlays(Rutherford)},1000);
setTimeout(function(){map.addOverlays(Somerset)},1000);
setTimeout(function(){map.addOverlays(Sparta)},1000);
setTimeout(function(){map.addOverlays(Teaneck)},1000);
setTimeout(function(){map.addOverlays(Titusville)},1000);
setTimeout(function(){map.addOverlays(Wall)},1000);
setTimeout(function(){map.addOverlays(Warren)},1000);
maxLng = -74.00213600;
maxLat = 41.07370300;
minLng = -75.13522800;
minLat = 39.85987500;
reCenterMap();
} // 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//////' + showArray);
map.removeOverlays(Belle_Mead);
map.removeOverlays(Belleville);
map.removeOverlays(Bellmawr);
map.removeOverlays(Bloomsbury);
map.removeOverlays(Califon);
map.removeOverlays(Cherry_Hill);
map.removeOverlays(Fairfield);
map.removeOverlays(Hackensack);
map.removeOverlays(Haddon_Heights);
map.removeOverlays(Highland_Park);
map.removeOverlays(Jersey_City);
map.removeOverlays(Lakewood);
map.removeOverlays(Lanoka_Harbor);
map.removeOverlays(Lodi);
map.removeOverlays(North_Branch);
map.removeOverlays(Orange);
map.removeOverlays(Paramus);
map.removeOverlays(Parlin);
map.removeOverlays(Peapack);
map.removeOverlays(Pompton_Plains);
map.removeOverlays(Rutherford);
map.removeOverlays(Somerset);
map.removeOverlays(Sparta);
map.removeOverlays(Teaneck);
map.removeOverlays(Titusville);
map.removeOverlays(Wall);
map.removeOverlays(Warren);
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(Fairfield);map.removeOverlays(Belle_Mead);
map.removeOverlays(Belleville);
map.removeOverlays(Bellmawr);
map.removeOverlays(Bloomsbury);
map.removeOverlays(Califon);
map.removeOverlays(Cherry_Hill);
map.removeOverlays(Fairfield);
map.removeOverlays(Hackensack);
map.removeOverlays(Haddon_Heights);
map.removeOverlays(Highland_Park);
map.removeOverlays(Jersey_City);
map.removeOverlays(Lakewood);
map.removeOverlays(Lanoka_Harbor);
map.removeOverlays(Lodi);
map.removeOverlays(North_Branch);
map.removeOverlays(Orange);
map.removeOverlays(Paramus);
map.removeOverlays(Parlin);
map.removeOverlays(Peapack);
map.removeOverlays(Pompton_Plains);
map.removeOverlays(Rutherford);
map.removeOverlays(Somerset);
map.removeOverlays(Sparta);
map.removeOverlays(Teaneck);
map.removeOverlays(Titusville);
map.removeOverlays(Wall);
map.removeOverlays(Warren);
map.addOverlays(Belle_Mead);
centerByArray(Belle_Mead, false, false);
cntMarker += Belle_Mead.length;
map.addOverlays(Belleville);
centerByArray(Belleville, false, false);
cntMarker += Belleville.length;
map.addOverlays(Bellmawr);
centerByArray(Bellmawr, false, false);
cntMarker += Bellmawr.length;
map.addOverlays(Bloomsbury);
centerByArray(Bloomsbury, false, false);
cntMarker += Bloomsbury.length;
map.addOverlays(Califon);
centerByArray(Califon, false, false);
cntMarker += Califon.length;
map.addOverlays(Cherry_Hill);
centerByArray(Cherry_Hill, false, false);
cntMarker += Cherry_Hill.length;
map.addOverlays(Fairfield);
centerByArray(Fairfield, false, false);
cntMarker += Fairfield.length;
map.addOverlays(Hackensack);
centerByArray(Hackensack, false, false);
cntMarker += Hackensack.length;
map.addOverlays(Haddon_Heights);
centerByArray(Haddon_Heights, false, false);
cntMarker += Haddon_Heights.length;
map.addOverlays(Highland_Park);
centerByArray(Highland_Park, false, false);
cntMarker += Highland_Park.length;
map.addOverlays(Jersey_City);
centerByArray(Jersey_City, false, false);
cntMarker += Jersey_City.length;
map.addOverlays(Lakewood);
centerByArray(Lakewood, false, false);
cntMarker += Lakewood.length;
map.addOverlays(Lanoka_Harbor);
centerByArray(Lanoka_Harbor, false, false);
cntMarker += Lanoka_Harbor.length;
map.addOverlays(Lodi);
centerByArray(Lodi, false, false);
cntMarker += Lodi.length;
map.addOverlays(North_Branch);
centerByArray(North_Branch, false, false);
cntMarker += North_Branch.length;
map.addOverlays(Orange);
centerByArray(Orange, false, false);
cntMarker += Orange.length;
map.addOverlays(Paramus);
centerByArray(Paramus, false, false);
cntMarker += Paramus.length;
map.addOverlays(Parlin);
centerByArray(Parlin, false, false);
cntMarker += Parlin.length;
map.addOverlays(Peapack);
centerByArray(Peapack, false, false);
cntMarker += Peapack.length;
map.addOverlays(Pompton_Plains);
centerByArray(Pompton_Plains, false, false);
cntMarker += Pompton_Plains.length;
map.addOverlays(Rutherford);
centerByArray(Rutherford, false, false);
cntMarker += Rutherford.length;
map.addOverlays(Somerset);
centerByArray(Somerset, false, false);
cntMarker += Somerset.length;
map.addOverlays(Sparta);
centerByArray(Sparta, false, false);
cntMarker += Sparta.length;
map.addOverlays(Teaneck);
centerByArray(Teaneck, false, false);
cntMarker += Teaneck.length;
map.addOverlays(Titusville);
centerByArray(Titusville, false, false);
cntMarker += Titusville.length;
map.addOverlays(Wall);
centerByArray(Wall, false, false);
cntMarker += Wall.length;
map.addOverlays(Warren);
centerByArray(Warren, false, false);
cntMarker += Warren.length;
centerByArray(Fairfield,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///17226,17419,17943,17343,17118,17139,17301,17697,17983,17995,17413,17587,17300,17451,17145,17302,18074,17188,18013,18009,17185,17419,17943,17118,17084,18107,34909,17139,18087,17301,17697,17974,17995,17300,17451,17420,18074,17970,18013,18009,17711,/all');
//window.open('/map.php?type=2&schools=17226,17419,17943,17343,17118,17139,17301,17697,17983,17995,17413,17587,17300,17451,17145,17302,18074,17188,18013,18009,17185,17419,17943,17118,17084,18107,34909,17139,18087,17301,17697,17974,17995,17300,17451,17420,18074,17970,18013,18009,17711,&school_level=&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;
}