function addMarkers() { mySelect = document.getElementById('selection'); Windsor = [];Aulander = [];Powellsville = [];Colerain = [];Merry_Hill = [];Lewiston_Woodville = [];mySelect.options[mySelect.options.length] = new Option("Aulander schools",'all=Aulander'); mySelect.options[mySelect.options.length] = new Option("Colerain schools",'all=Colerain'); mySelect.options[mySelect.options.length] = new Option("Lewiston Woodville schools",'all=Lewiston_Woodville'); mySelect.options[mySelect.options.length] = new Option("Merry Hill schools",'all=Merry_Hill'); mySelect.options[mySelect.options.length] = new Option("Powellsville schools",'all=Powellsville'); mySelect.options[mySelect.options.length] = new Option("Windsor schools",'all=Windsor'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Windsor[Windsor.length] = createMarker(new GPoint(-76.93678284,36.10874176),"
Askewville Elementary School
121 E Askewville Street
Windsor, NC 27983

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Askewville Elementary School",'Windsor=' + Windsor.length); Aulander[Aulander.length] = createMarker(new GPoint(-77.08119965,36.19079971),"
Aulander Elementary School
Po Box 310
Aulander, NC 27805

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Aulander Elementary School",'Aulander=' + Aulander.length); Windsor[Windsor.length] = createMarker(new GPoint(-76.94069672,36.01639938),"
Bertie High School
715 Us 13 N
Windsor, NC 27983

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Bertie High School",'Windsor=' + Windsor.length); Powellsville[Powellsville.length] = createMarker(new GPoint(-76.76802063,36.19849014),"
C G White Middle School
503 E Main Street
Powellsville, NC 27967

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("C G White Middle School",'Powellsville=' + Powellsville.length); Colerain[Colerain.length] = createMarker(new GPoint(-76.84400177,36.18080139),"
Colerain Elementary School
Po Box 188
Colerain, NC 27924

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Colerain Elementary School",'Colerain=' + Colerain.length); Merry_Hill[Merry_Hill.length] = createMarker(new GPoint(-76.75659943,36.08599854),"
John P Law Elementary School
Po Box 9
Merry Hill, NC 27957

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("John P Law Elementary School",'Merry_Hill=' + Merry_Hill.length); Windsor[Windsor.length] = createMarker(new GPoint(-76.94416046,35.97643280),"
Serendipity School
117 County Farm Road
Windsor, NC 27983

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Serendipity School",'Windsor=' + Windsor.length); Windsor[Windsor.length] = createMarker(new GPoint(-77.02655029,36.03893280),"
Southwestern Middle School
819 Governors Road
Windsor, NC 27983

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Southwestern Middle School",'Windsor=' + Windsor.length); Lewiston_Woodville[Lewiston_Woodville.length] = createMarker(new GPoint(-77.19300079,36.09289932),"
West Bertie Elementary School
Po Box 279
Lewiston Woodville, NC 27849

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("West Bertie Elementary School",'Lewiston_Woodville=' + Lewiston_Woodville.length); Windsor[Windsor.length] = createMarker(new GPoint(-76.91780853,35.98275757),"
Windsor Elementary School
104 Cooper Hill Road
Windsor, NC 27983

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Windsor Elementary School",'Windsor=' + Windsor.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(Aulander); map.removeOverlays(Colerain); map.removeOverlays(Lewiston_Woodville); map.removeOverlays(Merry_Hill); map.removeOverlays(Powellsville); map.removeOverlays(Windsor); 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(Windsor);map.removeOverlays(Aulander); map.removeOverlays(Colerain); map.removeOverlays(Lewiston_Woodville); map.removeOverlays(Merry_Hill); map.removeOverlays(Powellsville); map.removeOverlays(Windsor); map.addOverlays(Aulander); centerByArray(Aulander, false, false); cntMarker += Aulander.length; map.addOverlays(Colerain); centerByArray(Colerain, false, false); cntMarker += Colerain.length; map.addOverlays(Lewiston_Woodville); centerByArray(Lewiston_Woodville, false, false); cntMarker += Lewiston_Woodville.length; map.addOverlays(Merry_Hill); centerByArray(Merry_Hill, false, false); cntMarker += Merry_Hill.length; map.addOverlays(Powellsville); centerByArray(Powellsville, false, false); cntMarker += Powellsville.length; map.addOverlays(Windsor); centerByArray(Windsor, false, false); cntMarker += Windsor.length; centerByArray(Windsor,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'); } }