function addMarkers() { mySelect = document.getElementById('selection'); Albany = [];Shade = [];Amesville = [];The_Plains = [];Athens = [];Chauncey = [];Coolville = [];Stewart = [];Nelsonville = [];Glouster = [];mySelect.options[mySelect.options.length] = new Option("Albany schools",'all=Albany'); mySelect.options[mySelect.options.length] = new Option("Amesville schools",'all=Amesville'); mySelect.options[mySelect.options.length] = new Option("Athens schools",'all=Athens'); mySelect.options[mySelect.options.length] = new Option("Chauncey schools",'all=Chauncey'); mySelect.options[mySelect.options.length] = new Option("Coolville schools",'all=Coolville'); mySelect.options[mySelect.options.length] = new Option("Glouster schools",'all=Glouster'); mySelect.options[mySelect.options.length] = new Option("Nelsonville schools",'all=Nelsonville'); mySelect.options[mySelect.options.length] = new Option("Shade schools",'all=Shade'); mySelect.options[mySelect.options.length] = new Option("Stewart schools",'all=Stewart'); mySelect.options[mySelect.options.length] = new Option("The Plains schools",'all=The_Plains'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Albany[Albany.length] = createMarker(new GPoint(-82.20674133,39.22657013),"
",iconRd); mySelect.options[mySelect.options.length] = new Option("Alexander Elementary School",'Albany=' + Albany.length); Albany[Albany.length] = createMarker(new GPoint(-82.24398041,39.16698074),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Alexander High School",'Albany=' + Albany.length); Shade[Shade.length] = createMarker(new GPoint(-82.03942871,39.22744751),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Alexander Junior High School",'Shade=' + Shade.length); Albany[Albany.length] = createMarker(new GPoint(-82.22022247,39.32080460),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Alexander Middle School",'Albany=' + Albany.length); Amesville[Amesville.length] = createMarker(new GPoint(-81.95500183,39.41320038),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Amesville Elementary School",'Amesville=' + Amesville.length); The_Plains[The_Plains.length] = createMarker(new GPoint(-82.12613678,39.36874771),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Athens High School",'The_Plains=' + The_Plains.length); Athens[Athens.length] = createMarker(new GPoint(-82.10118103,39.32918167),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Athens Middle School",'Athens=' + Athens.length); Chauncey[Chauncey.length] = createMarker(new GPoint(-82.12840271,39.40029907),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Chauncey Elementary School",'Chauncey=' + Chauncey.length); Coolville[Coolville.length] = createMarker(new GPoint(-81.81919861,39.21220016),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Coolville Elementary School",'Coolville=' + Coolville.length); Athens[Athens.length] = createMarker(new GPoint(-82.09445953,39.33357239),"",iconRd); mySelect.options[mySelect.options.length] = new Option("East Elementary School",'Athens=' + Athens.length); Stewart[Stewart.length] = createMarker(new GPoint(-81.86683655,39.30838394),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Federal Hocking High School",'Stewart=' + Stewart.length); Stewart[Stewart.length] = createMarker(new GPoint(-81.86683655,39.30838394),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Federal Hocking Middle School",'Stewart=' + Stewart.length); Athens[Athens.length] = createMarker(new GPoint(-82.13824463,39.32086182),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Morrison Elementary School",'Athens=' + Athens.length); Nelsonville[Nelsonville.length] = createMarker(new GPoint(-82.25231171,39.46491241),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Nelsonville-york Elementary School",'Nelsonville=' + Nelsonville.length); Nelsonville[Nelsonville.length] = createMarker(new GPoint(-82.25231171,39.46491241),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Nelsonville-york High School",'Nelsonville=' + Nelsonville.length); Nelsonville[Nelsonville.length] = createMarker(new GPoint(-82.22901154,39.41579819),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Nelsonville-york Junior High School",'Nelsonville=' + Nelsonville.length); The_Plains[The_Plains.length] = createMarker(new GPoint(-82.14263916,39.37088013),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Plains Elementary School",'The_Plains=' + The_Plains.length); Nelsonville[Nelsonville.length] = createMarker(new GPoint(-82.21205902,39.43471527),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Tri-county Career Center",'Nelsonville=' + Nelsonville.length); Glouster[Glouster.length] = createMarker(new GPoint(-82.07615662,39.46847916),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Trimble Elementary School",'Glouster=' + Glouster.length); Glouster[Glouster.length] = createMarker(new GPoint(-82.09539795,39.50339890),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Trimble High School",'Glouster=' + Glouster.length); Glouster[Glouster.length] = createMarker(new GPoint(-82.07615662,39.46847916),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Trimble Middle School",'Glouster=' + Glouster.length); Athens[Athens.length] = createMarker(new GPoint(-82.11162567,39.33473969),"",iconRd); mySelect.options[mySelect.options.length] = new Option("West Elementary School",'Athens=' + Athens.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(Albany); map.removeOverlays(Amesville); map.removeOverlays(Athens); map.removeOverlays(Chauncey); map.removeOverlays(Coolville); map.removeOverlays(Glouster); map.removeOverlays(Nelsonville); map.removeOverlays(Shade); map.removeOverlays(Stewart); map.removeOverlays(The_Plains); 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(Albany);map.removeOverlays(Albany); map.removeOverlays(Amesville); map.removeOverlays(Athens); map.removeOverlays(Chauncey); map.removeOverlays(Coolville); map.removeOverlays(Glouster); map.removeOverlays(Nelsonville); map.removeOverlays(Shade); map.removeOverlays(Stewart); map.removeOverlays(The_Plains); map.addOverlays(Albany); centerByArray(Albany, false, false); cntMarker += Albany.length; map.addOverlays(Amesville); centerByArray(Amesville, false, false); cntMarker += Amesville.length; map.addOverlays(Athens); centerByArray(Athens, false, false); cntMarker += Athens.length; map.addOverlays(Chauncey); centerByArray(Chauncey, false, false); cntMarker += Chauncey.length; map.addOverlays(Coolville); centerByArray(Coolville, false, false); cntMarker += Coolville.length; map.addOverlays(Glouster); centerByArray(Glouster, false, false); cntMarker += Glouster.length; map.addOverlays(Nelsonville); centerByArray(Nelsonville, false, false); cntMarker += Nelsonville.length; map.addOverlays(Shade); centerByArray(Shade, false, false); cntMarker += Shade.length; map.addOverlays(Stewart); centerByArray(Stewart, false, false); cntMarker += Stewart.length; map.addOverlays(The_Plains); centerByArray(The_Plains, false, false); cntMarker += The_Plains.length; centerByArray(Albany,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'); } }