function addMarkers() { mySelect = document.getElementById('selection'); Cashion = [];Dover = [];Kingfisher = [];Hennessey = [];Loyal = [];Omega = [];Okarche = [];mySelect.options[mySelect.options.length] = new Option("Cashion schools",'all=Cashion'); mySelect.options[mySelect.options.length] = new Option("Dover schools",'all=Dover'); mySelect.options[mySelect.options.length] = new Option("Hennessey schools",'all=Hennessey'); mySelect.options[mySelect.options.length] = new Option("Kingfisher schools",'all=Kingfisher'); mySelect.options[mySelect.options.length] = new Option("Loyal schools",'all=Loyal'); mySelect.options[mySelect.options.length] = new Option("Okarche schools",'all=Okarche'); mySelect.options[mySelect.options.length] = new Option("Omega schools",'all=Omega'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Cashion[Cashion.length] = createMarker(new GPoint(-97.68090057,35.79740143),"
Cashion Elementary School
Po Box 100
Cashion, OK 73016

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Cashion Elementary School",'Cashion=' + Cashion.length); Cashion[Cashion.length] = createMarker(new GPoint(-97.68090057,35.79740143),"
Cashion High School
Po Box 100
Cashion, OK 73016

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Cashion High School",'Cashion=' + Cashion.length); Dover[Dover.length] = createMarker(new GPoint(-97.90859985,35.98089981),"
Dover Elementary School
Po Box 195
Dover, OK 73734

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Dover Elementary School",'Dover=' + Dover.length); Dover[Dover.length] = createMarker(new GPoint(-97.90190125,35.98709869),"
Dover High School
Po Box 195
Dover, OK 73734

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Dover High School",'Dover=' + Dover.length); Kingfisher[Kingfisher.length] = createMarker(new GPoint(-97.96890259,35.88290024),"
Gilmour Elementary School
Po Box 29
Kingfisher, OK 73750

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Gilmour Elementary School",'Kingfisher=' + Kingfisher.length); Hennessey[Hennessey.length] = createMarker(new GPoint(-97.88973236,36.10936356),"
Hennessey High School
707 E Oklahoma St
Hennessey, OK 73742

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Hennessey High School",'Hennessey=' + Hennessey.length); Hennessey[Hennessey.length] = createMarker(new GPoint(-97.89001465,36.10991287),"
Hennessey Lower Elementary School
130 N Mitchell Ave
Hennessey, OK 73742

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Hennessey Lower Elementary School",'Hennessey=' + Hennessey.length); Hennessey[Hennessey.length] = createMarker(new GPoint(-97.89001465,36.10982132),"
Hennessey Upper Elementary School
120 N Mitchell Ave
Hennessey, OK 73742

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Hennessey Upper Elementary School",'Hennessey=' + Hennessey.length); Kingfisher[Kingfisher.length] = createMarker(new GPoint(-97.96890259,35.88290024),"
Kingfisher High School
Po Box 29
Kingfisher, OK 73750

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Kingfisher High School",'Kingfisher=' + Kingfisher.length); Kingfisher[Kingfisher.length] = createMarker(new GPoint(-97.96890259,35.88290024),"
Kingfisher Middle School
Po Box 29
Kingfisher, OK 73750

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Kingfisher Middle School",'Kingfisher=' + Kingfisher.length); Loyal[Loyal.length] = createMarker(new GPoint(-98.11650085,35.97230148),"
Lomega Elementary School
Rr 1 Box 1
Loyal, OK 73756

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Lomega Elementary School",'Loyal=' + Loyal.length); Omega[Omega.length] = createMarker(new GPoint(-98.17220306,35.84960175),"
Lomega High School
Rr 1 Box 46
Omega, OK 73764

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Lomega High School",'Omega=' + Omega.length); Okarche[Okarche.length] = createMarker(new GPoint(-97.91950226,35.76079941),"
Okarche Elementary School
Po Box 276
Okarche, OK 73762

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Okarche Elementary School",'Okarche=' + Okarche.length); Okarche[Okarche.length] = createMarker(new GPoint(-97.91950226,35.76079941),"
Okarche High School
Po Box 276
Okarche, OK 73762

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Okarche High School",'Okarche=' + Okarche.length); Okarche[Okarche.length] = createMarker(new GPoint(-97.91950226,35.76079941),"
Okarche Junior High School
Po Box 276
Okarche, OK 73762

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Okarche Junior High School",'Okarche=' + Okarche.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(Cashion); map.removeOverlays(Dover); map.removeOverlays(Hennessey); map.removeOverlays(Kingfisher); map.removeOverlays(Loyal); map.removeOverlays(Okarche); map.removeOverlays(Omega); 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(Cashion);map.removeOverlays(Cashion); map.removeOverlays(Dover); map.removeOverlays(Hennessey); map.removeOverlays(Kingfisher); map.removeOverlays(Loyal); map.removeOverlays(Okarche); map.removeOverlays(Omega); map.addOverlays(Cashion); centerByArray(Cashion, false, false); cntMarker += Cashion.length; map.addOverlays(Dover); centerByArray(Dover, false, false); cntMarker += Dover.length; map.addOverlays(Hennessey); centerByArray(Hennessey, false, false); cntMarker += Hennessey.length; map.addOverlays(Kingfisher); centerByArray(Kingfisher, false, false); cntMarker += Kingfisher.length; map.addOverlays(Loyal); centerByArray(Loyal, false, false); cntMarker += Loyal.length; map.addOverlays(Okarche); centerByArray(Okarche, false, false); cntMarker += Okarche.length; map.addOverlays(Omega); centerByArray(Omega, false, false); cntMarker += Omega.length; centerByArray(Cashion,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'); } }