function addMarkers() { mySelect = document.getElementById('selection'); Astoria = [];Avon = [];Canton = [];Lewistown = [];Farmington = [];Cuba = [];London_Mills = [];Table_Grove = [];mySelect.options[mySelect.options.length] = new Option("Astoria schools",'all=Astoria'); mySelect.options[mySelect.options.length] = new Option("Avon schools",'all=Avon'); mySelect.options[mySelect.options.length] = new Option("Canton schools",'all=Canton'); mySelect.options[mySelect.options.length] = new Option("Cuba schools",'all=Cuba'); mySelect.options[mySelect.options.length] = new Option("Farmington schools",'all=Farmington'); mySelect.options[mySelect.options.length] = new Option("Lewistown schools",'all=Lewistown'); mySelect.options[mySelect.options.length] = new Option("London Mills schools",'all=London_Mills'); mySelect.options[mySelect.options.length] = new Option("Table Grove schools",'all=Table_Grove'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Astoria[Astoria.length] = createMarker(new GPoint(-90.35277557,40.22849655),"
",iconRd); mySelect.options[mySelect.options.length] = new Option("Astoria Elementary School",'Astoria=' + Astoria.length); Astoria[Astoria.length] = createMarker(new GPoint(-90.35277557,40.22849655),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Astoria High School",'Astoria=' + Astoria.length); Astoria[Astoria.length] = createMarker(new GPoint(-90.35277557,40.22849655),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Astoria Junior High School",'Astoria=' + Astoria.length); Avon[Avon.length] = createMarker(new GPoint(-90.43218994,40.66443634),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Avon Grade School",'Avon=' + Avon.length); Avon[Avon.length] = createMarker(new GPoint(-90.43218994,40.66443634),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Avon Middle School",'Avon=' + Avon.length); Avon[Avon.length] = createMarker(new GPoint(-90.43218994,40.66443634),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Avon Senior High School",'Avon=' + Avon.length); Canton[Canton.length] = createMarker(new GPoint(-90.03591919,40.56985092),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Canton High School",'Canton=' + Canton.length); Lewistown[Lewistown.length] = createMarker(new GPoint(-90.14364624,40.38566208),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Central Elementary School",'Lewistown=' + Lewistown.length); Farmington[Farmington.length] = createMarker(new GPoint(-90.00149536,40.69803238),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Chapman Middle School",'Farmington=' + Farmington.length); Cuba[Cuba.length] = createMarker(new GPoint(-90.18920135,40.49959946),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Cuba Elementary School",'Cuba=' + Cuba.length); Cuba[Cuba.length] = createMarker(new GPoint(-90.18920135,40.49959946),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Cuba Middle School",'Cuba=' + Cuba.length); Cuba[Cuba.length] = createMarker(new GPoint(-90.18920135,40.49959946),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Cuba Senior High School",'Cuba=' + Cuba.length); Canton[Canton.length] = createMarker(new GPoint(-90.02859900,40.55832000),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Eastview Elementary School",'Canton=' + Canton.length); Canton[Canton.length] = createMarker(new GPoint(-90.03514099,40.55831146),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Facs/src/lamonts",'Canton=' + Canton.length); Canton[Canton.length] = createMarker(new GPoint(-90.02384949,40.55843735),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Fulton Regional Safe School",'Canton=' + Canton.length); Farmington[Farmington.length] = createMarker(new GPoint(-90.01010132,40.69816208),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Harris Elementary School",'Farmington=' + Farmington.length); Canton[Canton.length] = createMarker(new GPoint(-90.02670288,40.55369949),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Illinois River Correctional Center",'Canton=' + Canton.length); Canton[Canton.length] = createMarker(new GPoint(-90.00779724,40.56093597),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Ingersoll Middle School",'Canton=' + Canton.length); Lewistown[Lewistown.length] = createMarker(new GPoint(-90.14364624,40.38566208),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Lewistown Elementary School",'Lewistown=' + Lewistown.length); Lewistown[Lewistown.length] = createMarker(new GPoint(-90.15518951,40.39313889),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Lewistown High School",'Lewistown=' + Lewistown.length); Canton[Canton.length] = createMarker(new GPoint(-90.03523254,40.57841873),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Lincoln Elementary School",'Canton=' + Canton.length); Canton[Canton.length] = createMarker(new GPoint(-90.02384949,40.55843735),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Mccall School",'Canton=' + Canton.length); Lewistown[Lewistown.length] = createMarker(new GPoint(-90.15322113,40.39535904),"",iconGr); mySelect.options[mySelect.options.length] = new Option("New Horizons",'Lewistown=' + Lewistown.length); Canton[Canton.length] = createMarker(new GPoint(-90.03514099,40.55831146),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Spoon River Academy",'Canton=' + Canton.length); London_Mills[London_Mills.length] = createMarker(new GPoint(-90.26508331,40.71049881),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Spoon River Valley Elementary School",'London_Mills=' + London_Mills.length); London_Mills[London_Mills.length] = createMarker(new GPoint(-90.26508331,40.71049881),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Spoon River Valley Junior High School",'London_Mills=' + London_Mills.length); London_Mills[London_Mills.length] = createMarker(new GPoint(-90.26508331,40.71049881),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Spoon River Valley Senior High School",'London_Mills=' + London_Mills.length); Table_Grove[Table_Grove.length] = createMarker(new GPoint(-90.42395020,40.36423874),"",iconRd); mySelect.options[mySelect.options.length] = new Option("V I T Elementary School",'Table_Grove=' + Table_Grove.length); Table_Grove[Table_Grove.length] = createMarker(new GPoint(-90.42395020,40.36423874),"",iconBl); mySelect.options[mySelect.options.length] = new Option("V I T Junior High School",'Table_Grove=' + Table_Grove.length); Table_Grove[Table_Grove.length] = createMarker(new GPoint(-90.42395020,40.36423874),"",iconGr); mySelect.options[mySelect.options.length] = new Option("V I T Senior High School",'Table_Grove=' + Table_Grove.length); Canton[Canton.length] = createMarker(new GPoint(-90.05173492,40.56653214),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Westview Elementary School",'Canton=' + Canton.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(Astoria); map.removeOverlays(Avon); map.removeOverlays(Canton); map.removeOverlays(Cuba); map.removeOverlays(Farmington); map.removeOverlays(Lewistown); map.removeOverlays(London_Mills); map.removeOverlays(Table_Grove); 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(Astoria);map.removeOverlays(Astoria); map.removeOverlays(Avon); map.removeOverlays(Canton); map.removeOverlays(Cuba); map.removeOverlays(Farmington); map.removeOverlays(Lewistown); map.removeOverlays(London_Mills); map.removeOverlays(Table_Grove); map.addOverlays(Astoria); centerByArray(Astoria, false, false); cntMarker += Astoria.length; map.addOverlays(Avon); centerByArray(Avon, false, false); cntMarker += Avon.length; map.addOverlays(Canton); centerByArray(Canton, false, false); cntMarker += Canton.length; map.addOverlays(Cuba); centerByArray(Cuba, false, false); cntMarker += Cuba.length; map.addOverlays(Farmington); centerByArray(Farmington, false, false); cntMarker += Farmington.length; map.addOverlays(Lewistown); centerByArray(Lewistown, false, false); cntMarker += Lewistown.length; map.addOverlays(London_Mills); centerByArray(London_Mills, false, false); cntMarker += London_Mills.length; map.addOverlays(Table_Grove); centerByArray(Table_Grove, false, false); cntMarker += Table_Grove.length; centerByArray(Astoria,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'); } }