function addMarkers() { mySelect = document.getElementById('selection'); Independence = [];Elk_Creek = [];Galax = [];Troutdale = [];Fries = [];Whitetop = [];mySelect.options[mySelect.options.length] = new Option("Elk Creek schools",'all=Elk_Creek'); mySelect.options[mySelect.options.length] = new Option("Fries schools",'all=Fries'); mySelect.options[mySelect.options.length] = new Option("Galax schools",'all=Galax'); mySelect.options[mySelect.options.length] = new Option("Independence schools",'all=Independence'); mySelect.options[mySelect.options.length] = new Option("Troutdale schools",'all=Troutdale'); mySelect.options[mySelect.options.length] = new Option("Whitetop schools",'all=Whitetop'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Independence[Independence.length] = createMarker(new GPoint(-81.15085400,36.62241300),"
Bridle Creek Elementary School
77 Bridle Creek Rd
Independence, VA 24348

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Bridle Creek Elementary School",'Independence=' + Independence.length); Elk_Creek[Elk_Creek.length] = createMarker(new GPoint(-81.17781067,36.72100067),"
Elk Creek Elementary School
57 School Ln
Elk Creek, VA 24326

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Elk Creek Elementary School",'Elk_Creek=' + Elk_Creek.length); Galax[Galax.length] = createMarker(new GPoint(-80.91184998,36.58524323),"
Fairview Elementary School
2323 Fairview Rd
Galax, VA 24333

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Fairview Elementary School",'Galax=' + Galax.length); Troutdale[Troutdale.length] = createMarker(new GPoint(-81.34559631,36.69767761),"
Flatridge Elementary School
8496 Flat Ridge Rd
Troutdale, VA 24378

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Flatridge Elementary School",'Troutdale=' + Troutdale.length); Fries[Fries.length] = createMarker(new GPoint(-81.00959778,36.72069931),"
Fries Middle School
Po Box 446
Fries, VA 24330

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Fries Middle School",'Fries=' + Fries.length); Independence[Independence.length] = createMarker(new GPoint(-81.15869904,36.62260056),"
Grayson Co High Career & Tech Ed
Po Box 707
Independence, VA 24348

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Grayson Co High Career & Tech Ed",'Independence=' + Independence.length); Independence[Independence.length] = createMarker(new GPoint(-81.15869904,36.62260056),"
Grayson County High School
Po Box 828
Independence, VA 24348

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Grayson County High School",'Independence=' + Independence.length); Independence[Independence.length] = createMarker(new GPoint(-81.15869904,36.62260056),"
Independence Elementary School
Po Box 429
Independence, VA 24348

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Independence Elementary School",'Independence=' + Independence.length); Independence[Independence.length] = createMarker(new GPoint(-81.15869904,36.62260056),"
Independence Middle School
Po Box 155
Independence, VA 24348

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Independence Middle School",'Independence=' + Independence.length); Whitetop[Whitetop.length] = createMarker(new GPoint(-81.53457642,36.59676743),"
Mt. Rogers Comb.
11337 Highlands Pkwy
Whitetop, VA 24292

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Mt. Rogers Comb.",'Whitetop=' + Whitetop.length); Fries[Fries.length] = createMarker(new GPoint(-81.03892517,36.71101761),"
Providence Elementary School
56 Bainbridge Rd
Fries, VA 24330

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Providence Elementary School",'Fries=' + Fries.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(Elk_Creek); map.removeOverlays(Fries); map.removeOverlays(Galax); map.removeOverlays(Independence); map.removeOverlays(Troutdale); map.removeOverlays(Whitetop); 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(Independence);map.removeOverlays(Elk_Creek); map.removeOverlays(Fries); map.removeOverlays(Galax); map.removeOverlays(Independence); map.removeOverlays(Troutdale); map.removeOverlays(Whitetop); map.addOverlays(Elk_Creek); centerByArray(Elk_Creek, false, false); cntMarker += Elk_Creek.length; map.addOverlays(Fries); centerByArray(Fries, false, false); cntMarker += Fries.length; map.addOverlays(Galax); centerByArray(Galax, false, false); cntMarker += Galax.length; map.addOverlays(Independence); centerByArray(Independence, false, false); cntMarker += Independence.length; map.addOverlays(Troutdale); centerByArray(Troutdale, false, false); cntMarker += Troutdale.length; map.addOverlays(Whitetop); centerByArray(Whitetop, false, false); cntMarker += Whitetop.length; centerByArray(Independence,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'); } }