function addMarkers() { mySelect = document.getElementById('selection'); Marion = [];Caledonia = [];Green_Camp = [];Prospect = [];La_Rue = [];Morral = [];mySelect.options[mySelect.options.length] = new Option("Caledonia schools",'all=Caledonia'); mySelect.options[mySelect.options.length] = new Option("Green Camp schools",'all=Green_Camp'); mySelect.options[mySelect.options.length] = new Option("La Rue schools",'all=La_Rue'); mySelect.options[mySelect.options.length] = new Option("Marion schools",'all=Marion'); mySelect.options[mySelect.options.length] = new Option("Morral schools",'all=Morral'); mySelect.options[mySelect.options.length] = new Option("Prospect schools",'all=Prospect'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Marion[Marion.length] = createMarker(new GPoint(-83.10472870,40.58311081),"
",iconBl); mySelect.options[mySelect.options.length] = new Option("Baker Middle School",'Marion=' + Marion.length); Caledonia[Caledonia.length] = createMarker(new GPoint(-83.02185059,40.58263016),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Claridon Elementary School",'Caledonia=' + Caledonia.length); Marion[Marion.length] = createMarker(new GPoint(-83.16050720,40.56740189),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Colonial Acres Elementary School",'Marion=' + Marion.length); Marion[Marion.length] = createMarker(new GPoint(-83.14947510,40.57179260),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Edison Middle School",'Marion=' + Marion.length); Marion[Marion.length] = createMarker(new GPoint(-83.25238800,40.56619263),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Elgin Digital Academy",'Marion=' + Marion.length); Marion[Marion.length] = createMarker(new GPoint(-83.24668121,40.56679916),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Elgin High School",'Marion=' + Marion.length); Green_Camp[Green_Camp.length] = createMarker(new GPoint(-83.20960236,40.53200150),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Elgin Junior High School",'Green_Camp=' + Green_Camp.length); Prospect[Prospect.length] = createMarker(new GPoint(-83.18737030,40.45186996),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Elgin South Elementary School",'Prospect=' + Prospect.length); La_Rue[La_Rue.length] = createMarker(new GPoint(-83.38421631,40.58024597),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Elgin West Elementary School",'La_Rue=' + La_Rue.length); Marion[Marion.length] = createMarker(new GPoint(-83.11898804,40.60689163),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Fair Park Elementary School",'Marion=' + Marion.length); Marion[Marion.length] = createMarker(new GPoint(-83.10468292,40.58546448),"",iconRd); mySelect.options[mySelect.options.length] = new Option("George Washington Elementary School",'Marion=' + Marion.length); Marion[Marion.length] = createMarker(new GPoint(-83.09007263,40.59108734),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Harding High School",'Marion=' + Marion.length); Marion[Marion.length] = createMarker(new GPoint(-83.04262543,40.57364655),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Heritage Elementary School",'Marion=' + Marion.length); Marion[Marion.length] = createMarker(new GPoint(-83.12239838,40.58340073),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Hickory Grove (majcf) High School",'Marion=' + Marion.length); Marion[Marion.length] = createMarker(new GPoint(-83.15020752,40.58419800),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Indian Mound Elementary School",'Marion=' + Marion.length); Morral[Morral.length] = createMarker(new GPoint(-83.17347717,40.64283371),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Jackson-eastside Elementary School",'Morral=' + Morral.length); Marion[Marion.length] = createMarker(new GPoint(-83.08489990,40.58100128),"",iconGr); mySelect.options[mySelect.options.length] = new Option("James A Garfield Elementary School",'Marion=' + Marion.length); Caledonia[Caledonia.length] = createMarker(new GPoint(-82.97848511,40.61689377),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Liberty Elementary School",'Caledonia=' + Caledonia.length); Marion[Marion.length] = createMarker(new GPoint(-83.12239838,40.58340073),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Marion City Digital Academy",'Marion=' + Marion.length); Marion[Marion.length] = createMarker(new GPoint(-83.12075806,40.59509659),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Mark Street Elementary School",'Marion=' + Marion.length); Morral[Morral.length] = createMarker(new GPoint(-83.20973206,40.68766403),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Morral Elementary School",'Morral=' + Morral.length); Marion[Marion.length] = createMarker(new GPoint(-83.13247681,40.59834671),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Oak Street Elementary School",'Marion=' + Marion.length); Marion[Marion.length] = createMarker(new GPoint(-83.14530945,40.57487869),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Oakland Elementary School",'Marion=' + Marion.length); Marion[Marion.length] = createMarker(new GPoint(-83.13790131,40.57884979),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Olney Avenue Elementary School",'Marion=' + Marion.length); Marion[Marion.length] = createMarker(new GPoint(-83.13131714,40.58156967),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Pearl Street Elementary School",'Marion=' + Marion.length); Marion[Marion.length] = createMarker(new GPoint(-83.13971710,40.52006149),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Pleasant Community Digital",'Marion=' + Marion.length); Marion[Marion.length] = createMarker(new GPoint(-83.13966370,40.52006149),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Pleasant Elementary School",'Marion=' + Marion.length); Marion[Marion.length] = createMarker(new GPoint(-83.13956451,40.52006149),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Pleasant High School",'Marion=' + Marion.length); Marion[Marion.length] = createMarker(new GPoint(-83.13591003,40.51998520),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Pleasant Middle School",'Marion=' + Marion.length); Morral[Morral.length] = createMarker(new GPoint(-83.17347717,40.64286041),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Ridgedale Elementary School",'Morral=' + Morral.length); Morral[Morral.length] = createMarker(new GPoint(-83.17347717,40.64362717),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Ridgedale Jr/sr High School",'Morral=' + Morral.length); Caledonia[Caledonia.length] = createMarker(new GPoint(-83.03166962,40.61063766),"",iconGr); mySelect.options[mySelect.options.length] = new Option("River Valley Digital Academy",'Caledonia=' + Caledonia.length); Caledonia[Caledonia.length] = createMarker(new GPoint(-83.01430511,40.58290482),"",iconGr); mySelect.options[mySelect.options.length] = new Option("River Valley High School",'Caledonia=' + Caledonia.length); Caledonia[Caledonia.length] = createMarker(new GPoint(-83.01332092,40.58293533),"",iconBl); mySelect.options[mySelect.options.length] = new Option("River Valley Middle School",'Caledonia=' + Caledonia.length); Marion[Marion.length] = createMarker(new GPoint(-83.63459778,41.02329636),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Silver Street Elementary School",'Marion=' + Marion.length); Marion[Marion.length] = createMarker(new GPoint(-83.11927795,40.60703659),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Taft Elementary School",'Marion=' + Marion.length); Marion[Marion.length] = createMarker(new GPoint(-83.12776947,40.59652710),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Taft Middle School",'Marion=' + Marion.length); Marion[Marion.length] = createMarker(new GPoint(-83.08433533,40.58103943),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Treca Digital Academy",'Marion=' + Marion.length); Marion[Marion.length] = createMarker(new GPoint(-83.07066345,40.58159637),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Tri-rivers Career Center",'Marion=' + Marion.length); Marion[Marion.length] = createMarker(new GPoint(-83.12158800,40.58215800),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Ulysses S. Grant Middle School",'Marion=' + Marion.length); Marion[Marion.length] = createMarker(new GPoint(-83.12304800,40.57099400),"",iconRd); mySelect.options[mySelect.options.length] = new Option("William Mckinley Elementary School",'Marion=' + Marion.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(Caledonia); map.removeOverlays(Green_Camp); map.removeOverlays(La_Rue); map.removeOverlays(Marion); map.removeOverlays(Morral); map.removeOverlays(Prospect); 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(Marion);map.removeOverlays(Caledonia); map.removeOverlays(Green_Camp); map.removeOverlays(La_Rue); map.removeOverlays(Marion); map.removeOverlays(Morral); map.removeOverlays(Prospect); map.addOverlays(Caledonia); centerByArray(Caledonia, false, false); cntMarker += Caledonia.length; map.addOverlays(Green_Camp); centerByArray(Green_Camp, false, false); cntMarker += Green_Camp.length; map.addOverlays(La_Rue); centerByArray(La_Rue, false, false); cntMarker += La_Rue.length; map.addOverlays(Marion); centerByArray(Marion, false, false); cntMarker += Marion.length; map.addOverlays(Morral); centerByArray(Morral, false, false); cntMarker += Morral.length; map.addOverlays(Prospect); centerByArray(Prospect, false, false); cntMarker += Prospect.length; centerByArray(Marion,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'); } }