function addMarkers(){ mySelect = document.getElementById('selection'); Sparta = [];Hamburg = [];Stanhope = [];Newton = [];Vernon = [];Franklin = [];Lafayette = [];Branchville = [];Sussex = [];Andover = [];mySelect.options[mySelect.options.length] = new Option("Andover schools",'all=Andover'); mySelect.options[mySelect.options.length] = new Option("Branchville schools",'all=Branchville'); mySelect.options[mySelect.options.length] = new Option("Franklin schools",'all=Franklin'); mySelect.options[mySelect.options.length] = new Option("Hamburg schools",'all=Hamburg'); mySelect.options[mySelect.options.length] = new Option("Lafayette schools",'all=Lafayette'); mySelect.options[mySelect.options.length] = new Option("Newton schools",'all=Newton'); mySelect.options[mySelect.options.length] = new Option("Sparta schools",'all=Sparta'); mySelect.options[mySelect.options.length] = new Option("Stanhope schools",'all=Stanhope'); mySelect.options[mySelect.options.length] = new Option("Sussex schools",'all=Sussex'); mySelect.options[mySelect.options.length] = new Option("Vernon schools",'all=Vernon'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Sparta[Sparta.length] = createMarker(new GPoint(-74.63258000,41.03941100),"
Alpine Montessori
57 Main Street
Sparta, NJ 07871
Co-ed school, PK-1
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Alpine Montessori",'Sparta=' + Sparta.length); Sparta[Sparta.length] = createMarker(new GPoint(-74.63410000,41.03620000),"
Blessed Beginnings Preschool & Kindergarten
32 Main Street
Sparta, NJ 07871
Co-ed school, NS-PK
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Blessed Beginnings Preschool & Kindergarten",'Sparta=' + Sparta.length); Hamburg[Hamburg.length] = createMarker(new GPoint(-74.56621600,41.13930900),"
Building Blocks Of Learning
106 Quarry Road
Hamburg, NJ 07419
Co-ed school, PK-KG
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Building Blocks Of Learning",'Hamburg=' + Hamburg.length); Stanhope[Stanhope.length] = createMarker(new GPoint(-74.70560000,40.91850000),"
Building Blocks Of Learning
30 Route 206
Stanhope, NJ 07874
Co-ed school, PK-KG
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Building Blocks Of Learning",'Stanhope=' + Stanhope.length); Newton[Newton.length] = createMarker(new GPoint(-74.78184500,41.06614900),"
Camp Auxilium Learning Center
14 Old Swartswood Road
Newton, NJ 07860
Co-ed school, NS-PK
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Camp Auxilium Learning Center",'Newton=' + Newton.length); Sparta[Sparta.length] = createMarker(new GPoint(-74.62457700,41.04019500),"
Children's Garden
60 Glen Road
Sparta, NJ 07871
Co-ed school, NS-PK
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Children's Garden",'Sparta=' + Sparta.length); Vernon[Vernon.length] = createMarker(new GPoint(-74.48688900,41.18789600),"
Fledglings Montessori School
514 State Rt 515 Po Bx 14
Vernon, NJ 07462
Co-ed school, PK-4
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Fledglings Montessori School",'Vernon=' + Vernon.length); Sparta[Sparta.length] = createMarker(new GPoint(-74.64368200,41.04151200),"
The Hilltop Country Day School
32 Lafayette Road
Sparta, NJ 07871
Co-ed school, NS-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("The Hilltop Country Day School",'Sparta=' + Sparta.length); Franklin[Franklin.length] = createMarker(new GPoint(-74.59160900,41.11648400),"
Immaculate Conception Regional School
65 Church Street
Franklin, NJ 07416
Co-ed school, PK-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Immaculate Conception Regional School",'Franklin=' + Franklin.length); Sparta[Sparta.length] = createMarker(new GPoint(-74.66014300,41.03621000),"
Kiddie Academy Child Care Lear
233 Sparta Ave
Sparta, NJ 07871
Co-ed school, PK-K
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Kiddie Academy Child Care Lear",'Sparta=' + Sparta.length); Sparta[Sparta.length] = createMarker(new GPoint(-76.47838200,39.34128700),"
Kiddie Academy Child Care Learning Center
233 Sparta Avenue
Sparta, NJ 07871
Co-ed school, NS-PK
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Kiddie Academy Child Care Learning Center",'Sparta=' + Sparta.length); Lafayette[Lafayette.length] = createMarker(new GPoint(-74.69340000,41.08590000),"
Lakeland-andover School
Po Box 200
Lafayette, NJ 07848
Co-ed school, 8-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Lakeland-andover School",'Lafayette=' + Lafayette.length); Branchville[Branchville.length] = createMarker(new GPoint(-74.76290000,41.17700000),"
Little Children's World
Po Box 306
Branchville, NJ 07826
Co-ed school, PK-K
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Little Children's World",'Branchville=' + Branchville.length); Newton[Newton.length] = createMarker(new GPoint(-74.74615900,41.09194000),"
Northwest Christian School
92 Route 519
Newton, NJ 07860
Co-ed school, PK-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Northwest Christian School",'Newton=' + Newton.length); Sparta[Sparta.length] = createMarker(new GPoint(-74.66728900,41.03303000),"
Pope John Xxiii High School
28 Andover Road
Sparta, NJ 07871
Co-ed school, 9-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Pope John Xxiii High School",'Sparta=' + Sparta.length); Hamburg[Hamburg.length] = createMarker(new GPoint(-74.57360000,41.15480000),"
Prince Of Peace Early Learning Center
Po Box 5 Rt 94
Hamburg, NJ 07419
Co-ed school, PK-K
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Prince Of Peace Early Learning Center",'Hamburg=' + Hamburg.length); Sparta[Sparta.length] = createMarker(new GPoint(-74.66396300,41.03386400),"
Rev George A Brown School
294 Sparta Ave
Sparta, NJ 07871
Co-ed school, K-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Rev George A Brown School",'Sparta=' + Sparta.length); Newton[Newton.length] = createMarker(new GPoint(-74.75148400,41.05589500),"
St Joseph Regional School
20 Jefferson Street
Newton, NJ 07860
Co-ed school, K-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("St Joseph Regional School",'Newton=' + Newton.length); Sussex[Sussex.length] = createMarker(new GPoint(-74.60376400,41.21266300),"
Sussex Christian School Assn
51 Unionville Avenue
Sussex, NJ 07461
Co-ed school, K-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Sussex Christian School Assn",'Sussex=' + Sussex.length); Sparta[Sparta.length] = createMarker(new GPoint(-74.66939200,41.07198500),"
Tiny Town Pre-school
99 Demarest Road
Sparta, NJ 07871
Co-ed school, NS-PK
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Tiny Town Pre-school",'Sparta=' + Sparta.length); Andover[Andover.length] = createMarker(new GPoint(-74.79257200,40.95003300),"
Tranquility Adventist School
3 Academy Lane
Andover, NJ 07821
Co-ed school, PK-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Tranquility Adventist School",'Andover=' + Andover.length); Sparta[Sparta.length] = createMarker(new GPoint(-74.66730200,41.07370300),"
Willowglen Academy
6 Gail Court Unit 4
Sparta, NJ 07871
Co-ed school, 3-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Willowglen Academy",'Sparta=' + Sparta.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/////3/' + showArray); map.removeOverlays(Andover); map.removeOverlays(Branchville); map.removeOverlays(Franklin); map.removeOverlays(Hamburg); map.removeOverlays(Lafayette); map.removeOverlays(Newton); map.removeOverlays(Sparta); map.removeOverlays(Stanhope); map.removeOverlays(Sussex); map.removeOverlays(Vernon); 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(Sparta);map.removeOverlays(Andover); map.removeOverlays(Branchville); map.removeOverlays(Franklin); map.removeOverlays(Hamburg); map.removeOverlays(Lafayette); map.removeOverlays(Newton); map.removeOverlays(Sparta); map.removeOverlays(Stanhope); map.removeOverlays(Sussex); map.removeOverlays(Vernon); map.addOverlays(Andover); centerByArray(Andover, false, false); cntMarker += Andover.length; map.addOverlays(Branchville); centerByArray(Branchville, false, false); cntMarker += Branchville.length; map.addOverlays(Franklin); centerByArray(Franklin, false, false); cntMarker += Franklin.length; map.addOverlays(Hamburg); centerByArray(Hamburg, false, false); cntMarker += Hamburg.length; map.addOverlays(Lafayette); centerByArray(Lafayette, false, false); cntMarker += Lafayette.length; map.addOverlays(Newton); centerByArray(Newton, false, false); cntMarker += Newton.length; map.addOverlays(Sparta); centerByArray(Sparta, false, false); cntMarker += Sparta.length; map.addOverlays(Stanhope); centerByArray(Stanhope, false, false); cntMarker += Stanhope.length; map.addOverlays(Sussex); centerByArray(Sussex, false, false); cntMarker += Sussex.length; map.addOverlays(Vernon); centerByArray(Vernon, false, false); cntMarker += Vernon.length; centerByArray(Sparta,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=3&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; }