function addMarkers() { mySelect = document.getElementById('selection'); Archbold = [];Wauseon = [];Swanton = [];Delta = [];Metamora = [];Fayette = [];Lyons = [];Pettisville = [];mySelect.options[mySelect.options.length] = new Option("Archbold schools",'all=Archbold'); mySelect.options[mySelect.options.length] = new Option("Delta schools",'all=Delta'); mySelect.options[mySelect.options.length] = new Option("Fayette schools",'all=Fayette'); mySelect.options[mySelect.options.length] = new Option("Lyons schools",'all=Lyons'); mySelect.options[mySelect.options.length] = new Option("Metamora schools",'all=Metamora'); mySelect.options[mySelect.options.length] = new Option("Pettisville schools",'all=Pettisville'); mySelect.options[mySelect.options.length] = new Option("Swanton schools",'all=Swanton'); mySelect.options[mySelect.options.length] = new Option("Wauseon schools",'all=Wauseon'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Archbold[Archbold.length] = createMarker(new GPoint(-84.31140900,41.51433563),"
",iconRd); mySelect.options[mySelect.options.length] = new Option("Archbold Elementary School",'Archbold=' + Archbold.length); Archbold[Archbold.length] = createMarker(new GPoint(-84.30808258,41.51433563),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Archbold High School",'Archbold=' + Archbold.length); Archbold[Archbold.length] = createMarker(new GPoint(-84.30916595,41.52173615),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Archbold Middle School",'Archbold=' + Archbold.length); Wauseon[Wauseon.length] = createMarker(new GPoint(-84.13891602,41.53990555),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Burr Road Middle School",'Wauseon=' + Wauseon.length); Swanton[Swanton.length] = createMarker(new GPoint(-83.88858032,41.59227371),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Crestwood Elementary School",'Swanton=' + Swanton.length); Delta[Delta.length] = createMarker(new GPoint(-84.00549316,41.57753754),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Delta Elementary School",'Delta=' + Delta.length); Wauseon[Wauseon.length] = createMarker(new GPoint(-84.13574982,41.55001450),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Elm Street Elementary School",'Wauseon=' + Wauseon.length); Metamora[Metamora.length] = createMarker(new GPoint(-83.97518158,41.67896652),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Evergreen High School",'Metamora=' + Metamora.length); Metamora[Metamora.length] = createMarker(new GPoint(-83.91351318,41.70813370),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Evergreen Middle School",'Metamora=' + Metamora.length); Fayette[Fayette.length] = createMarker(new GPoint(-84.31950378,41.66590118),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Fayette Elementary School",'Fayette=' + Fayette.length); Fayette[Fayette.length] = createMarker(new GPoint(-84.31950378,41.66590118),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Fayette Jr/sr High School",'Fayette=' + Fayette.length); Archbold[Archbold.length] = createMarker(new GPoint(-84.32651520,41.61584091),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Franklin Elementary School",'Archbold=' + Archbold.length); Metamora[Metamora.length] = createMarker(new GPoint(-83.93491364,41.62382889),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Fulton Elementary School",'Metamora=' + Metamora.length); Wauseon[Wauseon.length] = createMarker(new GPoint(-84.12591553,41.54416275),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Leggett St Primary Elementary School",'Wauseon=' + Wauseon.length); Lyons[Lyons.length] = createMarker(new GPoint(-84.07073975,41.70296860),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Lyons Elementary School",'Lyons=' + Lyons.length); Swanton[Swanton.length] = createMarker(new GPoint(-83.89337921,41.58523560),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Park Elementary School",'Swanton=' + Swanton.length); Pettisville[Pettisville.length] = createMarker(new GPoint(-84.17179871,41.59899902),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Pettisville Elementary School",'Pettisville=' + Pettisville.length); Pettisville[Pettisville.length] = createMarker(new GPoint(-84.13636017,41.31386185),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Pettisville High School",'Pettisville=' + Pettisville.length); Delta[Delta.length] = createMarker(new GPoint(-83.99898529,41.57966614),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Pike-delta-york High School",'Delta=' + Delta.length); Delta[Delta.length] = createMarker(new GPoint(-83.96019745,41.52090073),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Pike-delta-york Middle School",'Delta=' + Delta.length); Swanton[Swanton.length] = createMarker(new GPoint(-83.89440918,41.59063721),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Swanton High School",'Swanton=' + Swanton.length); Swanton[Swanton.length] = createMarker(new GPoint(-83.89440918,41.59063721),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Swanton Middle School",'Swanton=' + Swanton.length); Wauseon[Wauseon.length] = createMarker(new GPoint(-84.13024139,41.55366135),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Wauseon High School",'Wauseon=' + Wauseon.length); Wauseon[Wauseon.length] = createMarker(new GPoint(-84.05718231,41.53741455),"",iconBl); mySelect.options[mySelect.options.length] = new Option("York Elementary School",'Wauseon=' + Wauseon.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(Archbold); map.removeOverlays(Delta); map.removeOverlays(Fayette); map.removeOverlays(Lyons); map.removeOverlays(Metamora); map.removeOverlays(Pettisville); map.removeOverlays(Swanton); map.removeOverlays(Wauseon); 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(Archbold);map.removeOverlays(Archbold); map.removeOverlays(Delta); map.removeOverlays(Fayette); map.removeOverlays(Lyons); map.removeOverlays(Metamora); map.removeOverlays(Pettisville); map.removeOverlays(Swanton); map.removeOverlays(Wauseon); map.addOverlays(Archbold); centerByArray(Archbold, false, false); cntMarker += Archbold.length; map.addOverlays(Delta); centerByArray(Delta, false, false); cntMarker += Delta.length; map.addOverlays(Fayette); centerByArray(Fayette, false, false); cntMarker += Fayette.length; map.addOverlays(Lyons); centerByArray(Lyons, false, false); cntMarker += Lyons.length; map.addOverlays(Metamora); centerByArray(Metamora, false, false); cntMarker += Metamora.length; map.addOverlays(Pettisville); centerByArray(Pettisville, false, false); cntMarker += Pettisville.length; map.addOverlays(Swanton); centerByArray(Swanton, false, false); cntMarker += Swanton.length; map.addOverlays(Wauseon); centerByArray(Wauseon, false, false); cntMarker += Wauseon.length; centerByArray(Archbold,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'); } }