function addMarkers() { mySelect = document.getElementById('selection'); Baldwin_City = [];Lawrence = [];Eudora = [];Lecompton = [];mySelect.options[mySelect.options.length] = new Option("Baldwin City schools",'all=Baldwin_City'); mySelect.options[mySelect.options.length] = new Option("Eudora schools",'all=Eudora'); mySelect.options[mySelect.options.length] = new Option("Lawrence schools",'all=Lawrence'); mySelect.options[mySelect.options.length] = new Option("Lecompton schools",'all=Lecompton'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Baldwin_City[Baldwin_City.length] = createMarker(new GPoint(-95.21009827,38.78929901),"
",iconRd); mySelect.options[mySelect.options.length] = new Option("Baldwin Elementary Primary",'Baldwin_City=' + Baldwin_City.length); Baldwin_City[Baldwin_City.length] = createMarker(new GPoint(-95.21330261,38.79199982),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Baldwin Elementary Intermediate Center",'Baldwin_City=' + Baldwin_City.length); Baldwin_City[Baldwin_City.length] = createMarker(new GPoint(-95.21009827,38.78929901),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Baldwin High School",'Baldwin_City=' + Baldwin_City.length); Baldwin_City[Baldwin_City.length] = createMarker(new GPoint(-95.21009827,38.78929901),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Baldwin Junior High School",'Baldwin_City=' + Baldwin_City.length); Lawrence[Lawrence.length] = createMarker(new GPoint(-95.24172211,38.93496323),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Broken Arrow Elementary School",'Lawrence=' + Lawrence.length); Lawrence[Lawrence.length] = createMarker(new GPoint(-95.23727417,38.95085144),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Cordley Elementary School",'Lawrence=' + Lawrence.length); Lawrence[Lawrence.length] = createMarker(new GPoint(-95.27017975,38.98356247),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Deerfield Elementary School",'Lawrence=' + Lawrence.length); Lawrence[Lawrence.length] = createMarker(new GPoint(-95.22332001,38.95778275),"",iconRd); mySelect.options[mySelect.options.length] = new Option("East Heights Elementary School",'Lawrence=' + Lawrence.length); Eudora[Eudora.length] = createMarker(new GPoint(-95.09390259,38.92729950),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Eudora High School",'Eudora=' + Eudora.length); Eudora[Eudora.length] = createMarker(new GPoint(-95.09789276,38.94361115),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Eudora Middle School",'Eudora=' + Eudora.length); Eudora[Eudora.length] = createMarker(new GPoint(-95.09390259,38.92729950),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Eudora West Elementary School",'Eudora=' + Eudora.length); Lawrence[Lawrence.length] = createMarker(new GPoint(-95.20567322,39.00893021),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Grant Elementary School",'Lawrence=' + Lawrence.length); Lawrence[Lawrence.length] = createMarker(new GPoint(-95.25807953,38.96523285),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Hillcrest Elementary School",'Lawrence=' + Lawrence.length); Lawrence[Lawrence.length] = createMarker(new GPoint(-95.21581268,38.94769669),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Kennedy Elementary School",'Lawrence=' + Lawrence.length); Lawrence[Lawrence.length] = createMarker(new GPoint(-95.32577515,38.96315765),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Langston Hughes Elementary School",'Lawrence=' + Lawrence.length); Lawrence[Lawrence.length] = createMarker(new GPoint(-95.23572540,38.95806122),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Lawrence Central Junior High School",'Lawrence=' + Lawrence.length); Lawrence[Lawrence.length] = createMarker(new GPoint(-95.30067444,38.97413635),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Lawrence Free State High School",'Lawrence=' + Lawrence.length); Lawrence[Lawrence.length] = createMarker(new GPoint(-95.24197388,38.94994736),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Lawrence High School",'Lawrence=' + Lawrence.length); Lawrence[Lawrence.length] = createMarker(new GPoint(-95.24170685,38.93413925),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Lawrence South Junior High School",'Lawrence=' + Lawrence.length); Lawrence[Lawrence.length] = createMarker(new GPoint(-95.25806700,38.98572300),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Lawrence Virtual School",'Lawrence=' + Lawrence.length); Lawrence[Lawrence.length] = createMarker(new GPoint(-95.26818085,38.96487808),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Lawrence West Junior High School",'Lawrence=' + Lawrence.length); Lecompton[Lecompton.length] = createMarker(new GPoint(-95.43250275,39.02230072),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Lecompton Elementary School",'Lecompton=' + Lecompton.length); Baldwin_City[Baldwin_City.length] = createMarker(new GPoint(-95.21009827,38.78929901),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Marion Springs Elementary School",'Baldwin_City=' + Baldwin_City.length); Lawrence[Lawrence.length] = createMarker(new GPoint(-95.23102570,38.96680832),"",iconRd); mySelect.options[mySelect.options.length] = new Option("New York Elementary School",'Lawrence=' + Lawrence.length); Eudora[Eudora.length] = createMarker(new GPoint(-95.09390259,38.92729950),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Nottingham Elementary School",'Eudora=' + Eudora.length); Lawrence[Lawrence.length] = createMarker(new GPoint(-95.24436188,38.97323608),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Pinckney Elementary School",'Lawrence=' + Lawrence.length); Lawrence[Lawrence.length] = createMarker(new GPoint(-95.20977783,38.93510437),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Prairie Park Elementary School",'Lawrence=' + Lawrence.length); Lawrence[Lawrence.length] = createMarker(new GPoint(-95.30245972,38.96253586),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Quail Run Elementary School",'Lawrence=' + Lawrence.length); Lawrence[Lawrence.length] = createMarker(new GPoint(-95.26067352,38.99344254),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Riverside Elementary School",'Lawrence=' + Lawrence.length); Lawrence[Lawrence.length] = createMarker(new GPoint(-95.25598907,38.94446182),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Schwegler Elementary School",'Lawrence=' + Lawrence.length); Lawrence[Lawrence.length] = createMarker(new GPoint(-95.29814148,38.93823624),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Southwest Junior High School",'Lawrence=' + Lawrence.length); Lawrence[Lawrence.length] = createMarker(new GPoint(-95.29807281,38.93708420),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Sunflower Elementary School",'Lawrence=' + Lawrence.length); Lawrence[Lawrence.length] = createMarker(new GPoint(-95.26987457,38.96784973),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Sunset Hill Elementary School",'Lawrence=' + Lawrence.length); Baldwin_City[Baldwin_City.length] = createMarker(new GPoint(-95.21009827,38.78929901),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Vinland Elementary School",'Baldwin_City=' + Baldwin_City.length); Lawrence[Lawrence.length] = createMarker(new GPoint(-95.31642151,38.89944458),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Wakarusa Valley Elementary School",'Lawrence=' + Lawrence.length); Lawrence[Lawrence.length] = createMarker(new GPoint(-95.22856140,38.97686386),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Woodlawn Elementary School",'Lawrence=' + Lawrence.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(Baldwin_City); map.removeOverlays(Eudora); map.removeOverlays(Lawrence); map.removeOverlays(Lecompton); 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(Baldwin_City);map.removeOverlays(Baldwin_City); map.removeOverlays(Eudora); map.removeOverlays(Lawrence); map.removeOverlays(Lecompton); map.addOverlays(Baldwin_City); centerByArray(Baldwin_City, false, false); cntMarker += Baldwin_City.length; map.addOverlays(Eudora); centerByArray(Eudora, false, false); cntMarker += Eudora.length; map.addOverlays(Lawrence); centerByArray(Lawrence, false, false); cntMarker += Lawrence.length; map.addOverlays(Lecompton); centerByArray(Lecompton, false, false); cntMarker += Lecompton.length; centerByArray(Baldwin_City,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'); } }