function addMarkers() { mySelect = document.getElementById('selection'); Butner = [];Oxford = [];Creedmoor = [];Stovall = [];Franklinton = [];mySelect.options[mySelect.options.length] = new Option("Butner schools",'all=Butner'); mySelect.options[mySelect.options.length] = new Option("Creedmoor schools",'all=Creedmoor'); mySelect.options[mySelect.options.length] = new Option("Franklinton schools",'all=Franklinton'); mySelect.options[mySelect.options.length] = new Option("Oxford schools",'all=Oxford'); mySelect.options[mySelect.options.length] = new Option("Stovall schools",'all=Stovall'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Butner[Butner.length] = createMarker(new GPoint(-78.75794220,36.13619232),"
Butner-stem Elementary School
201 East D Street
Butner, NC 27509

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Butner-stem Elementary School",'Butner=' + Butner.length); Butner[Butner.length] = createMarker(new GPoint(-78.75375366,36.13929749),"
Butner-stem Middle School
501 East D Street
Butner, NC 27509

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Butner-stem Middle School",'Butner=' + Butner.length); Oxford[Oxford.length] = createMarker(new GPoint(-78.59064484,36.31365585),"
C G Credle Elementary School
223 College Street
Oxford, NC 27565

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("C G Credle Elementary School",'Oxford=' + Oxford.length); Creedmoor[Creedmoor.length] = createMarker(new GPoint(-78.69190216,36.10620117),"
Creedmoor Elementary School
Po Box 725
Creedmoor, NC 27522

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Creedmoor Elementary School",'Creedmoor=' + Creedmoor.length); Creedmoor[Creedmoor.length] = createMarker(new GPoint(-78.67294312,36.10726547),"
G C Hawley Middle School
2173 Brassfield Road
Creedmoor, NC 27522

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("G C Hawley Middle School",'Creedmoor=' + Creedmoor.length); Oxford[Oxford.length] = createMarker(new GPoint(-78.59954071,36.33983612),"
J F Webb High School
3200 Webb School Road
Oxford, NC 27565

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("J F Webb High School",'Oxford=' + Oxford.length); Oxford[Oxford.length] = createMarker(new GPoint(-78.60101400,36.33979100),"
Jf Webb High School Of Health
3200 Webb Road
Oxford, NC 27565

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Jf Webb High School Of Health",'Oxford=' + Oxford.length); Oxford[Oxford.length] = createMarker(new GPoint(-78.73268127,36.46252060),"
Joe Toler-oak Hill Elementary School
8176 Hwy 96
Oxford, NC 27565

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Joe Toler-oak Hill Elementary School",'Oxford=' + Oxford.length); Oxford[Oxford.length] = createMarker(new GPoint(-78.58695984,36.31620789),"
Mary Potter Intermediate
200 Taylor Street
Oxford, NC 27565

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Mary Potter Intermediate",'Oxford=' + Oxford.length); Creedmoor[Creedmoor.length] = createMarker(new GPoint(-78.68696594,36.12168121),"
Mount Energy Elementary School
2652 Hwy 56
Creedmoor, NC 27522

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Mount Energy Elementary School",'Creedmoor=' + Creedmoor.length); Oxford[Oxford.length] = createMarker(new GPoint(-78.59617615,36.33904648),"
Northern Granville Middle School
3144 Webb School Road
Oxford, NC 27565

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Northern Granville Middle School",'Oxford=' + Oxford.length); Creedmoor[Creedmoor.length] = createMarker(new GPoint(-78.67339700,36.12449800),"
S Granville High Of Health Sci
701 N Crescent Drive
Creedmoor, NC 27522

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("S Granville High Of Health Sci",'Creedmoor=' + Creedmoor.length); Creedmoor[Creedmoor.length] = createMarker(new GPoint(-78.69190216,36.10620117),"
South Granville High School
Po Box 398
Creedmoor, NC 27522

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("South Granville High School",'Creedmoor=' + Creedmoor.length); Stovall[Stovall.length] = createMarker(new GPoint(-78.57050323,36.44800186),"
Stovall-shaw Elementary School
Po Box 39
Stovall, NC 27582

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Stovall-shaw Elementary School",'Stovall=' + Stovall.length); Oxford[Oxford.length] = createMarker(new GPoint(-78.61526489,36.32119751),"
West Oxford Elementary School
412 Ivey Day Road
Oxford, NC 27565

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("West Oxford Elementary School",'Oxford=' + Oxford.length); Franklinton[Franklinton.length] = createMarker(new GPoint(-78.45832062,36.10089874),"
Wilton Elementary School
2555 Hwy 96
Franklinton, NC 27525

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Wilton Elementary School",'Franklinton=' + Franklinton.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(Butner); map.removeOverlays(Creedmoor); map.removeOverlays(Franklinton); map.removeOverlays(Oxford); map.removeOverlays(Stovall); 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(Butner);map.removeOverlays(Butner); map.removeOverlays(Creedmoor); map.removeOverlays(Franklinton); map.removeOverlays(Oxford); map.removeOverlays(Stovall); map.addOverlays(Butner); centerByArray(Butner, false, false); cntMarker += Butner.length; map.addOverlays(Creedmoor); centerByArray(Creedmoor, false, false); cntMarker += Creedmoor.length; map.addOverlays(Franklinton); centerByArray(Franklinton, false, false); cntMarker += Franklinton.length; map.addOverlays(Oxford); centerByArray(Oxford, false, false); cntMarker += Oxford.length; map.addOverlays(Stovall); centerByArray(Stovall, false, false); cntMarker += Stovall.length; centerByArray(Butner,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'); } }