function addMarkers() { mySelect = document.getElementById('selection'); Burrton = [];Newton = [];Halstead = [];Hesston = [];Sedgwick = [];Walton = [];mySelect.options[mySelect.options.length] = new Option("Burrton schools",'all=Burrton'); mySelect.options[mySelect.options.length] = new Option("Halstead schools",'all=Halstead'); mySelect.options[mySelect.options.length] = new Option("Hesston schools",'all=Hesston'); mySelect.options[mySelect.options.length] = new Option("Newton schools",'all=Newton'); mySelect.options[mySelect.options.length] = new Option("Sedgwick schools",'all=Sedgwick'); mySelect.options[mySelect.options.length] = new Option("Walton schools",'all=Walton'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Burrton[Burrton.length] = createMarker(new GPoint(-97.66410065,38.02379990),"
",iconRd); mySelect.options[mySelect.options.length] = new Option("Burrton Elementary School",'Burrton=' + Burrton.length); Burrton[Burrton.length] = createMarker(new GPoint(-97.66410065,38.02379990),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Burrton High School",'Burrton=' + Burrton.length); Newton[Newton.length] = createMarker(new GPoint(-97.33107758,38.04264832),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Chisholm Middle School",'Newton=' + Newton.length); Newton[Newton.length] = createMarker(new GPoint(-97.34513400,38.05286000),"",iconGr); mySelect.options[mySelect.options.length] = new Option("E3 (entrepreheniel Ed. Enterprise)",'Newton=' + Newton.length); Newton[Newton.length] = createMarker(new GPoint(-97.36096954,38.05023575),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Eby Learning Center I",'Newton=' + Newton.length); Newton[Newton.length] = createMarker(new GPoint(-97.36096954,38.05023575),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Eby Learning Center Ii",'Newton=' + Newton.length); Halstead[Halstead.length] = createMarker(new GPoint(-97.51208496,37.99953842),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Halstead High School",'Halstead=' + Halstead.length); Halstead[Halstead.length] = createMarker(new GPoint(-97.50789642,37.99936295),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Halstead Middle School",'Halstead=' + Halstead.length); Hesston[Hesston.length] = createMarker(new GPoint(-97.45230103,38.13729858),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Hesston Elementary School",'Hesston=' + Hesston.length); Hesston[Hesston.length] = createMarker(new GPoint(-97.45230103,38.13729858),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Hesston High School",'Hesston=' + Hesston.length); Hesston[Hesston.length] = createMarker(new GPoint(-97.45230103,38.13729858),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Hesston Middle School",'Hesston=' + Hesston.length); Newton[Newton.length] = createMarker(new GPoint(-97.36005402,38.05714035),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Newton Senior High School",'Newton=' + Newton.length); Newton[Newton.length] = createMarker(new GPoint(-97.34775543,38.06433487),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Northridge Elementary School",'Newton=' + Newton.length); Sedgwick[Sedgwick.length] = createMarker(new GPoint(-97.46869659,37.92490005),"",iconRd); mySelect.options[mySelect.options.length] = new Option("R L Wright Elementary School",'Sedgwick=' + Sedgwick.length); Newton[Newton.length] = createMarker(new GPoint(-97.34572601,38.04973984),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Santa Fe Middle School",'Newton=' + Newton.length); Sedgwick[Sedgwick.length] = createMarker(new GPoint(-97.46869659,37.92490005),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Sedgwick High School",'Sedgwick=' + Sedgwick.length); Newton[Newton.length] = createMarker(new GPoint(-97.33056641,38.04618835),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Slate Creek Elementary School",'Newton=' + Newton.length); Newton[Newton.length] = createMarker(new GPoint(-97.34574127,38.03186417),"",iconRd); mySelect.options[mySelect.options.length] = new Option("South Breeze Elementary School",'Newton=' + Newton.length); Newton[Newton.length] = createMarker(new GPoint(-97.36317444,38.04876709),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Sunset Elementary School",'Newton=' + Newton.length); Walton[Walton.length] = createMarker(new GPoint(-97.23539734,38.13019943),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Walton Elementary School",'Walton=' + Walton.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(Burrton); map.removeOverlays(Halstead); map.removeOverlays(Hesston); map.removeOverlays(Newton); map.removeOverlays(Sedgwick); map.removeOverlays(Walton); 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(Burrton);map.removeOverlays(Burrton); map.removeOverlays(Halstead); map.removeOverlays(Hesston); map.removeOverlays(Newton); map.removeOverlays(Sedgwick); map.removeOverlays(Walton); map.addOverlays(Burrton); centerByArray(Burrton, false, false); cntMarker += Burrton.length; map.addOverlays(Halstead); centerByArray(Halstead, false, false); cntMarker += Halstead.length; map.addOverlays(Hesston); centerByArray(Hesston, false, false); cntMarker += Hesston.length; map.addOverlays(Newton); centerByArray(Newton, false, false); cntMarker += Newton.length; map.addOverlays(Sedgwick); centerByArray(Sedgwick, false, false); cntMarker += Sedgwick.length; map.addOverlays(Walton); centerByArray(Walton, false, false); cntMarker += Walton.length; centerByArray(Burrton,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'); } }