function addMarkers() { mySelect = document.getElementById('selection'); Kinston = [];La_Grange = [];Lagrange = [];Pink_Hill = [];Grifton = [];Deep_Run = [];mySelect.options[mySelect.options.length] = new Option("Deep Run schools",'all=Deep_Run'); mySelect.options[mySelect.options.length] = new Option("Grifton schools",'all=Grifton'); mySelect.options[mySelect.options.length] = new Option("Kinston schools",'all=Kinston'); mySelect.options[mySelect.options.length] = new Option("La Grange schools",'all=La_Grange'); mySelect.options[mySelect.options.length] = new Option("Lagrange schools",'all=Lagrange'); mySelect.options[mySelect.options.length] = new Option("Pink Hill schools",'all=Pink_Hill'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Kinston[Kinston.length] = createMarker(new GPoint(-77.67826843,35.28058624),"
Banks Elementary School
2148 Falling Creek Rd
Kinston, NC 28504

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Banks Elementary School",'Kinston=' + Kinston.length); Kinston[Kinston.length] = createMarker(new GPoint(-77.55706787,35.25673676),"
C H Bynum Elementary School
100 Bynum Blvd
Kinston, NC 28501

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("C H Bynum Elementary School",'Kinston=' + Kinston.length); Kinston[Kinston.length] = createMarker(new GPoint(-77.55960083,35.26689911),"
Children's Village Academy
58po Box 2206
Kinston, NC 28501

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Children's Village Academy",'Kinston=' + Kinston.length); Kinston[Kinston.length] = createMarker(new GPoint(-77.51279449,35.31668854),"
Contentnea Elementary School
2909 Graingers Station Rd
Kinston, NC 28501

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Contentnea Elementary School",'Kinston=' + Kinston.length); La_Grange[La_Grange.length] = createMarker(new GPoint(-77.79399109,35.31409836),"
E B Frink Middle School
102 N Martin Luther King Jr Dr
La Grange, NC 28551

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("E B Frink Middle School",'La_Grange=' + La_Grange.length); Kinston[Kinston.length] = createMarker(new GPoint(-77.57237244,35.26348114),"
J H Sampson Elementary School
606 Tower Hill Road
Kinston, NC 28501

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("J H Sampson Elementary School",'Kinston=' + Kinston.length); Kinston[Kinston.length] = createMarker(new GPoint(-77.69253540,35.25484848),"
Kennedy Home
2557 Cedar Dell Lane
Kinston, NC 28504

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Kennedy Home",'Kinston=' + Kinston.length); Kinston[Kinston.length] = createMarker(new GPoint(-77.79270900,35.31373600),"
Kinston Charter Academy
2000 Martin L King, Jr Blvd
Kinston, NC 28501

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Kinston Charter Academy",'Kinston=' + Kinston.length); Kinston[Kinston.length] = createMarker(new GPoint(-77.57513428,35.29773331),"
Kinston High School
2601 N Queen St
Kinston, NC 28501

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Kinston High School",'Kinston=' + Kinston.length); Lagrange[Lagrange.length] = createMarker(new GPoint(-77.79515076,35.31011200),"
Lagrange Elementary School
402 W Railroad St
Lagrange, NC 28551

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Lagrange Elementary School",'Lagrange=' + Lagrange.length); Kinston[Kinston.length] = createMarker(new GPoint(-77.57759857,35.26518631),"
Lewis School
501 North Independence Street
Kinston, NC 28501

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Lewis School",'Kinston=' + Kinston.length); Kinston[Kinston.length] = createMarker(new GPoint(-77.63372200,35.26563600),"
Moss Hill Elementary School
6040 Hwy 55 West
Kinston, NC 28504

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Moss Hill Elementary School",'Kinston=' + Kinston.length); La_Grange[La_Grange.length] = createMarker(new GPoint(-77.67646790,35.34102249),"
North Lenoir High School
2400 Institute Road
La Grange, NC 28551

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("North Lenoir High School",'La_Grange=' + La_Grange.length); Kinston[Kinston.length] = createMarker(new GPoint(-77.60285950,35.27735519),"
Northwest Elementary School
1701 Old Well Rd
Kinston, NC 28501

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Northwest Elementary School",'Kinston=' + Kinston.length); Pink_Hill[Pink_Hill.length] = createMarker(new GPoint(-77.74504852,35.05393600),"
Pink Hill Elementary School
202 S Central Avenue
Pink Hill, NC 28572

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Pink Hill Elementary School",'Pink_Hill=' + Pink_Hill.length); Kinston[Kinston.length] = createMarker(new GPoint(-77.56268311,35.26268768),"
Rochelle Middle School
301 N Rochelle Blvd
Kinston, NC 28501

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Rochelle Middle School",'Kinston=' + Kinston.length); Grifton[Grifton.length] = createMarker(new GPoint(-77.54567719,35.35786438),"
Savannah Middle School
2583 Cameron Langston Road
Grifton, NC 28530

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Savannah Middle School",'Grifton=' + Grifton.length); Deep_Run[Deep_Run.length] = createMarker(new GPoint(-77.70520782,35.14490891),"
South Lenoir High School
3355 Old Hwy 11 South
Deep Run, NC 28525

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("South Lenoir High School",'Deep_Run=' + Deep_Run.length); Kinston[Kinston.length] = createMarker(new GPoint(-77.57036591,35.25835419),"
Southeast Elementary School
201 S Mcdaniel St
Kinston, NC 28501

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Southeast Elementary School",'Kinston=' + Kinston.length); Kinston[Kinston.length] = createMarker(new GPoint(-77.56562042,35.20750809),"
Southwood Elementary School
1245 Hwy 58 South
Kinston, NC 28504

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Southwood Elementary School",'Kinston=' + Kinston.length); Kinston[Kinston.length] = createMarker(new GPoint(-77.57636261,35.28675842),"
Teachers Memorial Elementary School
500 Marcella Dr
Kinston, NC 28501

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Teachers Memorial Elementary School",'Kinston=' + Kinston.length); Kinston[Kinston.length] = createMarker(new GPoint(-77.63484192,35.15864563),"
Woodington Middle School
4939 Hwy 258 South
Kinston, NC 28504

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Woodington Middle School",'Kinston=' + Kinston.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(Deep_Run); map.removeOverlays(Grifton); map.removeOverlays(Kinston); map.removeOverlays(La_Grange); map.removeOverlays(Lagrange); map.removeOverlays(Pink_Hill); 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(Kinston);map.removeOverlays(Deep_Run); map.removeOverlays(Grifton); map.removeOverlays(Kinston); map.removeOverlays(La_Grange); map.removeOverlays(Lagrange); map.removeOverlays(Pink_Hill); map.addOverlays(Deep_Run); centerByArray(Deep_Run, false, false); cntMarker += Deep_Run.length; map.addOverlays(Grifton); centerByArray(Grifton, false, false); cntMarker += Grifton.length; map.addOverlays(Kinston); centerByArray(Kinston, false, false); cntMarker += Kinston.length; map.addOverlays(La_Grange); centerByArray(La_Grange, false, false); cntMarker += La_Grange.length; map.addOverlays(Lagrange); centerByArray(Lagrange, false, false); cntMarker += Lagrange.length; map.addOverlays(Pink_Hill); centerByArray(Pink_Hill, false, false); cntMarker += Pink_Hill.length; centerByArray(Kinston,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'); } }