function addMarkers(){ mySelect = document.getElementById('selection'); Elizabeth = [];Fanwood = [];Scotch_Plains = [];Cranford = [];Garwood = [];Union = [];Summit = [];Winfield = [];Plainfield = [];Clark = [];Roselle = [];Linden = [];mySelect.options[mySelect.options.length] = new Option("Clark schools",'all=Clark'); mySelect.options[mySelect.options.length] = new Option("Cranford schools",'all=Cranford'); mySelect.options[mySelect.options.length] = new Option("Elizabeth schools",'all=Elizabeth'); mySelect.options[mySelect.options.length] = new Option("Fanwood schools",'all=Fanwood'); mySelect.options[mySelect.options.length] = new Option("Garwood schools",'all=Garwood'); mySelect.options[mySelect.options.length] = new Option("Linden schools",'all=Linden'); mySelect.options[mySelect.options.length] = new Option("Plainfield schools",'all=Plainfield'); mySelect.options[mySelect.options.length] = new Option("Roselle schools",'all=Roselle'); mySelect.options[mySelect.options.length] = new Option("Scotch Plains schools",'all=Scotch_Plains'); mySelect.options[mySelect.options.length] = new Option("Summit schools",'all=Summit'); mySelect.options[mySelect.options.length] = new Option("Union schools",'all=Union'); mySelect.options[mySelect.options.length] = new Option("Winfield schools",'all=Winfield'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Elizabeth[Elizabeth.length] = createMarker(new GPoint(-74.21456800,40.68328600),"
Benedictine Academy
840 North Broad Street
Elizabeth, NJ 07208
All-girls school, 9-12
[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Benedictine Academy",'Elizabeth=' + Elizabeth.length); Elizabeth[Elizabeth.length] = createMarker(new GPoint(-74.21554300,40.68214300),"
Bruriah High School For Girls
35 North Avenue
Elizabeth, NJ 07208
All-girls school, 7-12
[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Bruriah High School For Girls",'Elizabeth=' + Elizabeth.length); Fanwood[Fanwood.length] = createMarker(new GPoint(-74.38029000,40.64207600),"
Children's Specialized Hosp./s
330 South Avenue
Fanwood, NJ 07023
Co-ed school, NS-2
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Children's Specialized Hosp./s",'Fanwood=' + Fanwood.length); Scotch_Plains[Scotch_Plains.length] = createMarker(new GPoint(-74.37380600,40.62385600),"
Christopher Academy
1390 Terrill Road
Scotch Plains, NJ 07076
Co-ed school, PK-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Christopher Academy",'Scotch_Plains=' + Scotch_Plains.length); Cranford[Cranford.length] = createMarker(new GPoint(-74.31018800,40.65287000),"
Crestview Educational Trust
30 Lincoln Avenue W
Cranford, NJ 07016
Co-ed school, 6-11
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Crestview Educational Trust",'Cranford=' + Cranford.length); Garwood[Garwood.length] = createMarker(new GPoint(-74.32386100,40.65464100),"
Deron School Of Nj
320 2nd Avenue
Garwood, NJ 07027
Co-ed school, NS-NS
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Deron School Of Nj",'Garwood=' + Garwood.length); Union[Union.length] = createMarker(new GPoint(-74.24960900,40.67403500),"
The Jardine Academy
373 Clermont Terrace
Union, NJ 07083
Co-ed school, NS-NS
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("The Jardine Academy",'Union=' + Union.length); Elizabeth[Elizabeth.length] = createMarker(new GPoint(-74.23414200,40.66693900),"
Jewish Educational Center
330 Elmora Avenue
Elizabeth, NJ 07208
Co-ed school, PK-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Jewish Educational Center",'Elizabeth=' + Elizabeth.length); Summit[Summit.length] = createMarker(new GPoint(-74.36370200,40.72043600),"
Kent Place School
42 Norwood Avenue
Summit, NJ 07901
All-girls school, PK-12
[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Kent Place School",'Summit=' + Summit.length); Winfield[Winfield.length] = createMarker(new GPoint(-74.28476000,40.63618100),"
Kohler School
39 12 Wavecrest Ave
Winfield, NJ 07036
Co-ed school, Ungraded
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Kohler School",'Winfield=' + Winfield.length); Plainfield[Plainfield.length] = createMarker(new GPoint(-74.42103400,40.60392500),"
Koinonia Academy
1040 Plainfield Ave
Plainfield, NJ 07060
Co-ed school, NS-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Koinonia Academy",'Plainfield=' + Plainfield.length); Clark[Clark.length] = createMarker(new GPoint(-74.28149400,40.62992500),"
Mother Seton Regional High School
Valley Road
Clark, NJ 07066
All-girls school, 9-12
[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Mother Seton Regional High School",'Clark=' + Clark.length); Summit[Summit.length] = createMarker(new GPoint(-74.36721300,40.71197700),"
Oak Knoll School Of The Holy Child
44 Blackburn Road
Summit, NJ 07901
Co-ed school, K-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Oak Knoll School Of The Holy Child",'Summit=' + Summit.length); Summit[Summit.length] = createMarker(new GPoint(-74.36974300,40.72401200),"
Oratory Preparatory School
1 Beverly Road
Summit, NJ 07901
All-boys school, 7-12
[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Oratory Preparatory School",'Summit=' + Summit.length); Roselle[Roselle.length] = createMarker(new GPoint(-74.26248000,40.64626600),"
Roselle Catholic High School
350 Raritan Road
Roselle, NJ 07203
Co-ed school, 9-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Roselle Catholic High School",'Roselle=' + Roselle.length); Elizabeth[Elizabeth.length] = createMarker(new GPoint(-74.21556600,40.65893200),"
St. Mary Of The Assumption High School
237 South Broad Street
Elizabeth, NJ 07202
Co-ed school, 9-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("St. Mary Of The Assumption High School",'Elizabeth=' + Elizabeth.length); Elizabeth[Elizabeth.length] = createMarker(new GPoint(-74.18679800,40.65237300),"
St. Patrick High School
221 Court Street
Elizabeth, NJ 07206
Co-ed school, 9-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("St. Patrick High School",'Elizabeth=' + Elizabeth.length); Cranford[Cranford.length] = createMarker(new GPoint(-74.29909100,40.66713400),"
Solomon Schechter Day School
721 Orange Avenue
Cranford, NJ 07016
Co-ed school, PK-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Solomon Schechter Day School",'Cranford=' + Cranford.length); Elizabeth[Elizabeth.length] = createMarker(new GPoint(-74.22984500,40.66353300),"
Trinity Christian Academy
417 Pennington St
Elizabeth, NJ 07202
Co-ed school, PK-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Trinity Christian Academy",'Elizabeth=' + Elizabeth.length); Scotch_Plains[Scotch_Plains.length] = createMarker(new GPoint(-74.35796800,40.62610700),"
Union Catholic Regional High School
1600 Martine Avenue
Scotch Plains, NJ 07076
Co-ed school, 9-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Union Catholic Regional High School",'Scotch_Plains=' + Scotch_Plains.length); Linden[Linden.length] = createMarker(new GPoint(-74.22290100,40.64575300),"
Victory Christian Academy
2301 Grier Avenue
Linden, NJ 07036
Co-ed school, PK-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Victory Christian Academy",'Linden=' + Linden.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(Clark); map.removeOverlays(Cranford); map.removeOverlays(Elizabeth); map.removeOverlays(Fanwood); map.removeOverlays(Garwood); map.removeOverlays(Linden); map.removeOverlays(Plainfield); map.removeOverlays(Roselle); map.removeOverlays(Scotch_Plains); map.removeOverlays(Summit); map.removeOverlays(Union); map.removeOverlays(Winfield); 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(Elizabeth);map.removeOverlays(Clark); map.removeOverlays(Cranford); map.removeOverlays(Elizabeth); map.removeOverlays(Fanwood); map.removeOverlays(Garwood); map.removeOverlays(Linden); map.removeOverlays(Plainfield); map.removeOverlays(Roselle); map.removeOverlays(Scotch_Plains); map.removeOverlays(Summit); map.removeOverlays(Union); map.removeOverlays(Winfield); map.addOverlays(Clark); centerByArray(Clark, false, false); cntMarker += Clark.length; map.addOverlays(Cranford); centerByArray(Cranford, false, false); cntMarker += Cranford.length; map.addOverlays(Elizabeth); centerByArray(Elizabeth, false, false); cntMarker += Elizabeth.length; map.addOverlays(Fanwood); centerByArray(Fanwood, false, false); cntMarker += Fanwood.length; map.addOverlays(Garwood); centerByArray(Garwood, false, false); cntMarker += Garwood.length; map.addOverlays(Linden); centerByArray(Linden, false, false); cntMarker += Linden.length; map.addOverlays(Plainfield); centerByArray(Plainfield, false, false); cntMarker += Plainfield.length; map.addOverlays(Roselle); centerByArray(Roselle, false, false); cntMarker += Roselle.length; map.addOverlays(Scotch_Plains); centerByArray(Scotch_Plains, false, false); cntMarker += Scotch_Plains.length; map.addOverlays(Summit); centerByArray(Summit, false, false); cntMarker += Summit.length; map.addOverlays(Union); centerByArray(Union, false, false); cntMarker += Union.length; map.addOverlays(Winfield); centerByArray(Winfield, false, false); cntMarker += Winfield.length; centerByArray(Elizabeth,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; }