function addMarkers() { mySelect = document.getElementById('selection'); Stilwell = [];Tulsa = [];Bunch = [];Watts = [];Westville = [];mySelect.options[mySelect.options.length] = new Option("Bunch schools",'all=Bunch'); mySelect.options[mySelect.options.length] = new Option("Stilwell schools",'all=Stilwell'); mySelect.options[mySelect.options.length] = new Option("Tulsa schools",'all=Tulsa'); mySelect.options[mySelect.options.length] = new Option("Watts schools",'all=Watts'); mySelect.options[mySelect.options.length] = new Option("Westville schools",'all=Westville'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Stilwell[Stilwell.length] = createMarker(new GPoint(-94.63279724,35.81330109),"
Bell Elementary School
Po Box 346
Stilwell, OK 74960

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Bell Elementary School",'Stilwell=' + Stilwell.length); Tulsa[Tulsa.length] = createMarker(new GPoint(-95.98567400,36.18511000),"
Booker T. Washington High School
1514 E Zion St
Tulsa, OK 74106

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Booker T. Washington High School",'Tulsa=' + Tulsa.length); Bunch[Bunch.length] = createMarker(new GPoint(-94.74030304,35.74449921),"
Cave Springs Elementary School
Po Box 200
Bunch, OK 74931

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Cave Springs Elementary School",'Bunch=' + Bunch.length); Bunch[Bunch.length] = createMarker(new GPoint(-94.74030304,35.74449921),"
Cave Springs High School
Po Box 200
Bunch, OK 74931

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Cave Springs High School",'Bunch=' + Bunch.length); Stilwell[Stilwell.length] = createMarker(new GPoint(-94.63279724,35.81330109),"
Dahlonegah Elementary School
Rr 1 Box 1795
Stilwell, OK 74960

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Dahlonegah Elementary School",'Stilwell=' + Stilwell.length); Stilwell[Stilwell.length] = createMarker(new GPoint(-94.63279724,35.81330109),"
Greasy Elementary School
Po Box 467
Stilwell, OK 74960

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Greasy Elementary School",'Stilwell=' + Stilwell.length); Stilwell[Stilwell.length] = createMarker(new GPoint(-94.63279724,35.81330109),"
Maryetta Elementary School
Rr 6 Box 2840
Stilwell, OK 74960

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Maryetta Elementary School",'Stilwell=' + Stilwell.length); Stilwell[Stilwell.length] = createMarker(new GPoint(-94.63279724,35.81330109),"
Peavine Elementary School
Po Box 389
Stilwell, OK 74960

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Peavine Elementary School",'Stilwell=' + Stilwell.length); Stilwell[Stilwell.length] = createMarker(new GPoint(-94.63279724,35.81330109),"
Rocky Mountain Elementary School
Rr 1 Box 665
Stilwell, OK 74960

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Rocky Mountain Elementary School",'Stilwell=' + Stilwell.length); Watts[Watts.length] = createMarker(new GPoint(-94.68659973,36.11790085),"
Skelly Elementary School
Rr 1 Box 918
Watts, OK 74964

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Skelly Elementary School",'Watts=' + Watts.length); Stilwell[Stilwell.length] = createMarker(new GPoint(-94.63317108,35.81497574),"
Stilwell Elementary School
10 S 6th St
Stilwell, OK 74960

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Stilwell Elementary School",'Stilwell=' + Stilwell.length); Stilwell[Stilwell.length] = createMarker(new GPoint(-94.65224457,35.80853653),"
Stilwell High School
1801 W Locust St
Stilwell, OK 74960

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Stilwell High School",'Stilwell=' + Stilwell.length); Stilwell[Stilwell.length] = createMarker(new GPoint(-94.63409424,35.81654358),"
Stilwell Middle School
12 N 7th St
Stilwell, OK 74960

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Stilwell Middle School",'Stilwell=' + Stilwell.length); Watts[Watts.length] = createMarker(new GPoint(-94.68659973,36.11790085),"
Watts Elementary School
Rr 2 Box 1
Watts, OK 74964

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Watts Elementary School",'Watts=' + Watts.length); Watts[Watts.length] = createMarker(new GPoint(-94.68659973,36.11790085),"
Watts High School
Rr 2 Box 1
Watts, OK 74964

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Watts High School",'Watts=' + Watts.length); Westville[Westville.length] = createMarker(new GPoint(-94.59619904,35.99819946),"
Westville Elementary School
Po Box 410
Westville, OK 74965

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Westville Elementary School",'Westville=' + Westville.length); Westville[Westville.length] = createMarker(new GPoint(-94.59619904,35.99819946),"
Westville High School
Po Box 410
Westville, OK 74965

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Westville High School",'Westville=' + Westville.length); Westville[Westville.length] = createMarker(new GPoint(-94.59619904,35.99819946),"
Westville Junior High School
Po Box 410
Westville, OK 74965

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Westville Junior High School",'Westville=' + Westville.length); Stilwell[Stilwell.length] = createMarker(new GPoint(-94.63279724,35.81330109),"
Zion Elementary School
Po Box 347
Stilwell, OK 74960

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Zion Elementary School",'Stilwell=' + Stilwell.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(Bunch); map.removeOverlays(Stilwell); map.removeOverlays(Tulsa); map.removeOverlays(Watts); map.removeOverlays(Westville); 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(Stilwell);map.removeOverlays(Bunch); map.removeOverlays(Stilwell); map.removeOverlays(Tulsa); map.removeOverlays(Watts); map.removeOverlays(Westville); map.addOverlays(Bunch); centerByArray(Bunch, false, false); cntMarker += Bunch.length; map.addOverlays(Stilwell); centerByArray(Stilwell, false, false); cntMarker += Stilwell.length; map.addOverlays(Tulsa); centerByArray(Tulsa, false, false); cntMarker += Tulsa.length; map.addOverlays(Watts); centerByArray(Watts, false, false); cntMarker += Watts.length; map.addOverlays(Westville); centerByArray(Westville, false, false); cntMarker += Westville.length; centerByArray(Stilwell,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'); } }