function addMarkers() { mySelect = document.getElementById('selection'); Baxter_Springs = [];Columbus = [];Galena = [];Riverton = [];Scammon = [];Weir = [];West_Mineral = [];mySelect.options[mySelect.options.length] = new Option("Baxter Springs schools",'all=Baxter_Springs'); mySelect.options[mySelect.options.length] = new Option("Columbus schools",'all=Columbus'); mySelect.options[mySelect.options.length] = new Option("Galena schools",'all=Galena'); mySelect.options[mySelect.options.length] = new Option("Riverton schools",'all=Riverton'); mySelect.options[mySelect.options.length] = new Option("Scammon schools",'all=Scammon'); mySelect.options[mySelect.options.length] = new Option("Weir schools",'all=Weir'); mySelect.options[mySelect.options.length] = new Option("West Mineral schools",'all=West_Mineral'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Baxter_Springs[Baxter_Springs.length] = createMarker(new GPoint(-94.73491669,37.03767395),"
Baxter Springs High School
100 N Military
Baxter Springs, KS 66713

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Baxter Springs High School",'Baxter_Springs=' + Baxter_Springs.length); Baxter_Springs[Baxter_Springs.length] = createMarker(new GPoint(-94.73302460,37.02019501),"
Baxter Springs Middle School
1520 Cleveland
Baxter Springs, KS 66713

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Baxter Springs Middle School",'Baxter_Springs=' + Baxter_Springs.length); Baxter_Springs[Baxter_Springs.length] = createMarker(new GPoint(-94.73708344,37.02046204),"
Central Elementary School
1501 Park Ave
Baxter Springs, KS 66713

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Central Elementary School",'Baxter_Springs=' + Baxter_Springs.length); Columbus[Columbus.length] = createMarker(new GPoint(-94.84972382,37.16411972),"
Central Elementary School
810 S High School Avenue
Columbus, KS 66725

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Central Elementary School",'Columbus=' + Columbus.length); Columbus[Columbus.length] = createMarker(new GPoint(-94.84972382,37.17057800),"
Columbus High School
124 S High School Avenue
Columbus, KS 66725

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Columbus High School",'Columbus=' + Columbus.length); Galena[Galena.length] = createMarker(new GPoint(-94.63255310,37.07476425),"
Cornerstone Alternative Charter High School
702 E. 7th Street
Galena, KS 66739

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Cornerstone Alternative Charter High School",'Galena=' + Galena.length); Galena[Galena.length] = createMarker(new GPoint(-94.63381195,37.07396317),"
Galena High School
702 E. 7th Street
Galena, KS 66739

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Galena High School",'Galena=' + Galena.length); Galena[Galena.length] = createMarker(new GPoint(-94.63366699,37.07396317),"
Galena Middle School
702 E. 7th Street
Galena, KS 66739

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Galena Middle School",'Galena=' + Galena.length); Columbus[Columbus.length] = createMarker(new GPoint(-94.88584137,37.04364014),"
Greenlawn Elementary School
9155 Sw 30th Street
Columbus, KS 66725

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Greenlawn Elementary School",'Columbus=' + Columbus.length); Columbus[Columbus.length] = createMarker(new GPoint(-94.85007477,37.17317581),"
Highland Elementary School
319 N High School St
Columbus, KS 66725

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Highland Elementary School",'Columbus=' + Columbus.length); Galena[Galena.length] = createMarker(new GPoint(-94.63919900,37.07459000),"
Liberty Elementary School
702 E. 7th Street
Galena, KS 66739

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Liberty Elementary School",'Galena=' + Galena.length); Baxter_Springs[Baxter_Springs.length] = createMarker(new GPoint(-94.73788452,37.02786636),"
Lincoln Elementary School
801 Lincoln
Baxter Springs, KS 66713

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Lincoln Elementary School",'Baxter_Springs=' + Baxter_Springs.length); Columbus[Columbus.length] = createMarker(new GPoint(-94.83454132,37.16936111),"
Park Elementary School
724 E Garfield Street
Columbus, KS 66725

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Park Elementary School",'Columbus=' + Columbus.length); Riverton[Riverton.length] = createMarker(new GPoint(-94.70010376,37.08330154),"
Riverton Elementary School
Box 260
Riverton, KS 66770

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Riverton Elementary School",'Riverton=' + Riverton.length); Riverton[Riverton.length] = createMarker(new GPoint(-94.70010376,37.08330154),"
Riverton High School
Box 290
Riverton, KS 66770

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Riverton High School",'Riverton=' + Riverton.length); Riverton[Riverton.length] = createMarker(new GPoint(-94.70010376,37.08330154),"
Riverton Middle School
Box 260
Riverton, KS 66770

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Riverton Middle School",'Riverton=' + Riverton.length); Scammon[Scammon.length] = createMarker(new GPoint(-94.82505798,37.28096390),"
Scammon Elementary School
400 E. Katy Street
Scammon, KS 66773

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Scammon Elementary School",'Scammon=' + Scammon.length); Galena[Galena.length] = createMarker(new GPoint(-94.66827393,37.18201447),"
Spencer Elementary School
280 Ne 90th Street
Galena, KS 66739

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Spencer Elementary School",'Galena=' + Galena.length); Galena[Galena.length] = createMarker(new GPoint(-94.63697052,37.06286240),"
Spring Grove Primary Center
702 E. 7th Street
Galena, KS 66739

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Spring Grove Primary Center",'Galena=' + Galena.length); Weir[Weir.length] = createMarker(new GPoint(-94.72910309,37.29560089),"
Weir Elementary School
Box 308
Weir, KS 66781

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Weir Elementary School",'Weir=' + Weir.length); West_Mineral[West_Mineral.length] = createMarker(new GPoint(-94.92590332,37.28430176),"
West Mineral Elementary School
Box 90
West Mineral, KS 66782

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("West Mineral Elementary School",'West_Mineral=' + West_Mineral.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(Baxter_Springs); map.removeOverlays(Columbus); map.removeOverlays(Galena); map.removeOverlays(Riverton); map.removeOverlays(Scammon); map.removeOverlays(Weir); map.removeOverlays(West_Mineral); 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(Baxter_Springs);map.removeOverlays(Baxter_Springs); map.removeOverlays(Columbus); map.removeOverlays(Galena); map.removeOverlays(Riverton); map.removeOverlays(Scammon); map.removeOverlays(Weir); map.removeOverlays(West_Mineral); map.addOverlays(Baxter_Springs); centerByArray(Baxter_Springs, false, false); cntMarker += Baxter_Springs.length; map.addOverlays(Columbus); centerByArray(Columbus, false, false); cntMarker += Columbus.length; map.addOverlays(Galena); centerByArray(Galena, false, false); cntMarker += Galena.length; map.addOverlays(Riverton); centerByArray(Riverton, false, false); cntMarker += Riverton.length; map.addOverlays(Scammon); centerByArray(Scammon, false, false); cntMarker += Scammon.length; map.addOverlays(Weir); centerByArray(Weir, false, false); cntMarker += Weir.length; map.addOverlays(West_Mineral); centerByArray(West_Mineral, false, false); cntMarker += West_Mineral.length; centerByArray(Baxter_Springs,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'); } }