function addMarkers() { mySelect = document.getElementById('selection'); Tahlequah = [];Hulbert = [];Park_Hill = [];Peggs = [];Welling = [];mySelect.options[mySelect.options.length] = new Option("Hulbert schools",'all=Hulbert'); mySelect.options[mySelect.options.length] = new Option("Park Hill schools",'all=Park_Hill'); mySelect.options[mySelect.options.length] = new Option("Peggs schools",'all=Peggs'); mySelect.options[mySelect.options.length] = new Option("Tahlequah schools",'all=Tahlequah'); mySelect.options[mySelect.options.length] = new Option("Welling schools",'all=Welling'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Tahlequah[Tahlequah.length] = createMarker(new GPoint(-95.03769684,35.65100098),"
",iconRd); mySelect.options[mySelect.options.length] = new Option("Briggs Elementary School",'Tahlequah=' + Tahlequah.length); Tahlequah[Tahlequah.length] = createMarker(new GPoint(-94.97367859,35.91768646),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Central Elementary School",'Tahlequah=' + Tahlequah.length); Tahlequah[Tahlequah.length] = createMarker(new GPoint(-94.96041870,35.91736221),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Cherokee Elementary School",'Tahlequah=' + Tahlequah.length); Tahlequah[Tahlequah.length] = createMarker(new GPoint(-94.99359894,35.95077896),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Grand View Elementary School",'Tahlequah=' + Tahlequah.length); Tahlequah[Tahlequah.length] = createMarker(new GPoint(-94.96813202,35.90796280),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Greenwood Elementary School",'Tahlequah=' + Tahlequah.length); Hulbert[Hulbert.length] = createMarker(new GPoint(-95.18769836,35.91989899),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Hulbert Elementary School",'Hulbert=' + Hulbert.length); Hulbert[Hulbert.length] = createMarker(new GPoint(-95.14319400,35.93275000),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Hulbert Jr-sr High School",'Hulbert=' + Hulbert.length); Hulbert[Hulbert.length] = createMarker(new GPoint(-95.18769836,35.91989899),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Hulbert Junior Senior High School",'Hulbert=' + Hulbert.length); Park_Hill[Park_Hill.length] = createMarker(new GPoint(-94.96304321,35.79756546),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Keys Elementary School",'Park_Hill=' + Park_Hill.length); Park_Hill[Park_Hill.length] = createMarker(new GPoint(-94.96776581,35.79589844),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Keys High School",'Park_Hill=' + Park_Hill.length); Hulbert[Hulbert.length] = createMarker(new GPoint(-95.13490295,35.97480011),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Lost City Elementary School",'Hulbert=' + Hulbert.length); Tahlequah[Tahlequah.length] = createMarker(new GPoint(-94.99690247,35.72629929),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Lowrey Elementary School",'Tahlequah=' + Tahlequah.length); Hulbert[Hulbert.length] = createMarker(new GPoint(-95.16404724,35.87116241),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Norwood Elementary School",'Hulbert=' + Hulbert.length); Peggs[Peggs.length] = createMarker(new GPoint(-95.00559998,36.06380081),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Peggs Elementary School",'Peggs=' + Peggs.length); Tahlequah[Tahlequah.length] = createMarker(new GPoint(-94.97391510,35.91009903),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Sequoyah Elementary School",'Tahlequah=' + Tahlequah.length); Tahlequah[Tahlequah.length] = createMarker(new GPoint(-94.96970367,35.91519928),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Sequoyah High School",'Tahlequah=' + Tahlequah.length); Hulbert[Hulbert.length] = createMarker(new GPoint(-95.10044861,35.95896149),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Shady Grove Elementary School",'Hulbert=' + Hulbert.length); Tahlequah[Tahlequah.length] = createMarker(new GPoint(-94.97576904,35.92009735),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Tahlequah High School",'Tahlequah=' + Tahlequah.length); Tahlequah[Tahlequah.length] = createMarker(new GPoint(-94.97264900,35.91136000),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Tahlequah Jhs",'Tahlequah=' + Tahlequah.length); Tahlequah[Tahlequah.length] = createMarker(new GPoint(-94.97576904,35.91992569),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Tahlequah Junior High School",'Tahlequah=' + Tahlequah.length); Welling[Welling.length] = createMarker(new GPoint(-94.86889648,35.84640121),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Tenkiller Elementary School",'Welling=' + Welling.length); Tahlequah[Tahlequah.length] = createMarker(new GPoint(-95.07640076,35.80730057),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Woodall Elementary School",'Tahlequah=' + Tahlequah.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(Hulbert); map.removeOverlays(Park_Hill); map.removeOverlays(Peggs); map.removeOverlays(Tahlequah); map.removeOverlays(Welling); 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(Tahlequah);map.removeOverlays(Hulbert); map.removeOverlays(Park_Hill); map.removeOverlays(Peggs); map.removeOverlays(Tahlequah); map.removeOverlays(Welling); map.addOverlays(Hulbert); centerByArray(Hulbert, false, false); cntMarker += Hulbert.length; map.addOverlays(Park_Hill); centerByArray(Park_Hill, false, false); cntMarker += Park_Hill.length; map.addOverlays(Peggs); centerByArray(Peggs, false, false); cntMarker += Peggs.length; map.addOverlays(Tahlequah); centerByArray(Tahlequah, false, false); cntMarker += Tahlequah.length; map.addOverlays(Welling); centerByArray(Welling, false, false); cntMarker += Welling.length; centerByArray(Tahlequah,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'); } }