function addMarkers(){ mySelect = document.getElementById('selection'); Convent_Station = [];Cedar_Knolls = [];Whippany = [];Wharton = [];Pompton_Plains = [];Morristown = [];Mountain_Lakes = [];Lincoln_Park = [];Mendham = [];Chatham = [];Gladstone = [];Denville = [];Parsippany = [];Riverdale = [];Montville = [];mySelect.options[mySelect.options.length] = new Option("Cedar Knolls schools",'all=Cedar_Knolls'); mySelect.options[mySelect.options.length] = new Option("Chatham schools",'all=Chatham'); mySelect.options[mySelect.options.length] = new Option("Convent Station schools",'all=Convent_Station'); mySelect.options[mySelect.options.length] = new Option("Denville schools",'all=Denville'); mySelect.options[mySelect.options.length] = new Option("Gladstone schools",'all=Gladstone'); mySelect.options[mySelect.options.length] = new Option("Lincoln Park schools",'all=Lincoln_Park'); mySelect.options[mySelect.options.length] = new Option("Mendham schools",'all=Mendham'); mySelect.options[mySelect.options.length] = new Option("Montville schools",'all=Montville'); mySelect.options[mySelect.options.length] = new Option("Morristown schools",'all=Morristown'); mySelect.options[mySelect.options.length] = new Option("Mountain Lakes schools",'all=Mountain_Lakes'); mySelect.options[mySelect.options.length] = new Option("Parsippany schools",'all=Parsippany'); mySelect.options[mySelect.options.length] = new Option("Pompton Plains schools",'all=Pompton_Plains'); mySelect.options[mySelect.options.length] = new Option("Riverdale schools",'all=Riverdale'); mySelect.options[mySelect.options.length] = new Option("Wharton schools",'all=Wharton'); mySelect.options[mySelect.options.length] = new Option("Whippany schools",'all=Whippany'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Convent_Station[Convent_Station.length] = createMarker(new GPoint(-74.48190000,40.79660000),"
Academy Of St. Elizabeth
Po Box 297
Convent Station, NJ 07961
All-girls school, 9-12
[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Academy Of St. Elizabeth",'Convent_Station=' + Convent_Station.length); Cedar_Knolls[Cedar_Knolls.length] = createMarker(new GPoint(-74.45040400,40.81944700),"
Allegro School, Inc.
125 Ridgedale Ave
Cedar Knolls, NJ 07927
Co-ed school, Ungraded
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Allegro School, Inc.",'Cedar_Knolls=' + Cedar_Knolls.length); Whippany[Whippany.length] = createMarker(new GPoint(-74.40964700,40.82495900),"
Calais School
45 Highland Ave
Whippany, NJ 07981
Co-ed school, K-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Calais School",'Whippany=' + Whippany.length); Wharton[Wharton.length] = createMarker(new GPoint(-74.57936900,40.88750300),"
Celebrate The Children
345 South Main Street
Wharton, NJ 07885
Co-ed school, PK-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Celebrate The Children",'Wharton=' + Wharton.length); Pompton_Plains[Pompton_Plains.length] = createMarker(new GPoint(-74.30270000,40.96590000),"
Chancellor Academy
Po Box 338 157 West Parkway
Pompton Plains, NJ 07444
Co-ed school, 8-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Chancellor Academy",'Pompton_Plains=' + Pompton_Plains.length); Morristown[Morristown.length] = createMarker(new GPoint(-74.49947800,40.80776300),"
Cheder Lubavitch
Po Box 1996
Morristown, NJ 07962
Co-ed school, PK-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Cheder Lubavitch",'Morristown=' + Morristown.length); Mountain_Lakes[Mountain_Lakes.length] = createMarker(new GPoint(-74.44451700,40.89080500),"
Craig School
10 Tower Hill Rd
Mountain Lakes, NJ 07046
Co-ed school, 3-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Craig School",'Mountain_Lakes=' + Mountain_Lakes.length); Mountain_Lakes[Mountain_Lakes.length] = createMarker(new GPoint(-74.44451700,40.89080500),"
The Craig School
10 Tower Hill Road
Mountain Lakes, NJ 07046
Co-ed school, 2-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("The Craig School",'Mountain_Lakes=' + Mountain_Lakes.length); Lincoln_Park[Lincoln_Park.length] = createMarker(new GPoint(-74.30226100,40.92672300),"
Craig Upper School
200 Comly Road
Lincoln Park, NJ 07035
Co-ed school, 9-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Craig Upper School",'Lincoln_Park=' + Lincoln_Park.length); Mendham[Mendham.length] = createMarker(new GPoint(-73.98407000,40.75302200),"
Daytop Preparatory School
80 W Main Street
Mendham, NJ 07945
Co-ed school, 9-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Daytop Preparatory School",'Mendham=' + Mendham.length); Morristown[Morristown.length] = createMarker(new GPoint(-74.52958500,40.79196800),"
Delbarton School
230 Mendham Road
Morristown, NJ 07960
All-boys school, 7-12
[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Delbarton School",'Morristown=' + Morristown.length); Chatham[Chatham.length] = createMarker(new GPoint(-74.38657700,40.73987300),"
Eclc Of New Jersey
21 Lum Ave.
Chatham, NJ 07928
Co-ed school, NS-NS
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Eclc Of New Jersey",'Chatham=' + Chatham.length); Gladstone[Gladstone.length] = createMarker(new GPoint(-74.66558400,40.72250000),"
Montgomery Academy
St. John''s Drive, PO Box 710
Gladstone, NJ 07934
Co-ed school, K-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Montgomery Academy",'Gladstone=' + Gladstone.length); Denville[Denville.length] = createMarker(new GPoint(-74.48784800,40.90236900),"
Morris Catholic High School
200 Morris Ave
Denville, NJ 07834
Co-ed school, 9-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Morris Catholic High School",'Denville=' + Denville.length); Morristown[Morristown.length] = createMarker(new GPoint(-74.44851400,40.80273900),"
The Morristown-beard School
70 Whippany Road
Morristown, NJ 07960
Co-ed school, 6-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("The Morristown-beard School",'Morristown=' + Morristown.length); Pompton_Plains[Pompton_Plains.length] = createMarker(new GPoint(-74.31320000,40.95202300),"
Netherlands Reformed Christian School
164 Jacksonville Road
Pompton Plains, NJ 07444
Co-ed school, PK-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Netherlands Reformed Christian School",'Pompton_Plains=' + Pompton_Plains.length); Parsippany[Parsippany.length] = createMarker(new GPoint(-74.36849900,40.86457000),"
Parsippany Christian School
Po Box 5365
Parsippany, NJ 07054
Co-ed school, PK-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Parsippany Christian School",'Parsippany=' + Parsippany.length); Riverdale[Riverdale.length] = createMarker(new GPoint(-74.30382500,40.99397200),"
Riverdale Baptist Christian
6 Newbury Place
Riverdale, NJ 07457
Co-ed school, PK-9
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Riverdale Baptist Christian",'Riverdale=' + Riverdale.length); Morristown[Morristown.length] = createMarker(new GPoint(-74.48330300,40.80368000),"
Shepard School
10 Columba Street
Morristown, NJ 07960
Co-ed school, 9-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Shepard School",'Morristown=' + Morristown.length); Montville[Montville.length] = createMarker(new GPoint(-74.36498400,40.88617600),"
The Trinity Christian School O
160 Change Bridge
Montville, NJ 07045
Co-ed school, NS-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("The Trinity Christian School O",'Montville=' + Montville.length); Morristown[Morristown.length] = createMarker(new GPoint(-74.51046100,40.78167000),"
Villa Walsh Academy
455 Western Avenue
Morristown, NJ 07960
All-girls school, 7-12
[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Villa Walsh Academy",'Morristown=' + Morristown.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/////2/' + showArray); map.removeOverlays(Cedar_Knolls); map.removeOverlays(Chatham); map.removeOverlays(Convent_Station); map.removeOverlays(Denville); map.removeOverlays(Gladstone); map.removeOverlays(Lincoln_Park); map.removeOverlays(Mendham); map.removeOverlays(Montville); map.removeOverlays(Morristown); map.removeOverlays(Mountain_Lakes); map.removeOverlays(Parsippany); map.removeOverlays(Pompton_Plains); map.removeOverlays(Riverdale); map.removeOverlays(Wharton); map.removeOverlays(Whippany); 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(Convent_Station);map.removeOverlays(Cedar_Knolls); map.removeOverlays(Chatham); map.removeOverlays(Convent_Station); map.removeOverlays(Denville); map.removeOverlays(Gladstone); map.removeOverlays(Lincoln_Park); map.removeOverlays(Mendham); map.removeOverlays(Montville); map.removeOverlays(Morristown); map.removeOverlays(Mountain_Lakes); map.removeOverlays(Parsippany); map.removeOverlays(Pompton_Plains); map.removeOverlays(Riverdale); map.removeOverlays(Wharton); map.removeOverlays(Whippany); map.addOverlays(Cedar_Knolls); centerByArray(Cedar_Knolls, false, false); cntMarker += Cedar_Knolls.length; map.addOverlays(Chatham); centerByArray(Chatham, false, false); cntMarker += Chatham.length; map.addOverlays(Convent_Station); centerByArray(Convent_Station, false, false); cntMarker += Convent_Station.length; map.addOverlays(Denville); centerByArray(Denville, false, false); cntMarker += Denville.length; map.addOverlays(Gladstone); centerByArray(Gladstone, false, false); cntMarker += Gladstone.length; map.addOverlays(Lincoln_Park); centerByArray(Lincoln_Park, false, false); cntMarker += Lincoln_Park.length; map.addOverlays(Mendham); centerByArray(Mendham, false, false); cntMarker += Mendham.length; map.addOverlays(Montville); centerByArray(Montville, false, false); cntMarker += Montville.length; map.addOverlays(Morristown); centerByArray(Morristown, false, false); cntMarker += Morristown.length; map.addOverlays(Mountain_Lakes); centerByArray(Mountain_Lakes, false, false); cntMarker += Mountain_Lakes.length; map.addOverlays(Parsippany); centerByArray(Parsippany, false, false); cntMarker += Parsippany.length; map.addOverlays(Pompton_Plains); centerByArray(Pompton_Plains, false, false); cntMarker += Pompton_Plains.length; map.addOverlays(Riverdale); centerByArray(Riverdale, false, false); cntMarker += Riverdale.length; map.addOverlays(Wharton); centerByArray(Wharton, false, false); cntMarker += Wharton.length; map.addOverlays(Whippany); centerByArray(Whippany, false, false); cntMarker += Whippany.length; centerByArray(Convent_Station,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=2&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; }