function addMarkers() { mySelect = document.getElementById('selection'); Atlantic = [];Beaufort = [];Newport = [];Morehead_City = [];Harkers_Island = [];Smyrna = [];Cape_Carteret = [];mySelect.options[mySelect.options.length] = new Option("Atlantic schools",'all=Atlantic'); mySelect.options[mySelect.options.length] = new Option("Beaufort schools",'all=Beaufort'); mySelect.options[mySelect.options.length] = new Option("Cape Carteret schools",'all=Cape_Carteret'); mySelect.options[mySelect.options.length] = new Option("Harkers Island schools",'all=Harkers_Island'); mySelect.options[mySelect.options.length] = new Option("Morehead City schools",'all=Morehead_City'); mySelect.options[mySelect.options.length] = new Option("Newport schools",'all=Newport'); mySelect.options[mySelect.options.length] = new Option("Smyrna schools",'all=Smyrna'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Atlantic[Atlantic.length] = createMarker(new GPoint(-76.34780121,34.88550186),"
Atlantic Elementary School
Po Box 98
Atlantic, NC 28511

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Atlantic Elementary School",'Atlantic=' + Atlantic.length); Beaufort[Beaufort.length] = createMarker(new GPoint(-76.65620422,34.72035217),"
Beaufort Elementary School
110 Carraway Drive
Beaufort, NC 28516

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Beaufort Elementary School",'Beaufort=' + Beaufort.length); Beaufort[Beaufort.length] = createMarker(new GPoint(-76.64302826,34.72994232),"
Beaufort Middle School
100 Carraway Drive
Beaufort, NC 28516

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Beaufort Middle School",'Beaufort=' + Beaufort.length); Newport[Newport.length] = createMarker(new GPoint(-76.88320160,34.76190186),"
Bogue Sound Elementary School
3323 Highway 24
Newport, NC 28570

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Bogue Sound Elementary School",'Newport=' + Newport.length); Newport[Newport.length] = createMarker(new GPoint(-76.88320160,34.76190186),"
Broad Creek Middle School
2382 Hwy 24
Newport, NC 28570

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Broad Creek Middle School",'Newport=' + Newport.length); Morehead_City[Morehead_City.length] = createMarker(new GPoint(-76.71684265,34.72239304),"
Cape Lookout Marine Sci High School
1108 Bridges Street
Morehead City, NC 28557

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Cape Lookout Marine Sci High School",'Morehead_City=' + Morehead_City.length); Newport[Newport.length] = createMarker(new GPoint(-76.88320160,34.76190186),"
Croatan High School
1 Cougar Lane
Newport, NC 28570

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Croatan High School",'Newport=' + Newport.length); Beaufort[Beaufort.length] = createMarker(new GPoint(-76.61250305,34.79249954),"
East Carteret High School
3263 Hwy 70 E
Beaufort, NC 28516

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("East Carteret High School",'Beaufort=' + Beaufort.length); Harkers_Island[Harkers_Island.length] = createMarker(new GPoint(-76.55723572,34.69416046),"
Harkers Island Elementary School
1163 Island Road
Harkers Island, NC 28531

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Harkers Island Elementary School",'Harkers_Island=' + Harkers_Island.length); Morehead_City[Morehead_City.length] = createMarker(new GPoint(-76.74256897,34.72885895),"
Morehead City Middle School
400 Barbour Road
Morehead City, NC 28557

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Morehead City Middle School",'Morehead_City=' + Morehead_City.length); Morehead_City[Morehead_City.length] = createMarker(new GPoint(-76.77696228,34.73534775),"
Morehead City Primary
4409 Country Club Road
Morehead City, NC 28557

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Morehead City Primary",'Morehead_City=' + Morehead_City.length); Morehead_City[Morehead_City.length] = createMarker(new GPoint(-76.75006104,34.72398376),"
Morehead Elementary At Camp Glenn
3316 Arendell Street
Morehead City, NC 28557

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Morehead Elementary At Camp Glenn",'Morehead_City=' + Morehead_City.length); Newport[Newport.length] = createMarker(new GPoint(-76.86038971,34.77669144),"
Newport Elementary School
219 Chatham Street
Newport, NC 28570

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Newport Elementary School",'Newport=' + Newport.length); Newport[Newport.length] = createMarker(new GPoint(-76.85884857,34.77110672),"
Newport Middle School
500 E Chatham Street
Newport, NC 28570

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Newport Middle School",'Newport=' + Newport.length); Smyrna[Smyrna.length] = createMarker(new GPoint(-76.51490021,34.76440048),"
Smyrna Elementary School
174 Marshallberg Road
Smyrna, NC 28579

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Smyrna Elementary School",'Smyrna=' + Smyrna.length); Beaufort[Beaufort.length] = createMarker(new GPoint(-76.61250305,34.79249954),"
Tiller School
1950 Hwy 70e
Beaufort, NC 28516

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Tiller School",'Beaufort=' + Beaufort.length); Morehead_City[Morehead_City.length] = createMarker(new GPoint(-76.77706146,34.73535156),"
West Carteret High School
4700 Country Club Road
Morehead City, NC 28557

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("West Carteret High School",'Morehead_City=' + Morehead_City.length); Cape_Carteret[Cape_Carteret.length] = createMarker(new GPoint(-77.09860229,34.70420074),"
White Oak Elementary School
555 Wb Mclean Drive
Cape Carteret, NC 28584

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("White Oak Elementary School",'Cape_Carteret=' + Cape_Carteret.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(Atlantic); map.removeOverlays(Beaufort); map.removeOverlays(Cape_Carteret); map.removeOverlays(Harkers_Island); map.removeOverlays(Morehead_City); map.removeOverlays(Newport); map.removeOverlays(Smyrna); 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(Atlantic);map.removeOverlays(Atlantic); map.removeOverlays(Beaufort); map.removeOverlays(Cape_Carteret); map.removeOverlays(Harkers_Island); map.removeOverlays(Morehead_City); map.removeOverlays(Newport); map.removeOverlays(Smyrna); map.addOverlays(Atlantic); centerByArray(Atlantic, false, false); cntMarker += Atlantic.length; map.addOverlays(Beaufort); centerByArray(Beaufort, false, false); cntMarker += Beaufort.length; map.addOverlays(Cape_Carteret); centerByArray(Cape_Carteret, false, false); cntMarker += Cape_Carteret.length; map.addOverlays(Harkers_Island); centerByArray(Harkers_Island, false, false); cntMarker += Harkers_Island.length; map.addOverlays(Morehead_City); centerByArray(Morehead_City, false, false); cntMarker += Morehead_City.length; map.addOverlays(Newport); centerByArray(Newport, false, false); cntMarker += Newport.length; map.addOverlays(Smyrna); centerByArray(Smyrna, false, false); cntMarker += Smyrna.length; centerByArray(Atlantic,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'); } }