function addMarkers() { mySelect = document.getElementById('selection'); Belle_Rive = [];Mount_Vernon = [];Ina = [];Bluford = [];Texico = [];Centralia = [];Mt_Vernon = [];Opdyke = [];Dix = [];Waltonville = [];Woodlawn = [];mySelect.options[mySelect.options.length] = new Option("Belle Rive schools",'all=Belle_Rive'); mySelect.options[mySelect.options.length] = new Option("Bluford schools",'all=Bluford'); mySelect.options[mySelect.options.length] = new Option("Centralia schools",'all=Centralia'); mySelect.options[mySelect.options.length] = new Option("Dix schools",'all=Dix'); mySelect.options[mySelect.options.length] = new Option("Ina schools",'all=Ina'); mySelect.options[mySelect.options.length] = new Option("Mount Vernon schools",'all=Mount_Vernon'); mySelect.options[mySelect.options.length] = new Option("Mt Vernon schools",'all=Mt_Vernon'); mySelect.options[mySelect.options.length] = new Option("Opdyke schools",'all=Opdyke'); mySelect.options[mySelect.options.length] = new Option("Texico schools",'all=Texico'); mySelect.options[mySelect.options.length] = new Option("Waltonville schools",'all=Waltonville'); mySelect.options[mySelect.options.length] = new Option("Woodlawn schools",'all=Woodlawn'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Belle_Rive[Belle_Rive.length] = createMarker(new GPoint(-88.75559998,38.21429825),"
",iconRd); mySelect.options[mySelect.options.length] = new Option("Belle Rive Grade School",'Belle_Rive=' + Belle_Rive.length); Mount_Vernon[Mount_Vernon.length] = createMarker(new GPoint(-88.89669037,38.31952286),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Benjamin Franklin Early Educ Center",'Mount_Vernon=' + Mount_Vernon.length); Mount_Vernon[Mount_Vernon.length] = createMarker(new GPoint(-88.90996552,38.28025436),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Bethel Grade School",'Mount_Vernon=' + Mount_Vernon.length); Ina[Ina.length] = createMarker(new GPoint(-88.89530182,38.15100098),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Big Muddy River Correctional Center",'Ina=' + Ina.length); Bluford[Bluford.length] = createMarker(new GPoint(-88.74880219,38.36550140),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Bluford Elementary School",'Bluford=' + Bluford.length); Mount_Vernon[Mount_Vernon.length] = createMarker(new GPoint(-88.87031555,38.25776672),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Dodds Elementary School",'Mount_Vernon=' + Mount_Vernon.length); Bluford[Bluford.length] = createMarker(new GPoint(-88.75913239,38.44554138),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Farrington Elementary School",'Bluford=' + Bluford.length); Texico[Texico.length] = createMarker(new GPoint(-88.86727142,38.43156052),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Field Elementary School",'Texico=' + Texico.length); Centralia[Centralia.length] = createMarker(new GPoint(-89.14289856,38.52199936),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Grand Prairie Elementary School",'Centralia=' + Centralia.length); Ina[Ina.length] = createMarker(new GPoint(-88.90547180,38.14780807),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Ina Community Consolidated School",'Ina=' + Ina.length); Mount_Vernon[Mount_Vernon.length] = createMarker(new GPoint(-88.93343353,38.31097031),"",iconBl); mySelect.options[mySelect.options.length] = new Option("J L Buford Intermediate Ed Center",'Mount_Vernon=' + Mount_Vernon.length); Mt_Vernon[Mt_Vernon.length] = createMarker(new GPoint(-88.89777374,38.30691147),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Kmc 801 Bd Center",'Mt_Vernon=' + Mt_Vernon.length); Mount_Vernon[Mount_Vernon.length] = createMarker(new GPoint(-88.94817352,38.26884460),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Mcclellan Elementary School",'Mount_Vernon=' + Mount_Vernon.length); Mount_Vernon[Mount_Vernon.length] = createMarker(new GPoint(-88.89892578,38.31571579),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Mount Vernon High School",'Mount_Vernon=' + Mount_Vernon.length); Mount_Vernon[Mount_Vernon.length] = createMarker(new GPoint(-88.91092682,38.31652451),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Mt Vernon Alternative School",'Mount_Vernon=' + Mount_Vernon.length); Mt_Vernon[Mt_Vernon.length] = createMarker(new GPoint(-88.89892578,38.31571579),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Mt Vernon Area Voc Center",'Mt_Vernon=' + Mt_Vernon.length); Mount_Vernon[Mount_Vernon.length] = createMarker(new GPoint(-88.92742920,38.31711960),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Mt Vernon District 80 Primary Center",'Mount_Vernon=' + Mount_Vernon.length); Opdyke[Opdyke.length] = createMarker(new GPoint(-88.77249908,38.27949905),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Opdyke Grade School",'Opdyke=' + Opdyke.length); Dix[Dix.length] = createMarker(new GPoint(-88.93988800,38.43970108),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Rome Community Consolidated Elementary School",'Dix=' + Dix.length); Mount_Vernon[Mount_Vernon.length] = createMarker(new GPoint(-88.91092682,38.31652451),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Safe School Program",'Mount_Vernon=' + Mount_Vernon.length); Mt_Vernon[Mt_Vernon.length] = createMarker(new GPoint(-88.89892578,38.31571579),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Sesr Hamilton/jefferson Cty",'Mt_Vernon=' + Mt_Vernon.length); Mount_Vernon[Mount_Vernon.length] = createMarker(new GPoint(-88.86664581,38.32833099),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Summersville Grade School",'Mount_Vernon=' + Mount_Vernon.length); Waltonville[Waltonville.length] = createMarker(new GPoint(-89.05042267,38.21368408),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Waltonville Grade School",'Waltonville=' + Waltonville.length); Waltonville[Waltonville.length] = createMarker(new GPoint(-89.05047607,38.21368408),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Waltonville High School",'Waltonville=' + Waltonville.length); Bluford[Bluford.length] = createMarker(new GPoint(-88.74880219,38.36550140),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Webber Township High School",'Bluford=' + Bluford.length); Woodlawn[Woodlawn.length] = createMarker(new GPoint(-89.03487396,38.33154678),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Woodlawn Community High School",'Woodlawn=' + Woodlawn.length); Woodlawn[Woodlawn.length] = createMarker(new GPoint(-89.03507233,38.33003998),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Woodlawn School",'Woodlawn=' + Woodlawn.length); Mount_Vernon[Mount_Vernon.length] = createMarker(new GPoint(-88.91270447,38.31606293),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Zadok Casey Middle School",'Mount_Vernon=' + Mount_Vernon.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(Belle_Rive); map.removeOverlays(Bluford); map.removeOverlays(Centralia); map.removeOverlays(Dix); map.removeOverlays(Ina); map.removeOverlays(Mount_Vernon); map.removeOverlays(Mt_Vernon); map.removeOverlays(Opdyke); map.removeOverlays(Texico); map.removeOverlays(Waltonville); map.removeOverlays(Woodlawn); 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(Belle_Rive);map.removeOverlays(Belle_Rive); map.removeOverlays(Bluford); map.removeOverlays(Centralia); map.removeOverlays(Dix); map.removeOverlays(Ina); map.removeOverlays(Mount_Vernon); map.removeOverlays(Mt_Vernon); map.removeOverlays(Opdyke); map.removeOverlays(Texico); map.removeOverlays(Waltonville); map.removeOverlays(Woodlawn); map.addOverlays(Belle_Rive); centerByArray(Belle_Rive, false, false); cntMarker += Belle_Rive.length; map.addOverlays(Bluford); centerByArray(Bluford, false, false); cntMarker += Bluford.length; map.addOverlays(Centralia); centerByArray(Centralia, false, false); cntMarker += Centralia.length; map.addOverlays(Dix); centerByArray(Dix, false, false); cntMarker += Dix.length; map.addOverlays(Ina); centerByArray(Ina, false, false); cntMarker += Ina.length; map.addOverlays(Mount_Vernon); centerByArray(Mount_Vernon, false, false); cntMarker += Mount_Vernon.length; map.addOverlays(Mt_Vernon); centerByArray(Mt_Vernon, false, false); cntMarker += Mt_Vernon.length; map.addOverlays(Opdyke); centerByArray(Opdyke, false, false); cntMarker += Opdyke.length; map.addOverlays(Texico); centerByArray(Texico, false, false); cntMarker += Texico.length; map.addOverlays(Waltonville); centerByArray(Waltonville, false, false); cntMarker += Waltonville.length; map.addOverlays(Woodlawn); centerByArray(Woodlawn, false, false); cntMarker += Woodlawn.length; centerByArray(Belle_Rive,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'); } }