function addMarkers() { mySelect = document.getElementById('selection'); Aurora = [];Washington = [];Bath = [];Chocowinity = [];Pinetown = [];mySelect.options[mySelect.options.length] = new Option("Aurora schools",'all=Aurora'); mySelect.options[mySelect.options.length] = new Option("Bath schools",'all=Bath'); mySelect.options[mySelect.options.length] = new Option("Chocowinity schools",'all=Chocowinity'); mySelect.options[mySelect.options.length] = new Option("Pinetown schools",'all=Pinetown'); mySelect.options[mySelect.options.length] = new Option("Washington schools",'all=Washington'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Aurora[Aurora.length] = createMarker(new GPoint(-76.79152679,35.29978180),"
Aurora Middle School
693 North 7th Street
Aurora, NC 27806

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Aurora Middle School",'Aurora=' + Aurora.length); Washington[Washington.length] = createMarker(new GPoint(-77.04842377,35.54502106),"
B C Ed Tech Center
511 Harvey Street
Washington, NC 27899

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("B C Ed Tech Center",'Washington=' + Washington.length); Bath[Bath.length] = createMarker(new GPoint(-76.76660156,35.46179962),"
Bath Elementary School
110 S King Street
Bath, NC 27808

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Bath Elementary School",'Bath=' + Bath.length); Chocowinity[Chocowinity.length] = createMarker(new GPoint(-77.07890320,35.46960068),"
Chocowinity Middle School
3831 Us Hwy 17 S
Chocowinity, NC 27817

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Chocowinity Middle School",'Chocowinity=' + Chocowinity.length); Chocowinity[Chocowinity.length] = createMarker(new GPoint(-77.07890320,35.46960068),"
Chocowinity Primary
606 Gray Road
Chocowinity, NC 27817

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Chocowinity Primary",'Chocowinity=' + Chocowinity.length); Washington[Washington.length] = createMarker(new GPoint(-77.03638458,35.54513550),"
Eastern Elementary School
947 Hudnell Street
Washington, NC 27889

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Eastern Elementary School",'Washington=' + Washington.length); Washington[Washington.length] = createMarker(new GPoint(-77.06336975,35.55773163),"
John C Tayloe Elementary School
910 Tarboro Street
Washington, NC 27889

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("John C Tayloe Elementary School",'Washington=' + Washington.length); Washington[Washington.length] = createMarker(new GPoint(-77.05569458,35.55193329),"
John Small Elementary School
820 North Bridge Street
Washington, NC 27889

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("John Small Elementary School",'Washington=' + Washington.length); Pinetown[Pinetown.length] = createMarker(new GPoint(-76.83879852,35.59489822),"
Northeast Elementary School
21000 Us Hwy 264 East
Pinetown, NC 27865

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Northeast Elementary School",'Pinetown=' + Pinetown.length); Pinetown[Pinetown.length] = createMarker(new GPoint(-76.83879852,35.59489822),"
Northside High School
7868 Free Union Road
Pinetown, NC 27865

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Northside High School",'Pinetown=' + Pinetown.length); Washington[Washington.length] = createMarker(new GPoint(-77.04801178,35.54839325),"
P S Jones Middle School
230 E 8th Street
Washington, NC 27889

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("P S Jones Middle School",'Washington=' + Washington.length); Aurora[Aurora.length] = createMarker(new GPoint(-76.77940369,35.31859970),"
S W Snowden Elementary School
6921 Nc 306 North
Aurora, NC 27806

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("S W Snowden Elementary School",'Aurora=' + Aurora.length); Chocowinity[Chocowinity.length] = createMarker(new GPoint(-77.07890320,35.46960068),"
Southside High School
5700 Hwy 33 East
Chocowinity, NC 27817

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Southside High School",'Chocowinity=' + Chocowinity.length); Washington[Washington.length] = createMarker(new GPoint(-77.00774384,35.55860519),"
Washington High School
400 Slatestone Road
Washington, NC 27889

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Washington High School",'Washington=' + Washington.length); Washington[Washington.length] = createMarker(new GPoint(-77.02967834,35.54695129),"
Washington Montessori
500 Avon Center
Washington, NC 27889

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Washington Montessori",'Washington=' + Washington.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(Aurora); map.removeOverlays(Bath); map.removeOverlays(Chocowinity); map.removeOverlays(Pinetown); map.removeOverlays(Washington); 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(Aurora);map.removeOverlays(Aurora); map.removeOverlays(Bath); map.removeOverlays(Chocowinity); map.removeOverlays(Pinetown); map.removeOverlays(Washington); map.addOverlays(Aurora); centerByArray(Aurora, false, false); cntMarker += Aurora.length; map.addOverlays(Bath); centerByArray(Bath, false, false); cntMarker += Bath.length; map.addOverlays(Chocowinity); centerByArray(Chocowinity, false, false); cntMarker += Chocowinity.length; map.addOverlays(Pinetown); centerByArray(Pinetown, false, false); cntMarker += Pinetown.length; map.addOverlays(Washington); centerByArray(Washington, false, false); cntMarker += Washington.length; centerByArray(Aurora,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'); } }