function addMarkers() { mySelect = document.getElementById('selection'); Bailey = [];Rocky_Mount = [];Nashville = [];Elm_City = [];Battleboro = [];Middlesex = [];Red_Oak = [];Spring_Hope = [];Whitakers = [];mySelect.options[mySelect.options.length] = new Option("Bailey schools",'all=Bailey'); mySelect.options[mySelect.options.length] = new Option("Battleboro schools",'all=Battleboro'); mySelect.options[mySelect.options.length] = new Option("Elm City schools",'all=Elm_City'); mySelect.options[mySelect.options.length] = new Option("Middlesex schools",'all=Middlesex'); mySelect.options[mySelect.options.length] = new Option("Nashville schools",'all=Nashville'); mySelect.options[mySelect.options.length] = new Option("Red Oak schools",'all=Red_Oak'); mySelect.options[mySelect.options.length] = new Option("Rocky Mount schools",'all=Rocky_Mount'); mySelect.options[mySelect.options.length] = new Option("Spring Hope schools",'all=Spring_Hope'); mySelect.options[mySelect.options.length] = new Option("Whitakers schools",'all=Whitakers'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Bailey[Bailey.length] = createMarker(new GPoint(-78.09300232,35.80120087),"
",iconRd); mySelect.options[mySelect.options.length] = new Option("Bailey Elementary School",'Bailey=' + Bailey.length); Rocky_Mount[Rocky_Mount.length] = createMarker(new GPoint(-77.83895874,35.97542572),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Benvenue Elementary School",'Rocky_Mount=' + Rocky_Mount.length); Nashville[Nashville.length] = createMarker(new GPoint(-77.97000122,36.07771683),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Cedar Grove Elementary School",'Nashville=' + Nashville.length); Elm_City[Elm_City.length] = createMarker(new GPoint(-77.86338806,35.80643082),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Coopers Elementary School",'Elm_City=' + Elm_City.length); Rocky_Mount[Rocky_Mount.length] = createMarker(new GPoint(-77.83997345,35.96590805),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Englewood Elementary School",'Rocky_Mount=' + Rocky_Mount.length); Rocky_Mount[Rocky_Mount.length] = createMarker(new GPoint(-77.82189941,35.93626785),"",iconBl); mySelect.options[mySelect.options.length] = new Option("G R Edwards Middle School",'Rocky_Mount=' + Rocky_Mount.length); Rocky_Mount[Rocky_Mount.length] = createMarker(new GPoint(-77.80079651,35.94200134),"",iconRd); mySelect.options[mySelect.options.length] = new Option("James C Braswell Elementary School",'Rocky_Mount=' + Rocky_Mount.length); Battleboro[Battleboro.length] = createMarker(new GPoint(-77.82128906,36.03876114),"",iconRd); mySelect.options[mySelect.options.length] = new Option("M B Hubbard Elementary School",'Battleboro=' + Battleboro.length); Middlesex[Middlesex.length] = createMarker(new GPoint(-78.20809937,35.78229904),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Middlesex Elementary School",'Middlesex=' + Middlesex.length); Rocky_Mount[Rocky_Mount.length] = createMarker(new GPoint(-77.83380127,35.97639847),"",iconGr); mySelect.options[mySelect.options.length] = new Option("N-rms Middle College High School",'Rocky_Mount=' + Rocky_Mount.length); Rocky_Mount[Rocky_Mount.length] = createMarker(new GPoint(-77.90165710,35.95737457),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Nash Central High School",'Rocky_Mount=' + Rocky_Mount.length); Nashville[Nashville.length] = createMarker(new GPoint(-77.95541382,35.95729828),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Nash Central Middle School",'Nashville=' + Nashville.length); Nashville[Nashville.length] = createMarker(new GPoint(-77.96453857,35.97102737),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Nashville Elementary School",'Nashville=' + Nashville.length); Rocky_Mount[Rocky_Mount.length] = createMarker(new GPoint(-77.89225006,35.99616623),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Northern Nash High School",'Rocky_Mount=' + Rocky_Mount.length); Red_Oak[Red_Oak.length] = createMarker(new GPoint(-77.90470123,36.03820038),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Red Oak Elementary School",'Red_Oak=' + Red_Oak.length); Battleboro[Battleboro.length] = createMarker(new GPoint(-77.90186310,36.03601456),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Red Oak Middle School",'Battleboro=' + Battleboro.length); Rocky_Mount[Rocky_Mount.length] = createMarker(new GPoint(-77.80654907,35.94227982),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Rocky Mount High School",'Rocky_Mount=' + Rocky_Mount.length); Battleboro[Battleboro.length] = createMarker(new GPoint(-77.77330017,36.03820038),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Rocky Mount Preparatory",'Battleboro=' + Battleboro.length); Bailey[Bailey.length] = createMarker(new GPoint(-78.08621216,35.85150909),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Southern Nash High School",'Bailey=' + Bailey.length); Spring_Hope[Spring_Hope.length] = createMarker(new GPoint(-78.15435791,36.02495575),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Southern Nash Middle School",'Spring_Hope=' + Spring_Hope.length); Spring_Hope[Spring_Hope.length] = createMarker(new GPoint(-78.12400055,35.94179916),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Spring Hope Elementary School",'Spring_Hope=' + Spring_Hope.length); Whitakers[Whitakers.length] = createMarker(new GPoint(-77.89853668,36.10495377),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Swift Creek Elementary Magnet",'Whitakers=' + Whitakers.length); Nashville[Nashville.length] = createMarker(new GPoint(-77.96466827,35.96512222),"",iconGr); mySelect.options[mySelect.options.length] = new Option("W L Greene Alternative",'Nashville=' + Nashville.length); Rocky_Mount[Rocky_Mount.length] = createMarker(new GPoint(-77.81656647,35.92767334),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Williford Elementary School",'Rocky_Mount=' + Rocky_Mount.length); Rocky_Mount[Rocky_Mount.length] = createMarker(new GPoint(-77.84889984,35.95882034),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Winstead Avenue Elementary School",'Rocky_Mount=' + Rocky_Mount.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(Bailey); map.removeOverlays(Battleboro); map.removeOverlays(Elm_City); map.removeOverlays(Middlesex); map.removeOverlays(Nashville); map.removeOverlays(Red_Oak); map.removeOverlays(Rocky_Mount); map.removeOverlays(Spring_Hope); map.removeOverlays(Whitakers); 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(Bailey);map.removeOverlays(Bailey); map.removeOverlays(Battleboro); map.removeOverlays(Elm_City); map.removeOverlays(Middlesex); map.removeOverlays(Nashville); map.removeOverlays(Red_Oak); map.removeOverlays(Rocky_Mount); map.removeOverlays(Spring_Hope); map.removeOverlays(Whitakers); map.addOverlays(Bailey); centerByArray(Bailey, false, false); cntMarker += Bailey.length; map.addOverlays(Battleboro); centerByArray(Battleboro, false, false); cntMarker += Battleboro.length; map.addOverlays(Elm_City); centerByArray(Elm_City, false, false); cntMarker += Elm_City.length; map.addOverlays(Middlesex); centerByArray(Middlesex, false, false); cntMarker += Middlesex.length; map.addOverlays(Nashville); centerByArray(Nashville, false, false); cntMarker += Nashville.length; map.addOverlays(Red_Oak); centerByArray(Red_Oak, false, false); cntMarker += Red_Oak.length; map.addOverlays(Rocky_Mount); centerByArray(Rocky_Mount, false, false); cntMarker += Rocky_Mount.length; map.addOverlays(Spring_Hope); centerByArray(Spring_Hope, false, false); cntMarker += Spring_Hope.length; map.addOverlays(Whitakers); centerByArray(Whitakers, false, false); cntMarker += Whitakers.length; centerByArray(Bailey,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'); } }