function addMarkers() { mySelect = document.getElementById('selection'); Rockingham = [];Cordova = [];Ellerbe = [];Hamlet = [];Hoffman = [];mySelect.options[mySelect.options.length] = new Option("Cordova schools",'all=Cordova'); mySelect.options[mySelect.options.length] = new Option("Ellerbe schools",'all=Ellerbe'); mySelect.options[mySelect.options.length] = new Option("Hamlet schools",'all=Hamlet'); mySelect.options[mySelect.options.length] = new Option("Hoffman schools",'all=Hoffman'); mySelect.options[mySelect.options.length] = new Option("Rockingham schools",'all=Rockingham'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Rockingham[Rockingham.length] = createMarker(new GPoint(-79.77365112,34.93909073),"
Ashley Chapel Elementary School
377 Mispah Rd
Rockingham, NC 28379

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Ashley Chapel Elementary School",'Rockingham=' + Rockingham.length); Cordova[Cordova.length] = createMarker(new GPoint(-79.82199860,34.91299820),"
Cordova Elementary School
Po Box 149
Cordova, NC 28330

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Cordova Elementary School",'Cordova=' + Cordova.length); Ellerbe[Ellerbe.length] = createMarker(new GPoint(-79.76143646,35.07387543),"
Ellerbe Junior High School
128 W Ballard Street
Ellerbe, NC 28338

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Ellerbe Junior High School",'Ellerbe=' + Ellerbe.length); Hamlet[Hamlet.length] = createMarker(new GPoint(-79.71205902,34.88907242),"
Fairview Heights Elementary School
104 Hamilton Ave
Hamlet, NC 28345

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Fairview Heights Elementary School",'Hamlet=' + Hamlet.length); Hamlet[Hamlet.length] = createMarker(new GPoint(-79.72064209,34.89010620),"
Hamlet Junior High School
1406 Mcdonald Ave
Hamlet, NC 28345

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Hamlet Junior High School",'Hamlet=' + Hamlet.length); Hoffman[Hoffman.length] = createMarker(new GPoint(-79.56490326,35.02569962),"
Hoffman Elementary School
Po Box 187
Hoffman, NC 28347

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Hoffman Elementary School",'Hoffman=' + Hoffman.length); Rockingham[Rockingham.length] = createMarker(new GPoint(-79.76456451,34.94425583),"
L J Bell Elementary School
442 Hawthorne Ave
Rockingham, NC 28379

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("L J Bell Elementary School",'Rockingham=' + Rockingham.length); Rockingham[Rockingham.length] = createMarker(new GPoint(-79.76091766,34.93893433),"
Leak Street Middle School
1004 Leak St
Rockingham, NC 28379

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Leak Street Middle School",'Rockingham=' + Rockingham.length); Ellerbe[Ellerbe.length] = createMarker(new GPoint(-79.75315857,35.06108093),"
Mineral Springs Elementary School
1426 Green Lake Rd
Ellerbe, NC 28338

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Mineral Springs Elementary School",'Ellerbe=' + Ellerbe.length); Hamlet[Hamlet.length] = createMarker(new GPoint(-79.69784546,34.89609909),"
Monroe Avenue Elementary School
400 Monroe Ave
Hamlet, NC 28345

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Monroe Avenue Elementary School",'Hamlet=' + Hamlet.length); Hamlet[Hamlet.length] = createMarker(new GPoint(-79.67970276,34.91674042),"
Richmond Primary
804 County Home Road
Hamlet, NC 28345

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Richmond Primary",'Hamlet=' + Hamlet.length); Rockingham[Rockingham.length] = createMarker(new GPoint(-79.77400208,34.93889999),"
Richmond Senior High School
Po Box 1748
Rockingham, NC 28380

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Richmond Senior High School",'Rockingham=' + Rockingham.length); Rockingham[Rockingham.length] = createMarker(new GPoint(-79.74236298,34.98221970),"
Roberdel Children Center
124 Roberdel Sch Rd
Rockingham, NC 28379

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Roberdel Children Center",'Rockingham=' + Rockingham.length); Rockingham[Rockingham.length] = createMarker(new GPoint(-79.76317596,34.94335556),"
Rockingham Junior High School
415 Wall Street
Rockingham, NC 28379

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Rockingham Junior High School",'Rockingham=' + Rockingham.length); Rockingham[Rockingham.length] = createMarker(new GPoint(-79.76496124,34.91594696),"
Rohanen Junior High School
252 School Street
Rockingham, NC 28379

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Rohanen Junior High School",'Rockingham=' + Rockingham.length); Rockingham[Rockingham.length] = createMarker(new GPoint(-79.75642395,34.91222763),"
Rohanen Primary
102 Safie Sixth Street
Rockingham, NC 28379

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Rohanen Primary",'Rockingham=' + Rockingham.length); Rockingham[Rockingham.length] = createMarker(new GPoint(-79.72073364,34.94353867),"
Washington Street Middle School
566 E Washington St Ext
Rockingham, NC 28379

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Washington Street Middle School",'Rockingham=' + Rockingham.length); Rockingham[Rockingham.length] = createMarker(new GPoint(-79.78542328,34.94031143),"
West Rockingham Elementary School
271 W Us 74 Hwy
Rockingham, NC 28379

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("West Rockingham Elementary School",'Rockingham=' + Rockingham.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(Cordova); map.removeOverlays(Ellerbe); map.removeOverlays(Hamlet); map.removeOverlays(Hoffman); map.removeOverlays(Rockingham); 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(Rockingham);map.removeOverlays(Cordova); map.removeOverlays(Ellerbe); map.removeOverlays(Hamlet); map.removeOverlays(Hoffman); map.removeOverlays(Rockingham); map.addOverlays(Cordova); centerByArray(Cordova, false, false); cntMarker += Cordova.length; map.addOverlays(Ellerbe); centerByArray(Ellerbe, false, false); cntMarker += Ellerbe.length; map.addOverlays(Hamlet); centerByArray(Hamlet, false, false); cntMarker += Hamlet.length; map.addOverlays(Hoffman); centerByArray(Hoffman, false, false); cntMarker += Hoffman.length; map.addOverlays(Rockingham); centerByArray(Rockingham, false, false); cntMarker += Rockingham.length; centerByArray(Rockingham,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'); } }