function addMarkers() { mySelect = document.getElementById('selection'); Louisburg = [];Bunn = [];Youngsville = [];Franklinton = [];mySelect.options[mySelect.options.length] = new Option("Bunn schools",'all=Bunn'); mySelect.options[mySelect.options.length] = new Option("Franklinton schools",'all=Franklinton'); mySelect.options[mySelect.options.length] = new Option("Louisburg schools",'all=Louisburg'); mySelect.options[mySelect.options.length] = new Option("Youngsville schools",'all=Youngsville'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Louisburg[Louisburg.length] = createMarker(new GPoint(-78.30118400,36.09864700),"
A Child's Garden School
Po Box 1075
Louisburg, NC 27549

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("A Child's Garden School",'Louisburg=' + Louisburg.length); Bunn[Bunn.length] = createMarker(new GPoint(-78.25530243,35.95399857),"
Bunn Elementary School
Po Box 143
Bunn, NC 27508

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Bunn Elementary School",'Bunn=' + Bunn.length); Bunn[Bunn.length] = createMarker(new GPoint(-78.25530243,35.95399857),"
Bunn High School
Po Box 146
Bunn, NC 27508

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Bunn High School",'Bunn=' + Bunn.length); Bunn[Bunn.length] = createMarker(new GPoint(-78.26187134,35.97560883),"
Bunn Middle School
4742 Nc 39 Hwy S
Bunn, NC 27508

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Bunn Middle School",'Bunn=' + Bunn.length); Youngsville[Youngsville.length] = createMarker(new GPoint(-78.44870758,36.04024506),"
Cedar Creek Middle School
2228 Cedar Creek Road
Youngsville, NC 27596

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Cedar Creek Middle School",'Youngsville=' + Youngsville.length); Louisburg[Louisburg.length] = createMarker(new GPoint(-78.16919708,36.09317398),"
Edward Best Elementary School
4011 Nc 56 Hwy East
Louisburg, NC 27549

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Edward Best Elementary School",'Louisburg=' + Louisburg.length); Franklinton[Franklinton.length] = createMarker(new GPoint(-78.46121979,36.09912872),"
Franklinton Elementary School
431 S Hillsborough St.
Franklinton, NC 27525

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Franklinton Elementary School",'Franklinton=' + Franklinton.length); Franklinton[Franklinton.length] = createMarker(new GPoint(-78.46009827,36.10800171),"
Franklinton High School
Po Box 520
Franklinton, NC 27525

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Franklinton High School",'Franklinton=' + Franklinton.length); Louisburg[Louisburg.length] = createMarker(new GPoint(-78.19081879,36.16941071),"
Laurel Mill Elementary School
730 Laurel Mill Road
Louisburg, NC 27549

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Laurel Mill Elementary School",'Louisburg=' + Louisburg.length); Louisburg[Louisburg.length] = createMarker(new GPoint(-78.30123138,36.07946396),"
Louisburg Elementary School
50 Stone Southerland Road
Louisburg, NC 27549

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Louisburg Elementary School",'Louisburg=' + Louisburg.length); Louisburg[Louisburg.length] = createMarker(new GPoint(-78.29960632,36.11107635),"
Louisburg High School
201 Allen Lane
Louisburg, NC 27549

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Louisburg High School",'Louisburg=' + Louisburg.length); Louisburg[Louisburg.length] = createMarker(new GPoint(-78.30657196,36.09562683),"
Riverside Elementary Magnet
53 West River Road
Louisburg, NC 27549

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Riverside Elementary Magnet",'Louisburg=' + Louisburg.length); Louisburg[Louisburg.length] = createMarker(new GPoint(-78.36594391,36.01995850),"
Royal Elementary School
308 Flat Rock Church Road
Louisburg, NC 27549

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Royal Elementary School",'Louisburg=' + Louisburg.length); Louisburg[Louisburg.length] = createMarker(new GPoint(-78.27536774,36.10166550),"
Terrell Lane Middle School
101 Terrell Lane
Louisburg, NC 27549

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Terrell Lane Middle School",'Louisburg=' + Louisburg.length); Youngsville[Youngsville.length] = createMarker(new GPoint(-78.44689941,36.00799942),"
Youngsville Elementary School
Po Box 338
Youngsville, NC 27596

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