function addMarkers() { mySelect = document.getElementById('selection'); Boswell = [];Fort_Towson = [];Hugo = [];Grant = [];Soper = [];Swink = [];mySelect.options[mySelect.options.length] = new Option("Boswell schools",'all=Boswell'); mySelect.options[mySelect.options.length] = new Option("Fort Towson schools",'all=Fort_Towson'); mySelect.options[mySelect.options.length] = new Option("Grant schools",'all=Grant'); mySelect.options[mySelect.options.length] = new Option("Hugo schools",'all=Hugo'); mySelect.options[mySelect.options.length] = new Option("Soper schools",'all=Soper'); mySelect.options[mySelect.options.length] = new Option("Swink schools",'all=Swink'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Boswell[Boswell.length] = createMarker(new GPoint(-95.84839630,34.03030014),"
Boswell Elementary School
Po Box 839
Boswell, OK 74727

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Boswell Elementary School",'Boswell=' + Boswell.length); Boswell[Boswell.length] = createMarker(new GPoint(-95.84839630,34.03030014),"
Boswell High School
Po Box 839
Boswell, OK 74727

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Boswell High School",'Boswell=' + Boswell.length); Boswell[Boswell.length] = createMarker(new GPoint(-95.84839630,34.03030014),"
Boswell Middle School
Po Box 839
Boswell, OK 74727

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Boswell Middle School",'Boswell=' + Boswell.length); Fort_Towson[Fort_Towson.length] = createMarker(new GPoint(-95.23439789,34.05339813),"
Fort Towson Elementary School
Po Box 39
Fort Towson, OK 74735

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Fort Towson Elementary School",'Fort_Towson=' + Fort_Towson.length); Fort_Towson[Fort_Towson.length] = createMarker(new GPoint(-95.23439789,34.05339813),"
Fort Towson High School
Po Box 39
Fort Towson, OK 74735

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Fort Towson High School",'Fort_Towson=' + Fort_Towson.length); Hugo[Hugo.length] = createMarker(new GPoint(-95.51260376,34.01300049),"
Goodland Elementary School
1218 N 4200 Rd
Hugo, OK 74743

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Goodland Elementary School",'Hugo=' + Hugo.length); Grant[Grant.length] = createMarker(new GPoint(-95.50119781,33.92610168),"
Grant Elementary School
Po Box 159
Grant, OK 74738

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Grant Elementary School",'Grant=' + Grant.length); Hugo[Hugo.length] = createMarker(new GPoint(-95.51143646,34.01108932),"
Hugo Elementary School
208 N 2nd St
Hugo, OK 74743

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Hugo Elementary School",'Hugo=' + Hugo.length); Hugo[Hugo.length] = createMarker(new GPoint(-95.51143646,34.01108932),"
Hugo High School
208 N 2nd St
Hugo, OK 74743

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Hugo High School",'Hugo=' + Hugo.length); Hugo[Hugo.length] = createMarker(new GPoint(-95.51143646,34.01108932),"
Hugo Intermediate School
208 N 2nd St
Hugo, OK 74743

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Hugo Intermediate School",'Hugo=' + Hugo.length); Hugo[Hugo.length] = createMarker(new GPoint(-95.51143646,34.01108932),"
Hugo Junior High School
208 N 2nd St
Hugo, OK 74743

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Hugo Junior High School",'Hugo=' + Hugo.length); Soper[Soper.length] = createMarker(new GPoint(-95.68759918,34.03219986),"
Soper Elementary School
Po Box 149
Soper, OK 74759

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Soper Elementary School",'Soper=' + Soper.length); Soper[Soper.length] = createMarker(new GPoint(-95.68759918,34.03219986),"
Soper High School
Po Box 149
Soper, OK 74759

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Soper High School",'Soper=' + Soper.length); Swink[Swink.length] = createMarker(new GPoint(-95.20279694,34.01699829),"
Swink Elementary School
Po Box 73
Swink, OK 74761

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Swink Elementary School",'Swink=' + Swink.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(Boswell); map.removeOverlays(Fort_Towson); map.removeOverlays(Grant); map.removeOverlays(Hugo); map.removeOverlays(Soper); map.removeOverlays(Swink); 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(Boswell);map.removeOverlays(Boswell); map.removeOverlays(Fort_Towson); map.removeOverlays(Grant); map.removeOverlays(Hugo); map.removeOverlays(Soper); map.removeOverlays(Swink); map.addOverlays(Boswell); centerByArray(Boswell, false, false); cntMarker += Boswell.length; map.addOverlays(Fort_Towson); centerByArray(Fort_Towson, false, false); cntMarker += Fort_Towson.length; map.addOverlays(Grant); centerByArray(Grant, false, false); cntMarker += Grant.length; map.addOverlays(Hugo); centerByArray(Hugo, false, false); cntMarker += Hugo.length; map.addOverlays(Soper); centerByArray(Soper, false, false); cntMarker += Soper.length; map.addOverlays(Swink); centerByArray(Swink, false, false); cntMarker += Swink.length; centerByArray(Boswell,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'); } }