function addMarkers() { mySelect = document.getElementById('selection'); Winterville = [];Ayden = [];Greenville = [];Bethel = [];Farmville = [];Grimesland = [];Grifton = [];Stokes = [];mySelect.options[mySelect.options.length] = new Option("Ayden schools",'all=Ayden'); mySelect.options[mySelect.options.length] = new Option("Bethel schools",'all=Bethel'); mySelect.options[mySelect.options.length] = new Option("Farmville schools",'all=Farmville'); mySelect.options[mySelect.options.length] = new Option("Greenville schools",'all=Greenville'); mySelect.options[mySelect.options.length] = new Option("Grifton schools",'all=Grifton'); mySelect.options[mySelect.options.length] = new Option("Grimesland schools",'all=Grimesland'); mySelect.options[mySelect.options.length] = new Option("Stokes schools",'all=Stokes'); mySelect.options[mySelect.options.length] = new Option("Winterville schools",'all=Winterville'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Winterville[Winterville.length] = createMarker(new GPoint(-77.39720154,35.53219986),"
",iconBl); mySelect.options[mySelect.options.length] = new Option("A G Cox Middle School",'Winterville=' + Winterville.length); Ayden[Ayden.length] = createMarker(new GPoint(-77.43255615,35.47503281),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Ayden Elementary School",'Ayden=' + Ayden.length); Ayden[Ayden.length] = createMarker(new GPoint(-77.40190125,35.45709991),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Ayden Middle School",'Ayden=' + Ayden.length); Ayden[Ayden.length] = createMarker(new GPoint(-77.40190125,35.45709991),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Ayden-grifton High School",'Ayden=' + Ayden.length); Greenville[Greenville.length] = createMarker(new GPoint(-77.33393860,35.62568665),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Belvoir Elementary School",'Greenville=' + Greenville.length); Bethel[Bethel.length] = createMarker(new GPoint(-77.37041473,35.80689621),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Bethel Elementary School",'Bethel=' + Bethel.length); Greenville[Greenville.length] = createMarker(new GPoint(-77.35913086,35.59999847),"",iconBl); mySelect.options[mySelect.options.length] = new Option("C M Eppes Middle School",'Greenville=' + Greenville.length); Greenville[Greenville.length] = createMarker(new GPoint(-77.50392914,35.69566345),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Chicod Elementary School",'Greenville=' + Greenville.length); Winterville[Winterville.length] = createMarker(new GPoint(-77.42132900,35.53766700),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Creekside Elementary School",'Winterville=' + Winterville.length); Greenville[Greenville.length] = createMarker(new GPoint(-77.32451630,35.53154373),"",iconGr); mySelect.options[mySelect.options.length] = new Option("D H Conley High School",'Greenville=' + Greenville.length); Greenville[Greenville.length] = createMarker(new GPoint(-77.35430145,35.58527756),"",iconBl); mySelect.options[mySelect.options.length] = new Option("E B Aycock Middle School",'Greenville=' + Greenville.length); Greenville[Greenville.length] = createMarker(new GPoint(-77.34168243,35.59600067),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Eastern Elementary School",'Greenville=' + Greenville.length); Greenville[Greenville.length] = createMarker(new GPoint(-77.36305237,35.59360886),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Elmhurst Elementary School",'Greenville=' + Greenville.length); Greenville[Greenville.length] = createMarker(new GPoint(-77.38880157,35.62960052),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Falkland Elementary School",'Greenville=' + Greenville.length); Farmville[Farmville.length] = createMarker(new GPoint(-77.58260345,35.58580017),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Farmville Central High School",'Farmville=' + Farmville.length); Farmville[Farmville.length] = createMarker(new GPoint(-77.58260345,35.58580017),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Farmville Middle School",'Farmville=' + Farmville.length); Grimesland[Grimesland.length] = createMarker(new GPoint(-77.21150208,35.53870010),"",iconRd); mySelect.options[mySelect.options.length] = new Option("G R Whitfield Elementary School",'Grimesland=' + Grimesland.length); Grifton[Grifton.length] = createMarker(new GPoint(-77.43160248,35.37070084),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Grifton Elementary School",'Grifton=' + Grifton.length); Farmville[Farmville.length] = createMarker(new GPoint(-77.57564545,35.59375763),"",iconRd); mySelect.options[mySelect.options.length] = new Option("H B Sugg Elementary School",'Farmville=' + Farmville.length); Greenville[Greenville.length] = createMarker(new GPoint(-77.38697815,35.59167862),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Junius H Rose High School",'Greenville=' + Greenville.length); Bethel[Bethel.length] = createMarker(new GPoint(-77.37719727,35.79230118),"",iconGr); mySelect.options[mySelect.options.length] = new Option("North Pitt High School",'Bethel=' + Bethel.length); Greenville[Greenville.length] = createMarker(new GPoint(-77.47663879,35.73782730),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Northwest Elementary School",'Greenville=' + Greenville.length); Greenville[Greenville.length] = createMarker(new GPoint(-77.22370911,35.62196350),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Pactolus Elementary School",'Greenville=' + Greenville.length); Greenville[Greenville.length] = createMarker(new GPoint(-77.39320374,35.61286926),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Pitt Memorial Hospital",'Greenville=' + Greenville.length); Greenville[Greenville.length] = createMarker(new GPoint(-77.38531494,35.60980225),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Sadie Saulter Elementary School",'Greenville=' + Greenville.length); Farmville[Farmville.length] = createMarker(new GPoint(-77.57774353,35.59492111),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Sam D Bundy Elementary School",'Farmville=' + Farmville.length); Winterville[Winterville.length] = createMarker(new GPoint(-77.43495941,35.54145813),"",iconGr); mySelect.options[mySelect.options.length] = new Option("South Central High School",'Winterville=' + Winterville.length); Greenville[Greenville.length] = createMarker(new GPoint(-77.38479614,35.59907150),"",iconRd); mySelect.options[mySelect.options.length] = new Option("South Greenville Elementary School",'Greenville=' + Greenville.length); Stokes[Stokes.length] = createMarker(new GPoint(-77.26619720,35.71590042),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Stokes Elementary School",'Stokes=' + Stokes.length); Winterville[Winterville.length] = createMarker(new GPoint(-77.40131378,35.53092575),"",iconRd); mySelect.options[mySelect.options.length] = new Option("W H Robinson Elementary School",'Winterville=' + Winterville.length); Greenville[Greenville.length] = createMarker(new GPoint(-77.35011292,35.60663223),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Wahl Coates Elementary School",'Greenville=' + Greenville.length); Greenville[Greenville.length] = createMarker(new GPoint(-77.36128235,35.66577148),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Wellcome Middle School",'Greenville=' + Greenville.length); Greenville[Greenville.length] = createMarker(new GPoint(-77.35164642,35.54453659),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Wintergreen Intermediate",'Greenville=' + Greenville.length); Greenville[Greenville.length] = createMarker(new GPoint(-77.35165405,35.54473114),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Wintergreen Primary",'Greenville=' + Greenville.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(Ayden); map.removeOverlays(Bethel); map.removeOverlays(Farmville); map.removeOverlays(Greenville); map.removeOverlays(Grifton); map.removeOverlays(Grimesland); map.removeOverlays(Stokes); map.removeOverlays(Winterville); 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(Winterville);map.removeOverlays(Ayden); map.removeOverlays(Bethel); map.removeOverlays(Farmville); map.removeOverlays(Greenville); map.removeOverlays(Grifton); map.removeOverlays(Grimesland); map.removeOverlays(Stokes); map.removeOverlays(Winterville); map.addOverlays(Ayden); centerByArray(Ayden, false, false); cntMarker += Ayden.length; map.addOverlays(Bethel); centerByArray(Bethel, false, false); cntMarker += Bethel.length; map.addOverlays(Farmville); centerByArray(Farmville, false, false); cntMarker += Farmville.length; map.addOverlays(Greenville); centerByArray(Greenville, false, false); cntMarker += Greenville.length; map.addOverlays(Grifton); centerByArray(Grifton, false, false); cntMarker += Grifton.length; map.addOverlays(Grimesland); centerByArray(Grimesland, false, false); cntMarker += Grimesland.length; map.addOverlays(Stokes); centerByArray(Stokes, false, false); cntMarker += Stokes.length; map.addOverlays(Winterville); centerByArray(Winterville, false, false); cntMarker += Winterville.length; centerByArray(Winterville,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'); } }