function addMarkers() { mySelect = document.getElementById('selection'); Lawton = [];Cache = [];Chattanooga = [];Elgin = [];Fletcher = [];Geronimo = [];Fort_Sill = [];Indiahoma = [];Sterling = [];mySelect.options[mySelect.options.length] = new Option("Cache schools",'all=Cache'); mySelect.options[mySelect.options.length] = new Option("Chattanooga schools",'all=Chattanooga'); mySelect.options[mySelect.options.length] = new Option("Elgin schools",'all=Elgin'); mySelect.options[mySelect.options.length] = new Option("Fletcher schools",'all=Fletcher'); mySelect.options[mySelect.options.length] = new Option("Fort Sill schools",'all=Fort_Sill'); mySelect.options[mySelect.options.length] = new Option("Geronimo schools",'all=Geronimo'); mySelect.options[mySelect.options.length] = new Option("Indiahoma schools",'all=Indiahoma'); mySelect.options[mySelect.options.length] = new Option("Lawton schools",'all=Lawton'); mySelect.options[mySelect.options.length] = new Option("Sterling schools",'all=Sterling'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Lawton[Lawton.length] = createMarker(new GPoint(-98.43490601,34.61673737),"
",iconRd); mySelect.options[mySelect.options.length] = new Option("Adams Elementary School",'Lawton=' + Lawton.length); Lawton[Lawton.length] = createMarker(new GPoint(-98.47787476,34.60547638),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Almor West Elementary School",'Lawton=' + Lawton.length); Lawton[Lawton.length] = createMarker(new GPoint(-98.42144012,34.57976151),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Bishop Elementary School",'Lawton=' + Lawton.length); Lawton[Lawton.length] = createMarker(new GPoint(-98.46783447,34.61683655),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Brockland Elementary School",'Lawton=' + Lawton.length); Cache[Cache.length] = createMarker(new GPoint(-98.62511444,34.62373734),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Cache High School",'Cache=' + Cache.length); Cache[Cache.length] = createMarker(new GPoint(-98.62511444,34.62373734),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Cache Ies Elementary School",'Cache=' + Cache.length); Cache[Cache.length] = createMarker(new GPoint(-98.62511444,34.62373734),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Cache Middle School",'Cache=' + Cache.length); Cache[Cache.length] = createMarker(new GPoint(-98.62511444,34.62373734),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Cache Primary Elementary School",'Cache=' + Cache.length); Lawton[Lawton.length] = createMarker(new GPoint(-98.34342194,34.60556412),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Carriage Hills Elementary School",'Lawton=' + Lawton.length); Lawton[Lawton.length] = createMarker(new GPoint(-98.40017700,34.60543823),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Central Junior High School",'Lawton=' + Lawton.length); Chattanooga[Chattanooga.length] = createMarker(new GPoint(-98.64849854,34.43130112),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Chattanooga Elementary School",'Chattanooga=' + Chattanooga.length); Chattanooga[Chattanooga.length] = createMarker(new GPoint(-98.64849854,34.43130112),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Chattanooga High School",'Chattanooga=' + Chattanooga.length); Lawton[Lawton.length] = createMarker(new GPoint(-98.43083191,34.59783173),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Cleveland Elementary School",'Lawton=' + Lawton.length); Lawton[Lawton.length] = createMarker(new GPoint(-98.45045471,34.60022736),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Country Club Heights Elementary School",'Lawton=' + Lawton.length); Lawton[Lawton.length] = createMarker(new GPoint(-98.46715546,34.62680054),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Crosby Park Elementary School",'Lawton=' + Lawton.length); Lawton[Lawton.length] = createMarker(new GPoint(-98.38610077,34.60903549),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Douglass Learning Center",'Lawton=' + Lawton.length); Lawton[Lawton.length] = createMarker(new GPoint(-98.46718597,34.61179733),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Edison Elementary School",'Lawton=' + Lawton.length); Lawton[Lawton.length] = createMarker(new GPoint(-98.45746613,34.60558319),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Eisenhower Elementary School",'Lawton=' + Lawton.length); Lawton[Lawton.length] = createMarker(new GPoint(-98.45787048,34.60876465),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Eisenhower High School",'Lawton=' + Lawton.length); Lawton[Lawton.length] = createMarker(new GPoint(-98.46207428,34.60876465),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Eisenhower Junior High School",'Lawton=' + Lawton.length); Elgin[Elgin.length] = createMarker(new GPoint(-98.39240265,34.78060150),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Elgin Elementary School",'Elgin=' + Elgin.length); Elgin[Elgin.length] = createMarker(new GPoint(-98.39240265,34.78060150),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Elgin High School",'Elgin=' + Elgin.length); Elgin[Elgin.length] = createMarker(new GPoint(-98.39240265,34.78060150),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Elgin Middle School",'Elgin=' + Elgin.length); Fletcher[Fletcher.length] = createMarker(new GPoint(-98.20110321,34.78779984),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Fletcher Elementary School",'Fletcher=' + Fletcher.length); Fletcher[Fletcher.length] = createMarker(new GPoint(-98.20110321,34.78779984),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Fletcher High School",'Fletcher=' + Fletcher.length); Fletcher[Fletcher.length] = createMarker(new GPoint(-98.20110321,34.78779984),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Fletcher Junior High School",'Fletcher=' + Fletcher.length); Lawton[Lawton.length] = createMarker(new GPoint(-98.35238647,34.57883072),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Flower Mound Elementary School",'Lawton=' + Lawton.length); Lawton[Lawton.length] = createMarker(new GPoint(-98.42692566,34.61249542),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Garfield Elementary School",'Lawton=' + Lawton.length); Geronimo[Geronimo.length] = createMarker(new GPoint(-98.39469910,34.48350143),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Geronimo Elementary School",'Geronimo=' + Geronimo.length); Geronimo[Geronimo.length] = createMarker(new GPoint(-98.39469910,34.48350143),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Geronimo High School",'Geronimo=' + Geronimo.length); Fort_Sill[Fort_Sill.length] = createMarker(new GPoint(-98.39041138,34.66486740),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Geronimo Road Elementary School",'Fort_Sill=' + Fort_Sill.length); Lawton[Lawton.length] = createMarker(new GPoint(-98.45036316,34.62853622),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Hoover Elementary School",'Lawton=' + Lawton.length); Lawton[Lawton.length] = createMarker(new GPoint(-98.42578888,34.60326385),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Howell Elementary School",'Lawton=' + Lawton.length); Lawton[Lawton.length] = createMarker(new GPoint(-98.46335602,34.63323593),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Hugh Bish Elementary School",'Lawton=' + Lawton.length); Indiahoma[Indiahoma.length] = createMarker(new GPoint(-98.74790192,34.61100006),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Indiahoma Elementary School",'Indiahoma=' + Indiahoma.length); Indiahoma[Indiahoma.length] = createMarker(new GPoint(-98.74790192,34.61100006),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Indiahoma High School",'Indiahoma=' + Indiahoma.length); Lawton[Lawton.length] = createMarker(new GPoint(-98.42269897,34.63556671),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Jackson Elementary School",'Lawton=' + Lawton.length); Lawton[Lawton.length] = createMarker(new GPoint(-98.40453339,34.61514664),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Lawton High School",'Lawton=' + Lawton.length); Lawton[Lawton.length] = createMarker(new GPoint(-98.39344788,34.63370132),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Lee Ec Center",'Lawton=' + Lawton.length); Lawton[Lawton.length] = createMarker(new GPoint(-98.39698029,34.59653854),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Lincoln Elementary School",'Lawton=' + Lawton.length); Lawton[Lawton.length] = createMarker(new GPoint(-98.33458710,34.60883713),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Macarthur High School",'Lawton=' + Lawton.length); Lawton[Lawton.length] = createMarker(new GPoint(-98.33486938,34.61474228),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Macarthur Junior High School",'Lawton=' + Lawton.length); Lawton[Lawton.length] = createMarker(new GPoint(-98.32967377,34.58862305),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Park Lane Elementary School",'Lawton=' + Lawton.length); Lawton[Lawton.length] = createMarker(new GPoint(-98.41017914,34.63343811),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Pat Henry Elementary School",'Lawton=' + Lawton.length); Lawton[Lawton.length] = createMarker(new GPoint(-98.38063049,34.63801575),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Pioneer Park Elementary School",'Lawton=' + Lawton.length); Fort_Sill[Fort_Sill.length] = createMarker(new GPoint(-98.42223358,34.64306259),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Sheridan Road Elementary School",'Fort_Sill=' + Fort_Sill.length); Sterling[Sterling.length] = createMarker(new GPoint(-98.16940308,34.74990082),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Sterling Elementary School",'Sterling=' + Sterling.length); Sterling[Sterling.length] = createMarker(new GPoint(-98.17130280,34.75019836),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Sterling High School",'Sterling=' + Sterling.length); Lawton[Lawton.length] = createMarker(new GPoint(-98.34279633,34.59983826),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Sullivan Village Elementary School",'Lawton=' + Lawton.length); Lawton[Lawton.length] = createMarker(new GPoint(-98.42523193,34.62475204),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Swinney Elementary School",'Lawton=' + Lawton.length); Lawton[Lawton.length] = createMarker(new GPoint(-98.42748260,34.61594391),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Tomlinson Junior High School",'Lawton=' + Lawton.length); Lawton[Lawton.length] = createMarker(new GPoint(-98.40023041,34.61273575),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Washington Elementary School",'Lawton=' + Lawton.length); Lawton[Lawton.length] = createMarker(new GPoint(-98.46012115,34.62027740),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Western Hills Elementary School",'Lawton=' + Lawton.length); Lawton[Lawton.length] = createMarker(new GPoint(-98.43996429,34.62903595),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Westwood Elementary School",'Lawton=' + Lawton.length); Lawton[Lawton.length] = createMarker(new GPoint(-98.41008759,34.62062073),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Whittier Elementary School",'Lawton=' + Lawton.length); Lawton[Lawton.length] = createMarker(new GPoint(-98.40142822,34.58990479),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Will Rogers Elementary School",'Lawton=' + Lawton.length); Lawton[Lawton.length] = createMarker(new GPoint(-98.41376495,34.61005402),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Wilson Elementary School",'Lawton=' + Lawton.length); Lawton[Lawton.length] = createMarker(new GPoint(-98.47756958,34.61552048),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Woodland Hills Elementary School",'Lawton=' + Lawton.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(Cache); map.removeOverlays(Chattanooga); map.removeOverlays(Elgin); map.removeOverlays(Fletcher); map.removeOverlays(Fort_Sill); map.removeOverlays(Geronimo); map.removeOverlays(Indiahoma); map.removeOverlays(Lawton); map.removeOverlays(Sterling); 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(Lawton);map.removeOverlays(Cache); map.removeOverlays(Chattanooga); map.removeOverlays(Elgin); map.removeOverlays(Fletcher); map.removeOverlays(Fort_Sill); map.removeOverlays(Geronimo); map.removeOverlays(Indiahoma); map.removeOverlays(Lawton); map.removeOverlays(Sterling); map.addOverlays(Cache); centerByArray(Cache, false, false); cntMarker += Cache.length; map.addOverlays(Chattanooga); centerByArray(Chattanooga, false, false); cntMarker += Chattanooga.length; map.addOverlays(Elgin); centerByArray(Elgin, false, false); cntMarker += Elgin.length; map.addOverlays(Fletcher); centerByArray(Fletcher, false, false); cntMarker += Fletcher.length; map.addOverlays(Fort_Sill); centerByArray(Fort_Sill, false, false); cntMarker += Fort_Sill.length; map.addOverlays(Geronimo); centerByArray(Geronimo, false, false); cntMarker += Geronimo.length; map.addOverlays(Indiahoma); centerByArray(Indiahoma, false, false); cntMarker += Indiahoma.length; map.addOverlays(Lawton); centerByArray(Lawton, false, false); cntMarker += Lawton.length; map.addOverlays(Sterling); centerByArray(Sterling, false, false); cntMarker += Sterling.length; centerByArray(Lawton,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'); } }