function addMarkers(){ mySelect = document.getElementById('selection'); Lebanon = [];Flemington = [];Glen_Gardner = [];Clinton = [];Whitehouse_Station = [];Califon = [];Lambertville = [];Annandale = [];Princeton = [];Stanton = [];Bloomsbury = [];mySelect.options[mySelect.options.length] = new Option("Annandale schools",'all=Annandale'); 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("Glen Gardner schools",'all=Glen_Gardner'); 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("Princeton schools",'all=Princeton'); mySelect.options[mySelect.options.length] = new Option("Stanton schools",'all=Stanton'); mySelect.options[mySelect.options.length] = new Option("Whitehouse Station schools",'all=Whitehouse_Station'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Lebanon[Lebanon.length] = createMarker(new GPoint(-74.87412600,40.60040400),"
Acorn Montessori School
1222 Route 31
Lebanon, NJ 08833
Co-ed school, NS-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Acorn Montessori School",'Lebanon=' + Lebanon.length); Flemington[Flemington.length] = createMarker(new GPoint(-74.85491700,40.52929000),"
Cnt For Edc Advan/spring Run School
11 Minneakoning Road
Flemington, NJ 08822
Co-ed school, Ungraded
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Cnt For Edc Advan/spring Run School",'Flemington=' + Flemington.length); Glen_Gardner[Glen_Gardner.length] = createMarker(new GPoint(-74.91360000,40.71280000),"
Creative Basics At The Old School
Po Box 488
Glen Gardner, NJ 08826
Co-ed school, PK-K
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Creative Basics At The Old School",'Glen_Gardner=' + Glen_Gardner.length); Clinton[Clinton.length] = createMarker(new GPoint(-74.92182400,40.62935400),"
Crossroads Christian Academy
9 Pittstown Road
Clinton, NJ 08809
Co-ed school, PK-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Crossroads Christian Academy",'Clinton=' + Clinton.length); Whitehouse_Station[Whitehouse_Station.length] = createMarker(new GPoint(-74.77052200,40.62468600),"
First Step Learning Centers
2 Lake Drive
Whitehouse Station, NJ 08889
Co-ed school, NS-K
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("First Step Learning Centers",'Whitehouse_Station=' + Whitehouse_Station.length); Flemington[Flemington.length] = createMarker(new GPoint(-74.85409900,40.53626300),"
Flemington Country Day School
1a Leisure Court
Flemington, NJ 08822
Co-ed school, PK-K
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Flemington Country Day School",'Flemington=' + Flemington.length); Califon[Califon.length] = createMarker(new GPoint(-74.88496800,40.70802600),"
Hayth's Preschool, Kindergarten And Childcare
4 High View Street
Califon, NJ 07830
Co-ed school, PK-K
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Hayth's Preschool, Kindergarten And Childcare",'Califon=' + Califon.length); Lambertville[Lambertville.length] = createMarker(new GPoint(-74.87298700,40.50350600),"
Hunterdon Christian Academy
638 Brunswick Pike
Lambertville, NJ 08822
Co-ed school, PK-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Hunterdon Christian Academy",'Lambertville=' + Lambertville.length); Annandale[Annandale.length] = createMarker(new GPoint(-74.91640000,40.64000000),"
Immaculate Conception School
314 Old Allerton Road
Annandale, NJ 08801
Co-ed school, PK-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Immaculate Conception School",'Annandale=' + Annandale.length); Lebanon[Lebanon.length] = createMarker(new GPoint(-74.86337800,40.61469500),"
Ivy Leaf School
22 Allerton Road
Lebanon, NJ 08833
Co-ed school, PK-1
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Ivy Leaf School",'Lebanon=' + Lebanon.length); Lambertville[Lambertville.length] = createMarker(new GPoint(-74.94515800,40.36577900),"
Jesus School
44 Bridge Street
Lambertville, NJ 08530
Co-ed school, PK-K
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Jesus School",'Lambertville=' + Lambertville.length); Lebanon[Lebanon.length] = createMarker(new GPoint(-74.55315300,40.33148600),"
Kiddie Academy Of Lebanon
1388 Us Highway 22
Lebanon, NJ 08833
Co-ed school, NS-PK
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Kiddie Academy Of Lebanon",'Lebanon=' + Lebanon.length); Flemington[Flemington.length] = createMarker(new GPoint(-74.84608200,40.50786600),"
Kindercare Learning Center
4 Royal Road
Flemington, NJ 08822
Co-ed school, PK-K
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Kindercare Learning Center",'Flemington=' + Flemington.length); Whitehouse_Station[Whitehouse_Station.length] = createMarker(new GPoint(-74.77647100,40.60676600),"
The Merck Child Learning Center
199 Hall''''s Mill Road
Whitehouse Station, NJ 08889
Co-ed school, NS-K
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("The Merck Child Learning Center",'Whitehouse_Station=' + Whitehouse_Station.length); Flemington[Flemington.length] = createMarker(new GPoint(-74.86347500,40.49535600),"
Montessori Preschool Center Of Flemington
275 S Main Street
Flemington, NJ 08822
Co-ed school, PK-K
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Montessori Preschool Center Of Flemington",'Flemington=' + Flemington.length); Princeton[Princeton.length] = createMarker(new GPoint(-74.82076500,40.38302200),"
Princeton Latin Academy
Rambling Pines Route 518
Princeton, NJ 08525
Co-ed school, K-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Princeton Latin Academy",'Princeton=' + Princeton.length); Flemington[Flemington.length] = createMarker(new GPoint(-74.82435100,40.50449500),"
Rainbow Rascals Learning Center
43 Barley Sheaf Road
Flemington, NJ 08822
Co-ed school, PK-KG
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Rainbow Rascals Learning Center",'Flemington=' + Flemington.length); Flemington[Flemington.length] = createMarker(new GPoint(-74.85769200,40.53445000),"
St. Paul Christian School
201 Hwy 31
Flemington, NJ 08822
Co-ed school, PK-3
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("St. Paul Christian School",'Flemington=' + Flemington.length); Stanton[Stanton.length] = createMarker(new GPoint(-74.82903400,40.57343500),"
Stanton Learning Center
Po Box 144
Stanton, NJ 08885
Co-ed school, NS-PK
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Stanton Learning Center",'Stanton=' + Stanton.length); Bloomsbury[Bloomsbury.length] = createMarker(new GPoint(-75.13522800,40.63766800),"
Stepping Stone School
45 County Road 519
Bloomsbury, NJ 08804
Co-ed school, 2-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Stepping Stone School",'Bloomsbury=' + Bloomsbury.length); Flemington[Flemington.length] = createMarker(new GPoint(-74.85421900,40.51944700),"
Village Montessori School
105 Highway 31 Suite 700
Flemington, NJ 08822
Co-ed school, NS-PK
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Village Montessori School",'Flemington=' + Flemington.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/////1/' + showArray); map.removeOverlays(Annandale); map.removeOverlays(Bloomsbury); map.removeOverlays(Califon); map.removeOverlays(Clinton); map.removeOverlays(Flemington); map.removeOverlays(Glen_Gardner); map.removeOverlays(Lambertville); map.removeOverlays(Lebanon); map.removeOverlays(Princeton); map.removeOverlays(Stanton); 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(Lebanon);map.removeOverlays(Annandale); map.removeOverlays(Bloomsbury); map.removeOverlays(Califon); map.removeOverlays(Clinton); map.removeOverlays(Flemington); map.removeOverlays(Glen_Gardner); map.removeOverlays(Lambertville); map.removeOverlays(Lebanon); map.removeOverlays(Princeton); map.removeOverlays(Stanton); map.removeOverlays(Whitehouse_Station); map.addOverlays(Annandale); centerByArray(Annandale, false, false); cntMarker += Annandale.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(Glen_Gardner); centerByArray(Glen_Gardner, false, false); cntMarker += Glen_Gardner.length; map.addOverlays(Lambertville); centerByArray(Lambertville, false, false); cntMarker += Lambertville.length; map.addOverlays(Lebanon); centerByArray(Lebanon, false, false); cntMarker += Lebanon.length; map.addOverlays(Princeton); centerByArray(Princeton, false, false); cntMarker += Princeton.length; map.addOverlays(Stanton); centerByArray(Stanton, false, false); cntMarker += Stanton.length; map.addOverlays(Whitehouse_Station); centerByArray(Whitehouse_Station, false, false); cntMarker += Whitehouse_Station.length; centerByArray(Lebanon,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=1&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; }