function addMarkers(){ mySelect = document.getElementById('selection'); Trenton = [];Princeton = [];Lawrenceville = [];Hightstown = [];Pennington = [];Ewing = [];Titusville = [];Hamilton = [];mySelect.options[mySelect.options.length] = new Option("Ewing schools",'all=Ewing'); mySelect.options[mySelect.options.length] = new Option("Hamilton schools",'all=Hamilton'); mySelect.options[mySelect.options.length] = new Option("Hightstown schools",'all=Hightstown'); mySelect.options[mySelect.options.length] = new Option("Lawrenceville schools",'all=Lawrenceville'); mySelect.options[mySelect.options.length] = new Option("Pennington schools",'all=Pennington'); mySelect.options[mySelect.options.length] = new Option("Princeton schools",'all=Princeton'); mySelect.options[mySelect.options.length] = new Option("Titusville schools",'all=Titusville'); mySelect.options[mySelect.options.length] = new Option("Trenton schools",'all=Trenton'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Trenton[Trenton.length] = createMarker(new GPoint(-74.70555000,40.18664900),"
Delaware Valley School For Exceptional Children
87 Pearson Drive
Trenton, NJ 08610
Co-ed school, 8-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Delaware Valley School For Exceptional Children",'Trenton=' + Trenton.length); Trenton[Trenton.length] = createMarker(new GPoint(-74.78357300,40.26686300),"
Family Guidance Center-childre
1925 Pennington Rd
Trenton, NJ 08618
Co-ed school, 1-10
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Family Guidance Center-childre",'Trenton=' + Trenton.length); Trenton[Trenton.length] = createMarker(new GPoint(-74.75940400,40.21787500),"
The G.a.r.v.e.y. School
Po Box 1214
Trenton, NJ 08607
Co-ed school, 9-11
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("The G.a.r.v.e.y. School",'Trenton=' + Trenton.length); Trenton[Trenton.length] = createMarker(new GPoint(-74.73213000,40.25328900),"
Garden State Academy
2160 Brunswick Ave.
Trenton, NJ 08648
Co-ed school, 9-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Garden State Academy",'Trenton=' + Trenton.length); Princeton[Princeton.length] = createMarker(new GPoint(-74.68276400,40.33804400),"
The Hun School
176 Edgerstoure Rd
Princeton, NJ 08540
Co-ed school, 6-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("The Hun School",'Princeton=' + Princeton.length); Lawrenceville[Lawrenceville.length] = createMarker(new GPoint(-74.72681900,40.25455000),"
The Lawrenceville School
Po Box 6008
Lawrenceville, NJ 08648
Co-ed school, 9-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("The Lawrenceville School",'Lawrenceville=' + Lawrenceville.length); Princeton[Princeton.length] = createMarker(new GPoint(-74.66622300,40.35098800),"
The Lewis School of Princeton
53 Bayard Lane
Princeton, NJ 08540
Co-ed school, NS-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("The Lewis School of Princeton",'Princeton=' + Princeton.length); Lawrenceville[Lawrenceville.length] = createMarker(new GPoint(-74.74218100,40.25416300),"
Notre Dame High School
601 Lawrence Road
Lawrenceville, NJ 08648
Co-ed school, 9-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Notre Dame High School",'Lawrenceville=' + Lawrenceville.length); Hightstown[Hightstown.length] = createMarker(new GPoint(-74.52820000,40.26520000),"
The Peddie School
Po Box A South Main St
Hightstown, NJ 08520
Co-ed school, 8-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("The Peddie School",'Hightstown=' + Hightstown.length); Pennington[Pennington.length] = createMarker(new GPoint(-74.79363600,40.32769400),"
The Pennington School
112 W Delaware Avenue
Pennington, NJ 08534
Co-ed school, 6-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("The Pennington School",'Pennington=' + Pennington.length); Princeton[Princeton.length] = createMarker(new GPoint(-74.73241100,40.33108500),"
Princeton Child Dev Inst
300 Cold Soil Rd
Princeton, NJ 08540
Co-ed school, NS-NS
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Princeton Child Dev Inst",'Princeton=' + Princeton.length); Princeton[Princeton.length] = createMarker(new GPoint(-74.72593200,40.34008300),"
Princeton Day School
PO Box 75
Princeton, NJ 08542
Co-ed school, PK-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Princeton Day School",'Princeton=' + Princeton.length); Trenton[Trenton.length] = createMarker(new GPoint(-74.74667700,40.21214900),"
Sr Georgine School
544 Chestnut Avenue
Trenton, NJ 08611
Co-ed school, 2-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Sr Georgine School",'Trenton=' + Trenton.length); Princeton[Princeton.length] = createMarker(new GPoint(-74.68573500,40.36883100),"
Stuart Country Day School
1200 Stuart Road
Princeton, NJ 08540
All-girls school, PK-12
[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Stuart Country Day School",'Princeton=' + Princeton.length); Ewing[Ewing.length] = createMarker(new GPoint(-74.77035000,40.26439700),"
The Studio For Experiential Learning
320 Hollowbrook Rd.
Ewing, NJ 08638
Co-ed school, K-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("The Studio For Experiential Learning",'Ewing=' + Ewing.length); Titusville[Titusville.length] = createMarker(new GPoint(-74.87665600,40.30422800),"
The Titusville Academy
86 River Drive
Titusville, NJ 08560
Co-ed school, K-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("The Titusville Academy",'Titusville=' + Titusville.length); Hamilton[Hamilton.length] = createMarker(new GPoint(-74.71841200,40.21828600),"
Trenton Catholic School
175 Leonard Avenue
Hamilton, NJ 08610
Co-ed school, PK-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Trenton Catholic School",'Hamilton=' + Hamilton.length); Trenton[Trenton.length] = createMarker(new GPoint(-74.84130900,40.25240700),"
Villa Victoria Academy
376 W Upper Ferry Road
Trenton, NJ 08628
All-girls school, PK-12
[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Villa Victoria Academy",'Trenton=' + Trenton.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(Ewing); map.removeOverlays(Hamilton); map.removeOverlays(Hightstown); map.removeOverlays(Lawrenceville); map.removeOverlays(Pennington); map.removeOverlays(Princeton); map.removeOverlays(Titusville); map.removeOverlays(Trenton); 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(Trenton);map.removeOverlays(Ewing); map.removeOverlays(Hamilton); map.removeOverlays(Hightstown); map.removeOverlays(Lawrenceville); map.removeOverlays(Pennington); map.removeOverlays(Princeton); map.removeOverlays(Titusville); map.removeOverlays(Trenton); map.addOverlays(Ewing); centerByArray(Ewing, false, false); cntMarker += Ewing.length; map.addOverlays(Hamilton); centerByArray(Hamilton, false, false); cntMarker += Hamilton.length; map.addOverlays(Hightstown); centerByArray(Hightstown, false, false); cntMarker += Hightstown.length; map.addOverlays(Lawrenceville); centerByArray(Lawrenceville, false, false); cntMarker += Lawrenceville.length; map.addOverlays(Pennington); centerByArray(Pennington, false, false); cntMarker += Pennington.length; map.addOverlays(Princeton); centerByArray(Princeton, false, false); cntMarker += Princeton.length; map.addOverlays(Titusville); centerByArray(Titusville, false, false); cntMarker += Titusville.length; map.addOverlays(Trenton); centerByArray(Trenton, false, false); cntMarker += Trenton.length; centerByArray(Trenton,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; }