function addMarkers() { mySelect = document.getElementById('selection'); Wheeling = [];Elm_Grove = [];Triadelphia = [];West_Liberty = [];mySelect.options[mySelect.options.length] = new Option("Elm Grove schools",'all=Elm_Grove'); mySelect.options[mySelect.options.length] = new Option("Triadelphia schools",'all=Triadelphia'); mySelect.options[mySelect.options.length] = new Option("West Liberty schools",'all=West_Liberty'); mySelect.options[mySelect.options.length] = new Option("Wheeling schools",'all=Wheeling'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Wheeling[Wheeling.length] = createMarker(new GPoint(-80.69180298,40.04542542),"
",iconRd); mySelect.options[mySelect.options.length] = new Option("Bethlehem Elementary School",'Wheeling=' + Wheeling.length); Elm_Grove[Elm_Grove.length] = createMarker(new GPoint(-80.66267395,40.04244614),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Bridge Street Middle School",'Elm_Grove=' + Elm_Grove.length); Wheeling[Wheeling.length] = createMarker(new GPoint(-80.65399933,40.02579880),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Elm Grove Elementary School",'Wheeling=' + Wheeling.length); Wheeling[Wheeling.length] = createMarker(new GPoint(-80.73046112,40.07096100),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Madison Elementary School",'Wheeling=' + Wheeling.length); Triadelphia[Triadelphia.length] = createMarker(new GPoint(-80.60749817,40.06880188),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Middle Creek Elementary School",'Triadelphia=' + Triadelphia.length); Wheeling[Wheeling.length] = createMarker(new GPoint(-80.72148895,40.06928253),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Northern Regional Juvenile Detention Center",'Wheeling=' + Wheeling.length); Wheeling[Wheeling.length] = createMarker(new GPoint(-80.72383881,40.04504776),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Ritchie Elementary School",'Wheeling=' + Wheeling.length); Wheeling[Wheeling.length] = createMarker(new GPoint(-80.67498016,40.06081772),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Steenrod Elementary School",'Wheeling=' + Wheeling.length); Wheeling[Wheeling.length] = createMarker(new GPoint(-80.67393494,40.05950928),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Triadelphia Middle School",'Wheeling=' + Wheeling.length); Wheeling[Wheeling.length] = createMarker(new GPoint(-80.69989777,40.11339951),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Warwood Middle School",'Wheeling=' + Wheeling.length); West_Liberty[West_Liberty.length] = createMarker(new GPoint(-80.68820190,40.06949997),"",iconRd); mySelect.options[mySelect.options.length] = new Option("West Liberty Elementary School",'West_Liberty=' + West_Liberty.length); Wheeling[Wheeling.length] = createMarker(new GPoint(-80.72624207,40.04774857),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Wheeling Middle School",'Wheeling=' + Wheeling.length); Wheeling[Wheeling.length] = createMarker(new GPoint(-80.65533447,40.06121826),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Wheeling Park High School",'Wheeling=' + Wheeling.length); Wheeling[Wheeling.length] = createMarker(new GPoint(-80.69319916,40.07735062),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Woodsdale Elementary School",'Wheeling=' + Wheeling.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(Elm_Grove); map.removeOverlays(Triadelphia); map.removeOverlays(West_Liberty); map.removeOverlays(Wheeling); 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(Wheeling);map.removeOverlays(Elm_Grove); map.removeOverlays(Triadelphia); map.removeOverlays(West_Liberty); map.removeOverlays(Wheeling); map.addOverlays(Elm_Grove); centerByArray(Elm_Grove, false, false); cntMarker += Elm_Grove.length; map.addOverlays(Triadelphia); centerByArray(Triadelphia, false, false); cntMarker += Triadelphia.length; map.addOverlays(West_Liberty); centerByArray(West_Liberty, false, false); cntMarker += West_Liberty.length; map.addOverlays(Wheeling); centerByArray(Wheeling, false, false); cntMarker += Wheeling.length; centerByArray(Wheeling,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'); } }