function addMarkers() { mySelect = document.getElementById('selection'); Leland = [];Bolivia = [];Southport = [];Ash = [];Shallotte = [];Supply = [];mySelect.options[mySelect.options.length] = new Option("Ash schools",'all=Ash'); mySelect.options[mySelect.options.length] = new Option("Bolivia schools",'all=Bolivia'); mySelect.options[mySelect.options.length] = new Option("Leland schools",'all=Leland'); mySelect.options[mySelect.options.length] = new Option("Shallotte schools",'all=Shallotte'); mySelect.options[mySelect.options.length] = new Option("Southport schools",'all=Southport'); mySelect.options[mySelect.options.length] = new Option("Supply schools",'all=Supply'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Leland[Leland.length] = createMarker(new GPoint(-77.98835754,34.22850037),"
Belville Elementary School
575 River Road
Leland, NC 28451

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Belville Elementary School",'Leland=' + Leland.length); Bolivia[Bolivia.length] = createMarker(new GPoint(-78.19080353,34.00080109),"
Bolivia Elementary School
4036 Business 17 E
Bolivia, NC 28422

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Bolivia Elementary School",'Bolivia=' + Bolivia.length); Southport[Southport.length] = createMarker(new GPoint(-78.02248383,33.92465973),"
Brunswick Learning Center
705 North Lord Street
Southport, NC 28461

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Brunswick Learning Center",'Southport=' + Southport.length); Leland[Leland.length] = createMarker(new GPoint(-83.61069400,41.59425100),"
Charter Day School
7055 Bacon''s Way
Leland, NC 28451

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Charter Day School",'Leland=' + Leland.length); Ash[Ash.length] = createMarker(new GPoint(-78.54991913,33.94730759),"
Jessie Mae Monroe Elementary School
250 Pea Landing Road Nw
Ash, NC 28420

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Jessie Mae Monroe Elementary School",'Ash=' + Ash.length); Leland[Leland.length] = createMarker(new GPoint(-78.05318451,34.24242401),"
Leland Middle School
927 Old Fayetteville Road Ne
Leland, NC 28451

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Leland Middle School",'Leland=' + Leland.length); Leland[Leland.length] = createMarker(new GPoint(-78.04388428,34.26047134),"
Lincoln Primary
1664 Lincoln Road
Leland, NC 28451

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Lincoln Primary",'Leland=' + Leland.length); Leland[Leland.length] = createMarker(new GPoint(-78.06620026,34.24119949),"
North Brunswick High School
Po Box 2080
Leland, NC 28451

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("North Brunswick High School",'Leland=' + Leland.length); Shallotte[Shallotte.length] = createMarker(new GPoint(-78.38979340,33.96707535),"
Shallotte Middle School
225 Village Road
Shallotte, NC 28459

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Shallotte Middle School",'Shallotte=' + Shallotte.length); Southport[Southport.length] = createMarker(new GPoint(-78.04489899,33.96609879),"
South Brunswick High School
280 Cougar Drive Bsl
Southport, NC 28461

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("South Brunswick High School",'Southport=' + Southport.length); Southport[Southport.length] = createMarker(new GPoint(-78.04489899,33.96609879),"
South Brunswick Middle School
100 Cougar Drive Bsl
Southport, NC 28461

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("South Brunswick Middle School",'Southport=' + Southport.length); Southport[Southport.length] = createMarker(new GPoint(-78.02751923,33.92691803),"
Southport Elementary School
701 West 9th Street
Southport, NC 28461

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Southport Elementary School",'Southport=' + Southport.length); Supply[Supply.length] = createMarker(new GPoint(-78.25903400,34.02631000),"
Supply Elementary School
51 Benton Road Se
Supply, NC 28462

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Supply Elementary School",'Supply=' + Supply.length); Shallotte[Shallotte.length] = createMarker(new GPoint(-78.46023560,33.95757675),"
Union Elementary School
180 Union School Road Nw
Shallotte, NC 28459

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Union Elementary School",'Shallotte=' + Shallotte.length); Bolivia[Bolivia.length] = createMarker(new GPoint(-78.22916412,33.96931839),"
Virginia Williamson Elementary School
1020 Zion Hill Road
Bolivia, NC 28422

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Virginia Williamson Elementary School",'Bolivia=' + Bolivia.length); Ash[Ash.length] = createMarker(new GPoint(-78.51692963,34.06450653),"
Waccamaw Elementary School
5901 Waccamaw School Road Nw
Ash, NC 28420

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Waccamaw Elementary School",'Ash=' + Ash.length); Shallotte[Shallotte.length] = createMarker(new GPoint(-78.40682220,33.97725296),"
West Brunswick High School
550 Whiteville Road Nw
Shallotte, NC 28470

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("West Brunswick High School",'Shallotte=' + Shallotte.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(Ash); map.removeOverlays(Bolivia); map.removeOverlays(Leland); map.removeOverlays(Shallotte); map.removeOverlays(Southport); map.removeOverlays(Supply); 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(Leland);map.removeOverlays(Ash); map.removeOverlays(Bolivia); map.removeOverlays(Leland); map.removeOverlays(Shallotte); map.removeOverlays(Southport); map.removeOverlays(Supply); map.addOverlays(Ash); centerByArray(Ash, false, false); cntMarker += Ash.length; map.addOverlays(Bolivia); centerByArray(Bolivia, false, false); cntMarker += Bolivia.length; map.addOverlays(Leland); centerByArray(Leland, false, false); cntMarker += Leland.length; map.addOverlays(Shallotte); centerByArray(Shallotte, false, false); cntMarker += Shallotte.length; map.addOverlays(Southport); centerByArray(Southport, false, false); cntMarker += Southport.length; map.addOverlays(Supply); centerByArray(Supply, false, false); cntMarker += Supply.length; centerByArray(Leland,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'); } }