function addMarkers() { mySelect = document.getElementById('selection'); Norman = [];Oklahoma_City = [];Moore = [];Noble = [];Lexington = [];mySelect.options[mySelect.options.length] = new Option("Lexington schools",'all=Lexington'); mySelect.options[mySelect.options.length] = new Option("Moore schools",'all=Moore'); mySelect.options[mySelect.options.length] = new Option("Noble schools",'all=Noble'); mySelect.options[mySelect.options.length] = new Option("Norman schools",'all=Norman'); mySelect.options[mySelect.options.length] = new Option("Oklahoma City schools",'all=Oklahoma_City'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Norman[Norman.length] = createMarker(new GPoint(-97.45756531,35.22803879),"
",iconRd); mySelect.options[mySelect.options.length] = new Option("Adams Elementary School",'Norman=' + Norman.length); Norman[Norman.length] = createMarker(new GPoint(-97.46979523,35.21123886),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Alcott Middle School",'Norman=' + Norman.length); Oklahoma_City[Oklahoma_City.length] = createMarker(new GPoint(-97.47081757,35.32593536),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Apple Creek Elementary School",'Oklahoma_City=' + Oklahoma_City.length); Oklahoma_City[Oklahoma_City.length] = createMarker(new GPoint(-97.51947021,35.32039261),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Briarwood Elementary School",'Oklahoma_City=' + Oklahoma_City.length); Oklahoma_City[Oklahoma_City.length] = createMarker(new GPoint(-97.52983093,35.35426331),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Brink Junior High School",'Oklahoma_City=' + Oklahoma_City.length); Oklahoma_City[Oklahoma_City.length] = createMarker(new GPoint(-97.46925354,35.30551147),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Broadmoore Elementary School",'Oklahoma_City=' + Oklahoma_City.length); Oklahoma_City[Oklahoma_City.length] = createMarker(new GPoint(-97.45903015,35.37296295),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Bryant Elementary School",'Oklahoma_City=' + Oklahoma_City.length); Oklahoma_City[Oklahoma_City.length] = createMarker(new GPoint(-97.48718262,35.34063721),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Central Elementary School",'Oklahoma_City=' + Oklahoma_City.length); Moore[Moore.length] = createMarker(new GPoint(-97.48653412,35.34135437),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Central Junior High School",'Moore=' + Moore.length); Norman[Norman.length] = createMarker(new GPoint(-97.46796417,35.22443771),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Cleveland Elementary School",'Norman=' + Norman.length); Oklahoma_City[Oklahoma_City.length] = createMarker(new GPoint(-97.56513214,35.34066391),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Earlywine Elementary School",'Oklahoma_City=' + Oklahoma_City.length); Oklahoma_City[Oklahoma_City.length] = createMarker(new GPoint(-97.53887939,35.33423615),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Eastlake Elementary School",'Oklahoma_City=' + Oklahoma_City.length); Norman[Norman.length] = createMarker(new GPoint(-97.42015839,35.23903656),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Eisenhower Elementary School",'Norman=' + Norman.length); Oklahoma_City[Oklahoma_City.length] = createMarker(new GPoint(-97.55902863,35.35086823),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Fisher Elementary School",'Oklahoma_City=' + Oklahoma_City.length); Moore[Moore.length] = createMarker(new GPoint(-97.46923065,35.33406448),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Highland East Junior High School",'Moore=' + Moore.length); Moore[Moore.length] = createMarker(new GPoint(-97.51226807,35.34544373),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Highland West Junior High School",'Moore=' + Moore.length); Oklahoma_City[Oklahoma_City.length] = createMarker(new GPoint(-97.50762939,35.36723709),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Houchin Elementary School",'Oklahoma_City=' + Oklahoma_City.length); Norman[Norman.length] = createMarker(new GPoint(-97.41152954,35.21786880),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Irving Middle School",'Norman=' + Norman.length); Norman[Norman.length] = createMarker(new GPoint(-97.46347046,35.21353912),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Jackson Elementary School",'Norman=' + Norman.length); Norman[Norman.length] = createMarker(new GPoint(-97.43426514,35.22620392),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Jefferson Elementary School",'Norman=' + Norman.length); Noble[Noble.length] = createMarker(new GPoint(-97.38022614,35.13126373),"",iconRd); mySelect.options[mySelect.options.length] = new Option("John K. Hubbard Elementary School",'Noble=' + Noble.length); Noble[Noble.length] = createMarker(new GPoint(-97.39216614,35.13646317),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Katherine I. Daily Elementary School",'Noble=' + Noble.length); Oklahoma_City[Oklahoma_City.length] = createMarker(new GPoint(-97.50312805,35.35492706),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Kelly Elementary School",'Oklahoma_City=' + Oklahoma_City.length); Norman[Norman.length] = createMarker(new GPoint(-97.41963196,35.21056366),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Kennedy Elementary School",'Norman=' + Norman.length); Oklahoma_City[Oklahoma_City.length] = createMarker(new GPoint(-97.54169464,35.37006378),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Kingsgate Elementary School",'Oklahoma_City=' + Oklahoma_City.length); Norman[Norman.length] = createMarker(new GPoint(-97.28296661,35.25876999),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Lakeview Elementary School",'Norman=' + Norman.length); Norman[Norman.length] = createMarker(new GPoint(-97.42843628,35.22546387),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Leland Wolf Elementary School",'Norman=' + Norman.length); Norman[Norman.length] = createMarker(new GPoint(-97.42843628,35.22546387),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Leland Wolf High School (oyc)",'Norman=' + Norman.length); Lexington[Lexington.length] = createMarker(new GPoint(-97.32916260,35.01858139),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Lexington 5th Grade Center",'Lexington=' + Lexington.length); Lexington[Lexington.length] = createMarker(new GPoint(-97.32916260,35.01858139),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Lexington Elementary School",'Lexington=' + Lexington.length); Lexington[Lexington.length] = createMarker(new GPoint(-97.32916260,35.01858139),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Lexington High School",'Lexington=' + Lexington.length); Lexington[Lexington.length] = createMarker(new GPoint(-97.32916260,35.01858139),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Lexington Middle School",'Lexington=' + Lexington.length); Norman[Norman.length] = createMarker(new GPoint(-97.43623352,35.21515274),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Lincoln Elementary School",'Norman=' + Norman.length); Norman[Norman.length] = createMarker(new GPoint(-97.19456482,35.24183273),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Little Axe Elementary School",'Norman=' + Norman.length); Norman[Norman.length] = createMarker(new GPoint(-97.19456482,35.24183273),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Little Axe High School",'Norman=' + Norman.length); Norman[Norman.length] = createMarker(new GPoint(-97.19456482,35.24183273),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Little Axe Middle School",'Norman=' + Norman.length); Norman[Norman.length] = createMarker(new GPoint(-97.43839264,35.22449875),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Longfellow Middle School",'Norman=' + Norman.length); Norman[Norman.length] = createMarker(new GPoint(-97.43678284,35.19866562),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Madison Elementary School",'Norman=' + Norman.length); Norman[Norman.length] = createMarker(new GPoint(-97.45326996,35.20859909),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Mckinley Elementary School",'Norman=' + Norman.length); Norman[Norman.length] = createMarker(new GPoint(-97.46772766,35.19875717),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Monroe Elementary School",'Norman=' + Norman.length); Oklahoma_City[Oklahoma_City.length] = createMarker(new GPoint(-97.47663116,35.34055710),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Moore High School",'Oklahoma_City=' + Oklahoma_City.length); Noble[Noble.length] = createMarker(new GPoint(-97.37451172,35.14613724),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Noble High School",'Noble=' + Noble.length); Noble[Noble.length] = createMarker(new GPoint(-97.33090210,35.13809967),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Noble Middle School",'Noble=' + Noble.length); Norman[Norman.length] = createMarker(new GPoint(-97.45589447,35.21857071),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Norman High School",'Norman=' + Norman.length); Norman[Norman.length] = createMarker(new GPoint(-97.44982910,35.23988342),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Norman High School North",'Norman=' + Norman.length); Moore[Moore.length] = createMarker(new GPoint(-97.49105072,35.35464859),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Northmoor Elementary School",'Moore=' + Moore.length); Noble[Noble.length] = createMarker(new GPoint(-97.39048004,35.14073944),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Pioneer Ies Middle School",'Noble=' + Noble.length); Oklahoma_City[Oklahoma_City.length] = createMarker(new GPoint(-97.50555420,35.32646561),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Plaza Towers Elementary School",'Oklahoma_City=' + Oklahoma_City.length); Oklahoma_City[Oklahoma_City.length] = createMarker(new GPoint(-97.54743195,35.35523605),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Red Oak Elementary School",'Oklahoma_City=' + Oklahoma_City.length); Norman[Norman.length] = createMarker(new GPoint(-97.37061310,35.27633667),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Robin Hill Elementary School",'Norman=' + Norman.length); Norman[Norman.length] = createMarker(new GPoint(-97.50476837,35.26176453),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Roosevelt Elementary School",'Norman=' + Norman.length); Oklahoma_City[Oklahoma_City.length] = createMarker(new GPoint(-97.51210022,35.34019089),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Santa Fe Elementary School",'Oklahoma_City=' + Oklahoma_City.length); Oklahoma_City[Oklahoma_City.length] = createMarker(new GPoint(-97.31771088,35.36323547),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Schwartz Elementary School",'Oklahoma_City=' + Oklahoma_City.length); Oklahoma_City[Oklahoma_City.length] = createMarker(new GPoint(-97.53026581,35.37325668),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Sky Ranch Elementary School",'Oklahoma_City=' + Oklahoma_City.length); Oklahoma_City[Oklahoma_City.length] = createMarker(new GPoint(-97.42654419,35.37716293),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Sooner Elementary School",'Oklahoma_City=' + Oklahoma_City.length); Oklahoma_City[Oklahoma_City.length] = createMarker(new GPoint(-97.50492859,35.34115601),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Southgate-rippetoe Learning Ct",'Oklahoma_City=' + Oklahoma_City.length); Norman[Norman.length] = createMarker(new GPoint(-97.50177002,35.22594070),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Truman Elementary School",'Norman=' + Norman.length); Norman[Norman.length] = createMarker(new GPoint(-97.37070465,35.21163940),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Washington Elementary School",'Norman=' + Norman.length); Moore[Moore.length] = createMarker(new GPoint(-97.46479300,35.33420000),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Wayland Bonds Es",'Moore=' + Moore.length); Oklahoma_City[Oklahoma_City.length] = createMarker(new GPoint(-97.54763031,35.37334442),"",iconBl); mySelect.options[mySelect.options.length] = new Option("West Junior High School",'Oklahoma_City=' + Oklahoma_City.length); Oklahoma_City[Oklahoma_City.length] = createMarker(new GPoint(-97.53006744,35.34214020),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Westmoore High School",'Oklahoma_City=' + Oklahoma_City.length); Norman[Norman.length] = createMarker(new GPoint(-97.47110748,35.20746231),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Whittier Middle School",'Norman=' + Norman.length); Norman[Norman.length] = createMarker(new GPoint(-97.44466400,35.22784042),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Wilson Elementary School",'Norman=' + Norman.length); Moore[Moore.length] = createMarker(new GPoint(-97.46908569,35.34883881),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Winding Creek Elementary School",'Moore=' + Moore.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(Lexington); map.removeOverlays(Moore); map.removeOverlays(Noble); map.removeOverlays(Norman); map.removeOverlays(Oklahoma_City); 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(Norman);map.removeOverlays(Lexington); map.removeOverlays(Moore); map.removeOverlays(Noble); map.removeOverlays(Norman); map.removeOverlays(Oklahoma_City); map.addOverlays(Lexington); centerByArray(Lexington, false, false); cntMarker += Lexington.length; map.addOverlays(Moore); centerByArray(Moore, false, false); cntMarker += Moore.length; map.addOverlays(Noble); centerByArray(Noble, false, false); cntMarker += Noble.length; map.addOverlays(Norman); centerByArray(Norman, false, false); cntMarker += Norman.length; map.addOverlays(Oklahoma_City); centerByArray(Oklahoma_City, false, false); cntMarker += Oklahoma_City.length; centerByArray(Norman,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'); } }