function addMarkers() { mySelect = document.getElementById('selection'); Laurel_Hill = [];Laurinburg = [];Gibson = [];Wagram = [];mySelect.options[mySelect.options.length] = new Option("Gibson schools",'all=Gibson'); mySelect.options[mySelect.options.length] = new Option("Laurel Hill schools",'all=Laurel_Hill'); mySelect.options[mySelect.options.length] = new Option("Laurinburg schools",'all=Laurinburg'); mySelect.options[mySelect.options.length] = new Option("Wagram schools",'all=Wagram'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Laurel_Hill[Laurel_Hill.length] = createMarker(new GPoint(-79.51406097,34.80334854),"
Carver Middle School
18601 Fieldcrest Road
Laurel Hill, NC 28351

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Carver Middle School",'Laurel_Hill=' + Laurel_Hill.length); Laurinburg[Laurinburg.length] = createMarker(new GPoint(-79.46992493,34.77322388),"
Covington Street Elementary School
615 W Covington St
Laurinburg, NC 28352

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Covington Street Elementary School",'Laurinburg=' + Laurinburg.length); Laurinburg[Laurinburg.length] = createMarker(new GPoint(-79.46280670,34.77413940),"
East Laurinburg
Hwy 74 E
Laurinburg, NC 28352

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("East Laurinburg",'Laurinburg=' + Laurinburg.length); Laurinburg[Laurinburg.length] = createMarker(new GPoint(-79.44604492,34.78253174),"
I E Johnson Elementary School
815 Mcgirts Bridge Road
Laurinburg, NC 28352

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("I E Johnson Elementary School",'Laurinburg=' + Laurinburg.length); Laurel_Hill[Laurel_Hill.length] = createMarker(new GPoint(-79.52189636,34.82273865),"
Laurel Hill Elementary School
11340 Old Wire Road
Laurel Hill, NC 28351

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Laurel Hill Elementary School",'Laurel_Hill=' + Laurel_Hill.length); Laurinburg[Laurinburg.length] = createMarker(new GPoint(-79.46299744,34.77379990),"
Laurinburg Charter
Po Box 1575
Laurinburg, NC 28353

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Laurinburg Charter",'Laurinburg=' + Laurinburg.length); Laurinburg[Laurinburg.length] = createMarker(new GPoint(-79.46299744,34.77379990),"
Laurinburg Homework Center
Po Box 929
Laurinburg, NC 28353

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Laurinburg Homework Center",'Laurinburg=' + Laurinburg.length); Laurinburg[Laurinburg.length] = createMarker(new GPoint(-79.45642853,34.78754044),"
North Laurinburg Elementary School
831 N Gill St
Laurinburg, NC 28352

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("North Laurinburg Elementary School",'Laurinburg=' + Laurinburg.length); Gibson[Gibson.length] = createMarker(new GPoint(-79.58609772,34.76139832),"
Pate Gardner Elementary School
14241 Oil Mill Rd
Gibson, NC 28343

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Pate Gardner Elementary School",'Gibson=' + Gibson.length); Laurel_Hill[Laurel_Hill.length] = createMarker(new GPoint(-79.55528259,34.81174088),"
Scotland Accelerated Elementary School
9801 Malloy Avenue
Laurel Hill, NC 28351

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Scotland Accelerated Elementary School",'Laurel_Hill=' + Laurel_Hill.length); Laurinburg[Laurinburg.length] = createMarker(new GPoint(-79.46336800,34.77434200),"
Scotland High Of Engineering &
1000 W Church St
Laurinburg, NC 28352

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Scotland High Of Engineering &",'Laurinburg=' + Laurinburg.length); Laurinburg[Laurinburg.length] = createMarker(new GPoint(-79.46336800,34.77434200),"
Scotland High School
1000 W Church St
Laurinburg, NC 28352

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Scotland High School",'Laurinburg=' + Laurinburg.length); Laurinburg[Laurinburg.length] = createMarker(new GPoint(-79.41661072,34.85966110),"
Shaw Elementary School
18700 Old Wire Road
Laurinburg, NC 28352

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Shaw Elementary School",'Laurinburg=' + Laurinburg.length); Laurinburg[Laurinburg.length] = createMarker(new GPoint(-79.42849731,34.73891830),"
South Scotland Elementary School
17200 Barnes Bridge Rd
Laurinburg, NC 28352

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("South Scotland Elementary School",'Laurinburg=' + Laurinburg.length); Laurinburg[Laurinburg.length] = createMarker(new GPoint(-79.38426971,34.87799454),"
Spring Hill Middle School
22801 Airbase Road
Laurinburg, NC 28352

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Spring Hill Middle School",'Laurinburg=' + Laurinburg.length); Laurinburg[Laurinburg.length] = createMarker(new GPoint(-79.49106598,34.74108505),"
Sycamore Lane Middle School
2100 Sycamore Ln
Laurinburg, NC 28352

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Sycamore Lane Middle School",'Laurinburg=' + Laurinburg.length); Wagram[Wagram.length] = createMarker(new GPoint(-79.36473846,34.88917923),"
Wagram Primary
24081 Main Street
Wagram, NC 28396

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Wagram Primary",'Wagram=' + Wagram.length); Laurinburg[Laurinburg.length] = createMarker(new GPoint(-79.45921326,34.76031494),"
Washington Park Elementary School
1225 S Caledonia Rd
Laurinburg, NC 28352

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Washington Park Elementary School",'Laurinburg=' + Laurinburg.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(Gibson); map.removeOverlays(Laurel_Hill); map.removeOverlays(Laurinburg); map.removeOverlays(Wagram); 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(Laurel_Hill);map.removeOverlays(Gibson); map.removeOverlays(Laurel_Hill); map.removeOverlays(Laurinburg); map.removeOverlays(Wagram); map.addOverlays(Gibson); centerByArray(Gibson, false, false); cntMarker += Gibson.length; map.addOverlays(Laurel_Hill); centerByArray(Laurel_Hill, false, false); cntMarker += Laurel_Hill.length; map.addOverlays(Laurinburg); centerByArray(Laurinburg, false, false); cntMarker += Laurinburg.length; map.addOverlays(Wagram); centerByArray(Wagram, false, false); cntMarker += Wagram.length; centerByArray(Laurel_Hill,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'); } }