function addMarkers() { mySelect = document.getElementById('selection'); Accomac = [];Oak_Hall = [];Onley = [];Painter = [];Chincoteague = [];Mappsville = [];Parksley = [];Onancock = [];Melfa = [];Tangier = [];mySelect.options[mySelect.options.length] = new Option("Accomac schools",'all=Accomac'); mySelect.options[mySelect.options.length] = new Option("Chincoteague schools",'all=Chincoteague'); mySelect.options[mySelect.options.length] = new Option("Mappsville schools",'all=Mappsville'); mySelect.options[mySelect.options.length] = new Option("Melfa schools",'all=Melfa'); mySelect.options[mySelect.options.length] = new Option("Oak Hall schools",'all=Oak_Hall'); mySelect.options[mySelect.options.length] = new Option("Onancock schools",'all=Onancock'); mySelect.options[mySelect.options.length] = new Option("Onley schools",'all=Onley'); mySelect.options[mySelect.options.length] = new Option("Painter schools",'all=Painter'); mySelect.options[mySelect.options.length] = new Option("Parksley schools",'all=Parksley'); mySelect.options[mySelect.options.length] = new Option("Tangier schools",'all=Tangier'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Accomac[Accomac.length] = createMarker(new GPoint(-75.66480255,37.68511963),"
Accawmacke Elementary School
P.o. Box 389
Accomac, VA 23301

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Accawmacke Elementary School",'Accomac=' + Accomac.length); Oak_Hall[Oak_Hall.length] = createMarker(new GPoint(-75.62180328,37.95299911),"
Arcadia High School
Po Box 69
Oak Hall, VA 23416

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Arcadia High School",'Oak_Hall=' + Oak_Hall.length); Oak_Hall[Oak_Hall.length] = createMarker(new GPoint(-75.57643200,37.94935400),"
Arcadia Middle School
P. O. Box 220
Oak Hall, VA 23416

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Arcadia Middle School",'Oak_Hall=' + Oak_Hall.length); Oak_Hall[Oak_Hall.length] = createMarker(new GPoint(-75.62180328,37.95299911),"
Badger Voc Ed Ctr - North
Po Box 69
Oak Hall, VA 23416

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Badger Voc Ed Ctr - North",'Oak_Hall=' + Oak_Hall.length); Onley[Onley.length] = createMarker(new GPoint(-75.72257233,37.68592834),"
Badger Voc Ed Ctr - South
P.o. Box 302
Onley, VA 23418

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Badger Voc Ed Ctr - South",'Onley=' + Onley.length); Painter[Painter.length] = createMarker(new GPoint(-75.81629944,37.59889984),"
Central Middle School
Po Box 10
Painter, VA 23420

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Central Middle School",'Painter=' + Painter.length); Chincoteague[Chincoteague.length] = createMarker(new GPoint(-75.35792542,37.93837357),"
Chincoteague Elementary School
6078 Hallie Whealton Smith Dr
Chincoteague, VA 23336

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Chincoteague Elementary School",'Chincoteague=' + Chincoteague.length); Chincoteague[Chincoteague.length] = createMarker(new GPoint(-75.36621857,37.94219589),"
Chincoteague High School
4586 Main St
Chincoteague, VA 23336

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Chincoteague High School",'Chincoteague=' + Chincoteague.length); Mappsville[Mappsville.length] = createMarker(new GPoint(-75.56780243,37.83860016),"
Kegotank Elementary. Elementary School
Po Box 28
Mappsville, VA 23407

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Kegotank Elementary. Elementary School",'Mappsville=' + Mappsville.length); Accomac[Accomac.length] = createMarker(new GPoint(-75.66609955,37.71350098),"
Mary N. Smith Middle School
Po Box 120
Accomac, VA 23301

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Mary N. Smith Middle School",'Accomac=' + Accomac.length); Parksley[Parksley.length] = createMarker(new GPoint(-75.64624023,37.77891922),"
Metompkin Elementary School
24501 Parksley Rd
Parksley, VA 23421

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Metompkin Elementary School",'Parksley=' + Parksley.length); Onley[Onley.length] = createMarker(new GPoint(-75.72257233,37.68592834),"
Nandua High School
26350 Lankford Highway
Onley, VA 23418

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Nandua High School",'Onley=' + Onley.length); Onley[Onley.length] = createMarker(new GPoint(-75.72458800,37.68133700),"
Nandua Middle School
20330 Warrior Dr.
Onley, VA 23418

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Nandua Middle School",'Onley=' + Onley.length); Onancock[Onancock.length] = createMarker(new GPoint(-75.74741364,37.70965958),"
Onancock Lrng Ctr - Ecse
6 College Ave
Onancock, VA 23421

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Onancock Lrng Ctr - Ecse",'Onancock=' + Onancock.length); Parksley[Parksley.length] = createMarker(new GPoint(-75.63809967,37.77769852),"
Parksley Middle School
Po Box 85
Parksley, VA 23421

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Parksley Middle School",'Parksley=' + Parksley.length); Melfa[Melfa.length] = createMarker(new GPoint(-75.79143524,37.65259933),"
Pungoteague Elementary School
28480 Bobtown Rd
Melfa, VA 23410

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Pungoteague Elementary School",'Melfa=' + Melfa.length); Tangier[Tangier.length] = createMarker(new GPoint(-75.99210358,37.82559967),"
Tangier Comb.
Po Box 245
Tangier, VA 23440

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Tangier Comb.",'Tangier=' + Tangier.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(Accomac); map.removeOverlays(Chincoteague); map.removeOverlays(Mappsville); map.removeOverlays(Melfa); map.removeOverlays(Oak_Hall); map.removeOverlays(Onancock); map.removeOverlays(Onley); map.removeOverlays(Painter); map.removeOverlays(Parksley); map.removeOverlays(Tangier); 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(Accomac);map.removeOverlays(Accomac); map.removeOverlays(Chincoteague); map.removeOverlays(Mappsville); map.removeOverlays(Melfa); map.removeOverlays(Oak_Hall); map.removeOverlays(Onancock); map.removeOverlays(Onley); map.removeOverlays(Painter); map.removeOverlays(Parksley); map.removeOverlays(Tangier); map.addOverlays(Accomac); centerByArray(Accomac, false, false); cntMarker += Accomac.length; map.addOverlays(Chincoteague); centerByArray(Chincoteague, false, false); cntMarker += Chincoteague.length; map.addOverlays(Mappsville); centerByArray(Mappsville, false, false); cntMarker += Mappsville.length; map.addOverlays(Melfa); centerByArray(Melfa, false, false); cntMarker += Melfa.length; map.addOverlays(Oak_Hall); centerByArray(Oak_Hall, false, false); cntMarker += Oak_Hall.length; map.addOverlays(Onancock); centerByArray(Onancock, false, false); cntMarker += Onancock.length; map.addOverlays(Onley); centerByArray(Onley, false, false); cntMarker += Onley.length; map.addOverlays(Painter); centerByArray(Painter, false, false); cntMarker += Painter.length; map.addOverlays(Parksley); centerByArray(Parksley, false, false); cntMarker += Parksley.length; map.addOverlays(Tangier); centerByArray(Tangier, false, false); cntMarker += Tangier.length; centerByArray(Accomac,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'); } }