function addMarkers() { mySelect = document.getElementById('selection'); New_Bern = [];Havelock = [];Cove_City = [];Vanceboro = [];mySelect.options[mySelect.options.length] = new Option("Cove City schools",'all=Cove_City'); mySelect.options[mySelect.options.length] = new Option("Havelock schools",'all=Havelock'); mySelect.options[mySelect.options.length] = new Option("New Bern schools",'all=New_Bern'); mySelect.options[mySelect.options.length] = new Option("Vanceboro schools",'all=Vanceboro'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); New_Bern[New_Bern.length] = createMarker(new GPoint(-77.08387756,35.08241653),"
Albert H Bangert Elementary School
3712 Canterbury Road
New Bern, NC 28562

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Albert H Bangert Elementary School",'New_Bern=' + New_Bern.length); Havelock[Havelock.length] = createMarker(new GPoint(-76.92912292,34.91156387),"
Arthur W Edwards Elementary School
200 Education Lane
Havelock, NC 28532

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Arthur W Edwards Elementary School",'Havelock=' + Havelock.length); New_Bern[New_Bern.length] = createMarker(new GPoint(-77.13136292,35.09376144),"
Ben D Quinn Elementary School
4275 M L King Jr Boulevard
New Bern, NC 28562

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Ben D Quinn Elementary School",'New_Bern=' + New_Bern.length); New_Bern[New_Bern.length] = createMarker(new GPoint(-77.02050018,35.12220001),"
Bridgeton Elementary School
230 Branch Canal Road
New Bern, NC 28560

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Bridgeton Elementary School",'New_Bern=' + New_Bern.length); New_Bern[New_Bern.length] = createMarker(new GPoint(-77.04207200,35.10843000),"
Brinson Memorial Elementary School
319 Neuse Forest Avenue
New Bern, NC 28560

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Brinson Memorial Elementary School",'New_Bern=' + New_Bern.length); Havelock[Havelock.length] = createMarker(new GPoint(-76.91551208,34.89635086),"
Graham A Barden Elementary School
200 Cedar Drive
Havelock, NC 28532

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Graham A Barden Elementary School",'Havelock=' + Havelock.length); New_Bern[New_Bern.length] = createMarker(new GPoint(-77.07191467,35.10897446),"
Grover C Fields Middle School
2000 M L King Jr Boulevard
New Bern, NC 28560

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Grover C Fields Middle School",'New_Bern=' + New_Bern.length); New_Bern[New_Bern.length] = createMarker(new GPoint(-77.09468842,35.11718750),"
H J Macdonald Middle School
3127 Elizabeth Avenue
New Bern, NC 28562

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("H J Macdonald Middle School",'New_Bern=' + New_Bern.length); Havelock[Havelock.length] = createMarker(new GPoint(-76.90148926,34.87849808),"
Havelock Elementary School
201 Cunningham Boulevard
Havelock, NC 28532

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Havelock Elementary School",'Havelock=' + Havelock.length); Havelock[Havelock.length] = createMarker(new GPoint(-76.89493561,34.88231277),"
Havelock High School
101 Webb Boulevard
Havelock, NC 28532

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Havelock High School",'Havelock=' + Havelock.length); Havelock[Havelock.length] = createMarker(new GPoint(-76.89740753,34.87759781),"
Havelock Middle School
102 High School Drive
Havelock, NC 28532

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Havelock Middle School",'Havelock=' + Havelock.length); New_Bern[New_Bern.length] = createMarker(new GPoint(-77.06259155,35.11811829),"
J T Barber Elementary School
1700 Cobb Street
New Bern, NC 28560

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("J T Barber Elementary School",'New_Bern=' + New_Bern.length); Cove_City[Cove_City.length] = createMarker(new GPoint(-77.28803253,35.24890900),"
James W Smith Elementary School
150 Koonce Town Road
Cove City, NC 28523

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("James W Smith Elementary School",'Cove_City=' + Cove_City.length); New_Bern[New_Bern.length] = createMarker(new GPoint(-77.11409100,35.09868600),"
New Bern High School
4200 Academic Drive
New Bern, NC 28562

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("New Bern High School",'New_Bern=' + New_Bern.length); New_Bern[New_Bern.length] = createMarker(new GPoint(-77.06403351,35.12805939),"
Oaks Road Elementary School
2811 Oaks Road
New Bern, NC 28560

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Oaks Road Elementary School",'New_Bern=' + New_Bern.length); Havelock[Havelock.length] = createMarker(new GPoint(-76.88088226,34.88246918),"
Roger R Bell Elementary School
804 Fontana Boulevard
Havelock, NC 28532

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Roger R Bell Elementary School",'Havelock=' + Havelock.length); New_Bern[New_Bern.length] = createMarker(new GPoint(-77.07814789,35.10939026),"
Trent Park Elementary School
2500 Educational Drive
New Bern, NC 28562

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Trent Park Elementary School",'New_Bern=' + New_Bern.length); Havelock[Havelock.length] = createMarker(new GPoint(-76.94002533,34.93423080),"
Tucker Creek Middle School
200 Sermons Boulevard
Havelock, NC 28532

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Tucker Creek Middle School",'Havelock=' + Havelock.length); Vanceboro[Vanceboro.length] = createMarker(new GPoint(-77.14701843,35.30606842),"
Vanceboro-farm Life Elementary School
2000 Farm Life Avenue
Vanceboro, NC 28586

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Vanceboro-farm Life Elementary School",'Vanceboro=' + Vanceboro.length); Havelock[Havelock.length] = createMarker(new GPoint(-76.90132141,34.87908936),"
W Jesse Gurganus Elementary School
535 Hwy 70 W
Havelock, NC 28532

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("W Jesse Gurganus Elementary School",'Havelock=' + Havelock.length); Vanceboro[Vanceboro.length] = createMarker(new GPoint(-77.15451813,35.30915070),"
West Craven High School
2600 Streets Ferry Road
Vanceboro, NC 28586

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("West Craven High School",'Vanceboro=' + Vanceboro.length); New_Bern[New_Bern.length] = createMarker(new GPoint(-77.04434967,35.10837173),"
West Craven Middle School
515 Nw Craven Mid School Road
New Bern, NC 28562

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("West Craven Middle School",'New_Bern=' + New_Bern.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,10); /* 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////' + showArray); map.removeOverlays(Cove_City); map.removeOverlays(Havelock); map.removeOverlays(New_Bern); map.removeOverlays(Vanceboro); 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(New_Bern);map.removeOverlays(Cove_City); map.removeOverlays(Havelock); map.removeOverlays(New_Bern); map.removeOverlays(Vanceboro); map.addOverlays(Cove_City); centerByArray(Cove_City, false, false); cntMarker += Cove_City.length; map.addOverlays(Havelock); centerByArray(Havelock, false, false); cntMarker += Havelock.length; map.addOverlays(New_Bern); centerByArray(New_Bern, false, false); cntMarker += New_Bern.length; map.addOverlays(Vanceboro); centerByArray(Vanceboro, false, false); cntMarker += Vanceboro.length; centerByArray(New_Bern,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'); } }