function addMarkers() { mySelect = document.getElementById('selection'); Blanchard = [];Byars = [];Dibble = [];Newcastle = [];Purcell = [];Washington = [];Wayne = [];mySelect.options[mySelect.options.length] = new Option("Blanchard schools",'all=Blanchard'); mySelect.options[mySelect.options.length] = new Option("Byars schools",'all=Byars'); mySelect.options[mySelect.options.length] = new Option("Dibble schools",'all=Dibble'); mySelect.options[mySelect.options.length] = new Option("Newcastle schools",'all=Newcastle'); mySelect.options[mySelect.options.length] = new Option("Purcell schools",'all=Purcell'); mySelect.options[mySelect.options.length] = new Option("Washington schools",'all=Washington'); mySelect.options[mySelect.options.length] = new Option("Wayne schools",'all=Wayne'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Blanchard[Blanchard.length] = createMarker(new GPoint(-97.65443420,35.14003754),"
",iconRd); mySelect.options[mySelect.options.length] = new Option("Blanchard Elementary School",'Blanchard=' + Blanchard.length); Blanchard[Blanchard.length] = createMarker(new GPoint(-97.65443420,35.14003754),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Blanchard High School",'Blanchard=' + Blanchard.length); Blanchard[Blanchard.length] = createMarker(new GPoint(-97.65462500,35.13991300),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Blanchard Ies",'Blanchard=' + Blanchard.length); Blanchard[Blanchard.length] = createMarker(new GPoint(-97.65443420,35.14003754),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Blanchard Middle School",'Blanchard=' + Blanchard.length); Byars[Byars.length] = createMarker(new GPoint(-97.05310059,34.87649918),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Byars Elementary School",'Byars=' + Byars.length); Dibble[Dibble.length] = createMarker(new GPoint(-97.62940216,35.03329849),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Dibble Elementary School",'Dibble=' + Dibble.length); Dibble[Dibble.length] = createMarker(new GPoint(-97.62940216,35.03329849),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Dibble High School",'Dibble=' + Dibble.length); Dibble[Dibble.length] = createMarker(new GPoint(-97.62940216,35.03329849),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Dibble Middle School",'Dibble=' + Dibble.length); Newcastle[Newcastle.length] = createMarker(new GPoint(-97.60026550,35.24753952),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Newcastle Elementary School",'Newcastle=' + Newcastle.length); Newcastle[Newcastle.length] = createMarker(new GPoint(-97.60026550,35.24753952),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Newcastle High School",'Newcastle=' + Newcastle.length); Newcastle[Newcastle.length] = createMarker(new GPoint(-97.60026550,35.24753952),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Newcastle Middle School",'Newcastle=' + Newcastle.length); Purcell[Purcell.length] = createMarker(new GPoint(-97.37106323,35.02225876),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Purcell Elementary School",'Purcell=' + Purcell.length); Purcell[Purcell.length] = createMarker(new GPoint(-97.36412048,35.00569916),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Purcell High School",'Purcell=' + Purcell.length); Purcell[Purcell.length] = createMarker(new GPoint(-97.37106323,35.02360916),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Purcell Intermediate School",'Purcell=' + Purcell.length); Purcell[Purcell.length] = createMarker(new GPoint(-97.37088200,35.02104100),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Purcell Junior High School",'Purcell=' + Purcell.length); Washington[Washington.length] = createMarker(new GPoint(-97.47080231,35.11920166),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Washington Elementary School",'Washington=' + Washington.length); Washington[Washington.length] = createMarker(new GPoint(-97.47080231,35.11920166),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Washington High School",'Washington=' + Washington.length); Washington[Washington.length] = createMarker(new GPoint(-97.47080231,35.11920166),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Washington Middle School",'Washington=' + Washington.length); Wayne[Wayne.length] = createMarker(new GPoint(-97.32929993,34.90689850),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Wayne Elementary School",'Wayne=' + Wayne.length); Wayne[Wayne.length] = createMarker(new GPoint(-97.32929993,34.90689850),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Wayne High School",'Wayne=' + Wayne.length); Wayne[Wayne.length] = createMarker(new GPoint(-97.32929993,34.90689850),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Wayne Middle School",'Wayne=' + Wayne.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(Blanchard); map.removeOverlays(Byars); map.removeOverlays(Dibble); map.removeOverlays(Newcastle); map.removeOverlays(Purcell); map.removeOverlays(Washington); map.removeOverlays(Wayne); 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(Blanchard);map.removeOverlays(Blanchard); map.removeOverlays(Byars); map.removeOverlays(Dibble); map.removeOverlays(Newcastle); map.removeOverlays(Purcell); map.removeOverlays(Washington); map.removeOverlays(Wayne); map.addOverlays(Blanchard); centerByArray(Blanchard, false, false); cntMarker += Blanchard.length; map.addOverlays(Byars); centerByArray(Byars, false, false); cntMarker += Byars.length; map.addOverlays(Dibble); centerByArray(Dibble, false, false); cntMarker += Dibble.length; map.addOverlays(Newcastle); centerByArray(Newcastle, false, false); cntMarker += Newcastle.length; map.addOverlays(Purcell); centerByArray(Purcell, false, false); cntMarker += Purcell.length; map.addOverlays(Washington); centerByArray(Washington, false, false); cntMarker += Washington.length; map.addOverlays(Wayne); centerByArray(Wayne, false, false); cntMarker += Wayne.length; centerByArray(Blanchard,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'); } }