function addMarkers() { mySelect = document.getElementById('selection'); Alva = [];Ardmore = [];Edmond = [];Thomas = [];Oklahoma_City = [];Owasso = [];Ada = [];Guymon = [];Norman = [];Pryor = [];Claremore = [];Savanna = [];Shawnee = [];Ponca_City = [];mySelect.options[mySelect.options.length] = new Option("Ada schools",'all=Ada'); mySelect.options[mySelect.options.length] = new Option("Alva schools",'all=Alva'); mySelect.options[mySelect.options.length] = new Option("Ardmore schools",'all=Ardmore'); mySelect.options[mySelect.options.length] = new Option("Claremore schools",'all=Claremore'); mySelect.options[mySelect.options.length] = new Option("Edmond schools",'all=Edmond'); mySelect.options[mySelect.options.length] = new Option("Guymon schools",'all=Guymon'); 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("Owasso schools",'all=Owasso'); mySelect.options[mySelect.options.length] = new Option("Ponca City schools",'all=Ponca_City'); mySelect.options[mySelect.options.length] = new Option("Pryor schools",'all=Pryor'); mySelect.options[mySelect.options.length] = new Option("Savanna schools",'all=Savanna'); mySelect.options[mySelect.options.length] = new Option("Shawnee schools",'all=Shawnee'); mySelect.options[mySelect.options.length] = new Option("Thomas schools",'all=Thomas'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Alva[Alva.length] = createMarker(new GPoint(-98.67027283,36.80503845),"
",iconBl); mySelect.options[mySelect.options.length] = new Option("Alva Middle School",'Alva=' + Alva.length); Ardmore[Ardmore.length] = createMarker(new GPoint(-97.18299866,34.25880051),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Ardmore Middle School",'Ardmore=' + Ardmore.length); Edmond[Edmond.length] = createMarker(new GPoint(-97.50092316,35.68214035),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Cheyenne Middle School",'Edmond=' + Edmond.length); Thomas[Thomas.length] = createMarker(new GPoint(-98.73919678,35.73849869),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Custer Elementary School",'Thomas=' + Thomas.length); Edmond[Edmond.length] = createMarker(new GPoint(-97.62149811,35.68223190),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Deer Creek Middle School",'Edmond=' + Edmond.length); Ardmore[Ardmore.length] = createMarker(new GPoint(-97.07319641,34.18719864),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Dickson High School",'Ardmore=' + Ardmore.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); Owasso[Owasso.length] = createMarker(new GPoint(-95.85368347,36.28152084),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Hayward Smith Elementary School",'Owasso=' + Owasso.length); Ada[Ada.length] = createMarker(new GPoint(-96.67800140,34.77439880),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Homer Elementary School",'Ada=' + Ada.length); Guymon[Guymon.length] = createMarker(new GPoint(-101.46399689,36.73239899),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Homer Long Elementary School",'Guymon=' + Guymon.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); Pryor[Pryor.length] = createMarker(new GPoint(-95.31729889,36.30540085),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Lincoln Elementary School",'Pryor=' + Pryor.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.44982910,35.23988342),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Norman High School North",'Norman=' + Norman.length); Ardmore[Ardmore.length] = createMarker(new GPoint(-97.17803192,34.16148376),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Plainview High School",'Ardmore=' + Ardmore.length); Claremore[Claremore.length] = createMarker(new GPoint(-95.59706879,36.32822800),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Roosa Elementary School",'Claremore=' + Claremore.length); Edmond[Edmond.length] = createMarker(new GPoint(-97.47811890,35.65285873),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Russell Dougherty Elementary School",'Edmond=' + Edmond.length); Savanna[Savanna.length] = createMarker(new GPoint(-95.84359741,34.82880020),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Savanna Elementary School",'Savanna=' + Savanna.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); Shawnee[Shawnee.length] = createMarker(new GPoint(-96.92126465,35.37580490),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Shawnee Middle School",'Shawnee=' + Shawnee.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); Ponca_City[Ponca_City.length] = createMarker(new GPoint(-97.05863953,36.72038269),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Woodlands Elementary School",'Ponca_City=' + Ponca_City.length); map.removeOverlays(Ada); map.removeOverlays(Alva); map.removeOverlays(Ardmore); map.removeOverlays(Claremore); map.removeOverlays(Edmond); map.removeOverlays(Guymon); map.removeOverlays(Norman); map.removeOverlays(Oklahoma_City); map.removeOverlays(Owasso); map.removeOverlays(Ponca_City); map.removeOverlays(Pryor); map.removeOverlays(Savanna); map.removeOverlays(Shawnee); map.removeOverlays(Thomas); setTimeout(function(){map.addOverlays(Ada)},1000); setTimeout(function(){map.addOverlays(Alva)},1000); setTimeout(function(){map.addOverlays(Ardmore)},1000); setTimeout(function(){map.addOverlays(Claremore)},1000); setTimeout(function(){map.addOverlays(Edmond)},1000); setTimeout(function(){map.addOverlays(Guymon)},1000); setTimeout(function(){map.addOverlays(Norman)},1000); setTimeout(function(){map.addOverlays(Oklahoma_City)},1000); setTimeout(function(){map.addOverlays(Owasso)},1000); setTimeout(function(){map.addOverlays(Ponca_City)},1000); setTimeout(function(){map.addOverlays(Pryor)},1000); setTimeout(function(){map.addOverlays(Savanna)},1000); setTimeout(function(){map.addOverlays(Shawnee)},1000); setTimeout(function(){map.addOverlays(Thomas)},1000); maxLng = -95.31729889; maxLat = 36.80503845; minLng = -101.46399689; minLat = 34.16148376; reCenterMap(); } // 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(Ada); map.removeOverlays(Alva); map.removeOverlays(Ardmore); map.removeOverlays(Claremore); map.removeOverlays(Edmond); map.removeOverlays(Guymon); map.removeOverlays(Norman); map.removeOverlays(Oklahoma_City); map.removeOverlays(Owasso); map.removeOverlays(Ponca_City); map.removeOverlays(Pryor); map.removeOverlays(Savanna); map.removeOverlays(Shawnee); map.removeOverlays(Thomas); 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(Alva);map.removeOverlays(Ada); map.removeOverlays(Alva); map.removeOverlays(Ardmore); map.removeOverlays(Claremore); map.removeOverlays(Edmond); map.removeOverlays(Guymon); map.removeOverlays(Norman); map.removeOverlays(Oklahoma_City); map.removeOverlays(Owasso); map.removeOverlays(Ponca_City); map.removeOverlays(Pryor); map.removeOverlays(Savanna); map.removeOverlays(Shawnee); map.removeOverlays(Thomas); map.addOverlays(Ada); centerByArray(Ada, false, false); cntMarker += Ada.length; map.addOverlays(Alva); centerByArray(Alva, false, false); cntMarker += Alva.length; map.addOverlays(Ardmore); centerByArray(Ardmore, false, false); cntMarker += Ardmore.length; map.addOverlays(Claremore); centerByArray(Claremore, false, false); cntMarker += Claremore.length; map.addOverlays(Edmond); centerByArray(Edmond, false, false); cntMarker += Edmond.length; map.addOverlays(Guymon); centerByArray(Guymon, false, false); cntMarker += Guymon.length; map.addOverlays(Norman); centerByArray(Norman, false, false); cntMarker += Norman.length; map.addOverlays(Oklahoma_City); centerByArray(Oklahoma_City, false, false); cntMarker += Oklahoma_City.length; map.addOverlays(Owasso); centerByArray(Owasso, false, false); cntMarker += Owasso.length; map.addOverlays(Ponca_City); centerByArray(Ponca_City, false, false); cntMarker += Ponca_City.length; map.addOverlays(Pryor); centerByArray(Pryor, false, false); cntMarker += Pryor.length; map.addOverlays(Savanna); centerByArray(Savanna, false, false); cntMarker += Savanna.length; map.addOverlays(Shawnee); centerByArray(Shawnee, false, false); cntMarker += Shawnee.length; map.addOverlays(Thomas); centerByArray(Thomas, false, false); cntMarker += Thomas.length; centerByArray(Alva,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///65616,66444,66248,65243,65269,65672,65602,66150,66613,65196,65417,65515,65665,65807,66246,66239,66164,66119,66397,66463,66484,66588,/all'); } }