function addMarkers() { mySelect = document.getElementById('selection'); Adair = [];Chouteau = [];Pryor = [];Locust_Grove = [];Salina = [];Spavinaw = [];mySelect.options[mySelect.options.length] = new Option("Adair schools",'all=Adair'); mySelect.options[mySelect.options.length] = new Option("Chouteau schools",'all=Chouteau'); mySelect.options[mySelect.options.length] = new Option("Locust Grove schools",'all=Locust_Grove'); mySelect.options[mySelect.options.length] = new Option("Pryor schools",'all=Pryor'); mySelect.options[mySelect.options.length] = new Option("Salina schools",'all=Salina'); mySelect.options[mySelect.options.length] = new Option("Spavinaw schools",'all=Spavinaw'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Adair[Adair.length] = createMarker(new GPoint(-95.26439667,36.41120148),"
Adair High School
Po Box 197
Adair, OK 74330

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Adair High School",'Adair=' + Adair.length); Adair[Adair.length] = createMarker(new GPoint(-95.26439667,36.41120148),"
Adair Middle School
Po Box 197
Adair, OK 74330

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Adair Middle School",'Adair=' + Adair.length); Adair[Adair.length] = createMarker(new GPoint(-95.26439667,36.41120148),"
Bernita Hughes Elementary School
Po Box 197
Adair, OK 74330

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Bernita Hughes Elementary School",'Adair=' + Adair.length); Chouteau[Chouteau.length] = createMarker(new GPoint(-95.34049988,36.16419983),"
Chouteau Elementary School
Po Box 969
Chouteau, OK 74337

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Chouteau Elementary School",'Chouteau=' + Chouteau.length); Chouteau[Chouteau.length] = createMarker(new GPoint(-95.34049988,36.16419983),"
Chouteau-mazie High School
Po Box 969
Chouteau, OK 74337

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Chouteau-mazie High School",'Chouteau=' + Chouteau.length); Chouteau[Chouteau.length] = createMarker(new GPoint(-95.34049988,36.16419983),"
Chouteau-mazie Middle School
Po Box 969
Chouteau, OK 74337

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Chouteau-mazie Middle School",'Chouteau=' + Chouteau.length); Pryor[Pryor.length] = createMarker(new GPoint(-95.31729889,36.30540085),"
Jefferson Elementary School
Po Box 548
Pryor, OK 74362

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Jefferson Elementary School",'Pryor=' + Pryor.length); Pryor[Pryor.length] = createMarker(new GPoint(-95.31729889,36.30540085),"
Lincoln Elementary School
Po Box 548
Pryor, OK 74362

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Lincoln Elementary School",'Pryor=' + Pryor.length); Locust_Grove[Locust_Grove.length] = createMarker(new GPoint(-95.17070007,36.18180084),"
Locust Grove Early Lrning Center
Po Box 399
Locust Grove, OK 74352

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Locust Grove Early Lrning Center",'Locust_Grove=' + Locust_Grove.length); Locust_Grove[Locust_Grove.length] = createMarker(new GPoint(-95.17070007,36.18180084),"
Locust Grove High School
Po Box 399
Locust Grove, OK 74352

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Locust Grove High School",'Locust_Grove=' + Locust_Grove.length); Locust_Grove[Locust_Grove.length] = createMarker(new GPoint(-95.17070007,36.18180084),"
Locust Grove Middle School
Po Box 399
Locust Grove, OK 74352

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Locust Grove Middle School",'Locust_Grove=' + Locust_Grove.length); Locust_Grove[Locust_Grove.length] = createMarker(new GPoint(-95.17070007,36.18180084),"
Locust Grove Upper Elementary School
Po Box 399
Locust Grove, OK 74352

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Locust Grove Upper Elementary School",'Locust_Grove=' + Locust_Grove.length); Chouteau[Chouteau.length] = createMarker(new GPoint(-95.34049988,36.16419983),"
Mazie Elementary School
Po Box 969
Chouteau, OK 74337

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Mazie Elementary School",'Chouteau=' + Chouteau.length); Pryor[Pryor.length] = createMarker(new GPoint(-95.31729889,36.30540085),"
Osage Elementary School
Po Box 579
Pryor, OK 74362

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Osage Elementary School",'Pryor=' + Pryor.length); Pryor[Pryor.length] = createMarker(new GPoint(-95.31729889,36.30540085),"
Pryor High School
Po Box 548
Pryor, OK 74362

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Pryor High School",'Pryor=' + Pryor.length); Pryor[Pryor.length] = createMarker(new GPoint(-95.31729889,36.30540085),"
Pryor Junior High School
Po Box 548
Pryor, OK 74362

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Pryor Junior High School",'Pryor=' + Pryor.length); Pryor[Pryor.length] = createMarker(new GPoint(-95.31729889,36.30540085),"
Roosevelt Elementary School
Po Box 548
Pryor, OK 74362

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Roosevelt Elementary School",'Pryor=' + Pryor.length); Salina[Salina.length] = createMarker(new GPoint(-95.12010193,36.31290054),"
Salina Elementary School
Po Box 98
Salina, OK 74365

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Salina Elementary School",'Salina=' + Salina.length); Salina[Salina.length] = createMarker(new GPoint(-95.12010193,36.31290054),"
Salina High School
Po Box 98
Salina, OK 74365

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Salina High School",'Salina=' + Salina.length); Salina[Salina.length] = createMarker(new GPoint(-95.12010193,36.31290054),"
Salina Middle School
Po Box 98
Salina, OK 74365

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Salina Middle School",'Salina=' + Salina.length); Spavinaw[Spavinaw.length] = createMarker(new GPoint(-95.04270172,36.40029907),"
Spavinaw Elementary School
Po Box 108
Spavinaw, OK 74366

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Spavinaw Elementary School",'Spavinaw=' + Spavinaw.length); Pryor[Pryor.length] = createMarker(new GPoint(-95.31729889,36.30540085),"
Washington Elementary School
Po Box 548
Pryor, OK 74362

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Washington Elementary School",'Pryor=' + Pryor.length); Salina[Salina.length] = createMarker(new GPoint(-95.12010193,36.31290054),"
Wickliffe Elementary School
11176 E 470
Salina, OK 74365

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Wickliffe Elementary School",'Salina=' + Salina.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(Adair); map.removeOverlays(Chouteau); map.removeOverlays(Locust_Grove); map.removeOverlays(Pryor); map.removeOverlays(Salina); map.removeOverlays(Spavinaw); 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(Adair);map.removeOverlays(Adair); map.removeOverlays(Chouteau); map.removeOverlays(Locust_Grove); map.removeOverlays(Pryor); map.removeOverlays(Salina); map.removeOverlays(Spavinaw); map.addOverlays(Adair); centerByArray(Adair, false, false); cntMarker += Adair.length; map.addOverlays(Chouteau); centerByArray(Chouteau, false, false); cntMarker += Chouteau.length; map.addOverlays(Locust_Grove); centerByArray(Locust_Grove, false, false); cntMarker += Locust_Grove.length; map.addOverlays(Pryor); centerByArray(Pryor, false, false); cntMarker += Pryor.length; map.addOverlays(Salina); centerByArray(Salina, false, false); cntMarker += Salina.length; map.addOverlays(Spavinaw); centerByArray(Spavinaw, false, false); cntMarker += Spavinaw.length; centerByArray(Adair,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'); } }