function addMarkers() { mySelect = document.getElementById('selection'); New_Washington = [];Tiro = [];Chatfield = [];Bucyrus = [];North_Robinson = [];Crestline = [];Galion = [];Sulphur_Springs = [];mySelect.options[mySelect.options.length] = new Option("Bucyrus schools",'all=Bucyrus'); mySelect.options[mySelect.options.length] = new Option("Chatfield schools",'all=Chatfield'); mySelect.options[mySelect.options.length] = new Option("Crestline schools",'all=Crestline'); mySelect.options[mySelect.options.length] = new Option("Galion schools",'all=Galion'); mySelect.options[mySelect.options.length] = new Option("New Washington schools",'all=New_Washington'); mySelect.options[mySelect.options.length] = new Option("North Robinson schools",'all=North_Robinson'); mySelect.options[mySelect.options.length] = new Option("Sulphur Springs schools",'all=Sulphur_Springs'); mySelect.options[mySelect.options.length] = new Option("Tiro schools",'all=Tiro'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); New_Washington[New_Washington.length] = createMarker(new GPoint(-82.85341644,40.96030045),"
",iconGr); mySelect.options[mySelect.options.length] = new Option("Buckeye Central High School",'New_Washington=' + New_Washington.length); Tiro[Tiro.length] = createMarker(new GPoint(-82.79180145,40.90719986),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Buckeye East Elementary School",'Tiro=' + Tiro.length); Chatfield[Chatfield.length] = createMarker(new GPoint(-83.03119659,40.96540070),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Buckeye West Elementary School",'Chatfield=' + Chatfield.length); Bucyrus[Bucyrus.length] = createMarker(new GPoint(-82.98992920,40.81187439),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Bucyrus High School",'Bucyrus=' + Bucyrus.length); Bucyrus[Bucyrus.length] = createMarker(new GPoint(-82.97325897,40.80477524),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Bucyrus Middle School",'Bucyrus=' + Bucyrus.length); Bucyrus[Bucyrus.length] = createMarker(new GPoint(-82.97103119,40.80479431),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Carlisle Elementary School",'Bucyrus=' + Bucyrus.length); North_Robinson[North_Robinson.length] = createMarker(new GPoint(-82.85749817,40.79249954),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Col Crawford High School",'North_Robinson=' + North_Robinson.length); North_Robinson[North_Robinson.length] = createMarker(new GPoint(-82.85749817,40.79249954),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Col Crawford Intermediate Middle School",'North_Robinson=' + North_Robinson.length); Crestline[Crestline.length] = createMarker(new GPoint(-82.74475861,40.79922485),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Crestline High School",'Crestline=' + Crestline.length); Crestline[Crestline.length] = createMarker(new GPoint(-82.73931885,40.78546143),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Crestline Middle School",'Crestline=' + Crestline.length); Crestline[Crestline.length] = createMarker(new GPoint(-82.74089050,40.79193878),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Crestline North Elementary School",'Crestline=' + Crestline.length); Crestline[Crestline.length] = createMarker(new GPoint(-82.73262787,40.77845764),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Crestline Southeast Elementary School",'Crestline=' + Crestline.length); Galion[Galion.length] = createMarker(new GPoint(-82.77140045,40.72628021),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Dawsett Elementary School",'Galion=' + Galion.length); Galion[Galion.length] = createMarker(new GPoint(-82.79111481,40.73523331),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Galion High School",'Galion=' + Galion.length); Galion[Galion.length] = createMarker(new GPoint(-82.79125214,40.73258209),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Galion Middle School",'Galion=' + Galion.length); Bucyrus[Bucyrus.length] = createMarker(new GPoint(-82.98271179,40.81499100),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Kearsley Education Center Elementary School",'Bucyrus=' + Bucyrus.length); Bucyrus[Bucyrus.length] = createMarker(new GPoint(-82.97398376,40.79626465),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Kilbourne Elementary School",'Bucyrus=' + Bucyrus.length); Bucyrus[Bucyrus.length] = createMarker(new GPoint(-82.97367859,40.81564331),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Lincoln Elementary School",'Bucyrus=' + Bucyrus.length); Galion[Galion.length] = createMarker(new GPoint(-82.79080200,40.74301147),"",iconRd); mySelect.options[mySelect.options.length] = new Option("North Elementary School",'Galion=' + Galion.length); Bucyrus[Bucyrus.length] = createMarker(new GPoint(-82.97946930,40.80425644),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Norton Elementary School",'Bucyrus=' + Bucyrus.length); Galion[Galion.length] = createMarker(new GPoint(-82.80941772,40.73408890),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Renschville Elementary School",'Galion=' + Galion.length); Sulphur_Springs[Sulphur_Springs.length] = createMarker(new GPoint(-82.87719727,40.87080002),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Sulphur Springs Elementary School",'Sulphur_Springs=' + Sulphur_Springs.length); Bucyrus[Bucyrus.length] = createMarker(new GPoint(-82.91551208,40.74006271),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Whetstone Elementary School",'Bucyrus=' + Bucyrus.length); Galion[Galion.length] = createMarker(new GPoint(-82.79309845,40.72420883),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Wilma Crall Elementary School",'Galion=' + Galion.length); Bucyrus[Bucyrus.length] = createMarker(new GPoint(-83.01667786,40.82167053),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Wynford Elementary School",'Bucyrus=' + Bucyrus.length); Bucyrus[Bucyrus.length] = createMarker(new GPoint(-83.01667786,40.82138824),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Wynford High School",'Bucyrus=' + Bucyrus.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(Bucyrus); map.removeOverlays(Chatfield); map.removeOverlays(Crestline); map.removeOverlays(Galion); map.removeOverlays(New_Washington); map.removeOverlays(North_Robinson); map.removeOverlays(Sulphur_Springs); map.removeOverlays(Tiro); 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(New_Washington);map.removeOverlays(Bucyrus); map.removeOverlays(Chatfield); map.removeOverlays(Crestline); map.removeOverlays(Galion); map.removeOverlays(New_Washington); map.removeOverlays(North_Robinson); map.removeOverlays(Sulphur_Springs); map.removeOverlays(Tiro); map.addOverlays(Bucyrus); centerByArray(Bucyrus, false, false); cntMarker += Bucyrus.length; map.addOverlays(Chatfield); centerByArray(Chatfield, false, false); cntMarker += Chatfield.length; map.addOverlays(Crestline); centerByArray(Crestline, false, false); cntMarker += Crestline.length; map.addOverlays(Galion); centerByArray(Galion, false, false); cntMarker += Galion.length; map.addOverlays(New_Washington); centerByArray(New_Washington, false, false); cntMarker += New_Washington.length; map.addOverlays(North_Robinson); centerByArray(North_Robinson, false, false); cntMarker += North_Robinson.length; map.addOverlays(Sulphur_Springs); centerByArray(Sulphur_Springs, false, false); cntMarker += Sulphur_Springs.length; map.addOverlays(Tiro); centerByArray(Tiro, false, false); cntMarker += Tiro.length; centerByArray(New_Washington,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'); } }