function addMarkers() { mySelect = document.getElementById('selection'); Blackwell = [];Braman = [];Ponca_City = [];Kaw_City = [];Newkirk = [];Tonkawa = [];mySelect.options[mySelect.options.length] = new Option("Blackwell schools",'all=Blackwell'); mySelect.options[mySelect.options.length] = new Option("Braman schools",'all=Braman'); mySelect.options[mySelect.options.length] = new Option("Kaw City schools",'all=Kaw_City'); mySelect.options[mySelect.options.length] = new Option("Newkirk schools",'all=Newkirk'); mySelect.options[mySelect.options.length] = new Option("Ponca City schools",'all=Ponca_City'); mySelect.options[mySelect.options.length] = new Option("Tonkawa schools",'all=Tonkawa'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Blackwell[Blackwell.length] = createMarker(new GPoint(-97.27971649,36.78956223),"
",iconGr); mySelect.options[mySelect.options.length] = new Option("Blackwell High School",'Blackwell=' + Blackwell.length); Blackwell[Blackwell.length] = createMarker(new GPoint(-97.28446960,36.79278946),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Blackwell Middle School",'Blackwell=' + Blackwell.length); Braman[Braman.length] = createMarker(new GPoint(-97.31449890,36.93870163),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Braman Elementary School",'Braman=' + Braman.length); Braman[Braman.length] = createMarker(new GPoint(-97.31449890,36.93870163),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Braman High School",'Braman=' + Braman.length); Ponca_City[Ponca_City.length] = createMarker(new GPoint(-97.05714417,36.73863602),"",iconRd); mySelect.options[mySelect.options.length] = new Option("E. M. Trout Elementary School",'Ponca_City=' + Ponca_City.length); Ponca_City[Ponca_City.length] = createMarker(new GPoint(-97.07612610,36.69805527),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Garfield Academy",'Ponca_City=' + Ponca_City.length); Blackwell[Blackwell.length] = createMarker(new GPoint(-97.28670502,36.78643799),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Huston Center Elementary School",'Blackwell=' + Blackwell.length); Kaw_City[Kaw_City.length] = createMarker(new GPoint(-96.86569977,36.81000137),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Kaw City Elementary School",'Kaw_City=' + Kaw_City.length); Ponca_City[Ponca_City.length] = createMarker(new GPoint(-97.04912567,36.80608749),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Kildare Elementary School",'Ponca_City=' + Ponca_City.length); Ponca_City[Ponca_City.length] = createMarker(new GPoint(-97.08795166,36.71713638),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Liberty Elementary School",'Ponca_City=' + Ponca_City.length); Ponca_City[Ponca_City.length] = createMarker(new GPoint(-97.10026550,36.70409775),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Lincoln Elementary School",'Ponca_City=' + Ponca_City.length); Newkirk[Newkirk.length] = createMarker(new GPoint(-97.05220032,36.89849854),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Newkirk Elementary School",'Newkirk=' + Newkirk.length); Newkirk[Newkirk.length] = createMarker(new GPoint(-97.05220032,36.89849854),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Newkirk High School",'Newkirk=' + Newkirk.length); Newkirk[Newkirk.length] = createMarker(new GPoint(-97.05220032,36.89849854),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Newkirk Middle School",'Newkirk=' + Newkirk.length); Blackwell[Blackwell.length] = createMarker(new GPoint(-97.27661133,36.80143738),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Parkside Center Elementary School",'Blackwell=' + Blackwell.length); Newkirk[Newkirk.length] = createMarker(new GPoint(-97.17649841,36.88560104),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Peckham Elementary School",'Newkirk=' + Newkirk.length); Ponca_City[Ponca_City.length] = createMarker(new GPoint(-97.07701111,36.70336151),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Ponca City East MiddleSchool",'Ponca_City=' + Ponca_City.length); Ponca_City[Ponca_City.length] = createMarker(new GPoint(-97.07817841,36.71380997),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Ponca City High School",'Ponca_City=' + Ponca_City.length); Ponca_City[Ponca_City.length] = createMarker(new GPoint(-97.09830475,36.70413589),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Ponca City West Middle School",'Ponca_City=' + Ponca_City.length); Ponca_City[Ponca_City.length] = createMarker(new GPoint(-97.07418060,36.70973587),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Roosevelt Elementary School",'Ponca_City=' + Ponca_City.length); Tonkawa[Tonkawa.length] = createMarker(new GPoint(-97.31800079,36.67770004),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Tonkawa Elementary School",'Tonkawa=' + Tonkawa.length); Tonkawa[Tonkawa.length] = createMarker(new GPoint(-97.31800079,36.67770004),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Tonkawa High School",'Tonkawa=' + Tonkawa.length); Tonkawa[Tonkawa.length] = createMarker(new GPoint(-97.31800079,36.67770004),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Tonkawa Middle School",'Tonkawa=' + Tonkawa.length); Ponca_City[Ponca_City.length] = createMarker(new GPoint(-97.08502960,36.73461533),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Union Elementary School",'Ponca_City=' + Ponca_City.length); Blackwell[Blackwell.length] = createMarker(new GPoint(-97.29239655,36.80116272),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Washington Center Elementary School",'Blackwell=' + Blackwell.length); Ponca_City[Ponca_City.length] = createMarker(new GPoint(-97.07563019,36.72195053),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Washington Elementary School",'Ponca_City=' + Ponca_City.length); Ponca_City[Ponca_City.length] = createMarker(new GPoint(-97.05863953,36.72038269),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Woodlands Elementary School",'Ponca_City=' + Ponca_City.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(Blackwell); map.removeOverlays(Braman); map.removeOverlays(Kaw_City); map.removeOverlays(Newkirk); map.removeOverlays(Ponca_City); map.removeOverlays(Tonkawa); 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(Blackwell);map.removeOverlays(Blackwell); map.removeOverlays(Braman); map.removeOverlays(Kaw_City); map.removeOverlays(Newkirk); map.removeOverlays(Ponca_City); map.removeOverlays(Tonkawa); map.addOverlays(Blackwell); centerByArray(Blackwell, false, false); cntMarker += Blackwell.length; map.addOverlays(Braman); centerByArray(Braman, false, false); cntMarker += Braman.length; map.addOverlays(Kaw_City); centerByArray(Kaw_City, false, false); cntMarker += Kaw_City.length; map.addOverlays(Newkirk); centerByArray(Newkirk, false, false); cntMarker += Newkirk.length; map.addOverlays(Ponca_City); centerByArray(Ponca_City, false, false); cntMarker += Ponca_City.length; map.addOverlays(Tonkawa); centerByArray(Tonkawa, false, false); cntMarker += Tonkawa.length; centerByArray(Blackwell,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'); } }