function addMarkers() { mySelect = document.getElementById('selection'); Clarendon = [];Warren = [];Russell = [];North_Warren = [];Pittsfield = [];Sheffield = [];Spartansburg = [];Sugar_Grove = [];Tidioute = [];Youngsville = [];mySelect.options[mySelect.options.length] = new Option("Clarendon schools",'all=Clarendon'); mySelect.options[mySelect.options.length] = new Option("North Warren schools",'all=North_Warren'); mySelect.options[mySelect.options.length] = new Option("Pittsfield schools",'all=Pittsfield'); mySelect.options[mySelect.options.length] = new Option("Russell schools",'all=Russell'); mySelect.options[mySelect.options.length] = new Option("Sheffield schools",'all=Sheffield'); mySelect.options[mySelect.options.length] = new Option("Spartansburg schools",'all=Spartansburg'); mySelect.options[mySelect.options.length] = new Option("Sugar Grove schools",'all=Sugar_Grove'); mySelect.options[mySelect.options.length] = new Option("Tidioute schools",'all=Tidioute'); mySelect.options[mySelect.options.length] = new Option("Warren schools",'all=Warren'); mySelect.options[mySelect.options.length] = new Option("Youngsville schools",'all=Youngsville'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Clarendon[Clarendon.length] = createMarker(new GPoint(-79.12519836,41.73929977),"
",iconRd); mySelect.options[mySelect.options.length] = new Option("Allegheny Valley Elementary School",'Clarendon=' + Clarendon.length); Warren[Warren.length] = createMarker(new GPoint(-79.13808441,41.84777451),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Beaty-warren Middle School",'Warren=' + Warren.length); Russell[Russell.length] = createMarker(new GPoint(-79.09485626,41.98657990),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Eisenhower Middle School High School",'Russell=' + Russell.length); Warren[Warren.length] = createMarker(new GPoint(-79.14502716,41.86029053),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Home Street Elementary School",'Warren=' + Warren.length); Warren[Warren.length] = createMarker(new GPoint(-79.13819885,41.84712601),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Jefferson Elementary School",'Warren=' + Warren.length); Russell[Russell.length] = createMarker(new GPoint(-79.24870300,41.93909836),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Lander Elementary School",'Russell=' + Russell.length); Warren[Warren.length] = createMarker(new GPoint(-79.14491272,41.84416580),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Market Street Elementary School",'Warren=' + Warren.length); North_Warren[North_Warren.length] = createMarker(new GPoint(-79.14865875,41.87149429),"",iconRd); mySelect.options[mySelect.options.length] = new Option("North Warren Elementary School",'North_Warren=' + North_Warren.length); Pittsfield[Pittsfield.length] = createMarker(new GPoint(-79.42819977,41.82429886),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Pittsfield Elementary School",'Pittsfield=' + Pittsfield.length); Warren[Warren.length] = createMarker(new GPoint(-79.17008209,41.82754517),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Pleasant Township Elementary School",'Warren=' + Warren.length); Russell[Russell.length] = createMarker(new GPoint(-79.14167023,41.96914291),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Russell Elementary School",'Russell=' + Russell.length); Sheffield[Sheffield.length] = createMarker(new GPoint(-79.02909851,41.69699860),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Sheffield Elementary School",'Sheffield=' + Sheffield.length); Sheffield[Sheffield.length] = createMarker(new GPoint(-79.03495026,41.70328903),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Sheffield Ms/hs",'Sheffield=' + Sheffield.length); Warren[Warren.length] = createMarker(new GPoint(-79.13405609,41.84020233),"",iconRd); mySelect.options[mySelect.options.length] = new Option("South Street Elementary School",'Warren=' + Warren.length); Spartansburg[Spartansburg.length] = createMarker(new GPoint(-79.68771362,41.82504654),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Sparta Elementary School",'Spartansburg=' + Spartansburg.length); Sugar_Grove[Sugar_Grove.length] = createMarker(new GPoint(-79.33984375,41.98048019),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Sugar Grove Elementary School",'Sugar_Grove=' + Sugar_Grove.length); Tidioute[Tidioute.length] = createMarker(new GPoint(-79.40238953,41.68322754),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Tidioute Area School",'Tidioute=' + Tidioute.length); Tidioute[Tidioute.length] = createMarker(new GPoint(-79.40278800,41.68309100),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Tidioute Community Charter School",'Tidioute=' + Tidioute.length); Tidioute[Tidioute.length] = createMarker(new GPoint(-79.40238953,41.68322754),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Tidioute Elementary School",'Tidioute=' + Tidioute.length); Warren[Warren.length] = createMarker(new GPoint(-79.13539886,41.85509872),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Warren Area High School",'Warren=' + Warren.length); Warren[Warren.length] = createMarker(new GPoint(-79.13538361,41.85511398),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Warren County Avts",'Warren=' + Warren.length); Youngsville[Youngsville.length] = createMarker(new GPoint(-79.32627869,41.85008621),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Youngsville El/ms Elementary School",'Youngsville=' + Youngsville.length); Youngsville[Youngsville.length] = createMarker(new GPoint(-79.31455231,41.85233688),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Youngsville Middle School High School",'Youngsville=' + Youngsville.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(Clarendon); map.removeOverlays(North_Warren); map.removeOverlays(Pittsfield); map.removeOverlays(Russell); map.removeOverlays(Sheffield); map.removeOverlays(Spartansburg); map.removeOverlays(Sugar_Grove); map.removeOverlays(Tidioute); map.removeOverlays(Warren); map.removeOverlays(Youngsville); 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(Clarendon);map.removeOverlays(Clarendon); map.removeOverlays(North_Warren); map.removeOverlays(Pittsfield); map.removeOverlays(Russell); map.removeOverlays(Sheffield); map.removeOverlays(Spartansburg); map.removeOverlays(Sugar_Grove); map.removeOverlays(Tidioute); map.removeOverlays(Warren); map.removeOverlays(Youngsville); map.addOverlays(Clarendon); centerByArray(Clarendon, false, false); cntMarker += Clarendon.length; map.addOverlays(North_Warren); centerByArray(North_Warren, false, false); cntMarker += North_Warren.length; map.addOverlays(Pittsfield); centerByArray(Pittsfield, false, false); cntMarker += Pittsfield.length; map.addOverlays(Russell); centerByArray(Russell, false, false); cntMarker += Russell.length; map.addOverlays(Sheffield); centerByArray(Sheffield, false, false); cntMarker += Sheffield.length; map.addOverlays(Spartansburg); centerByArray(Spartansburg, false, false); cntMarker += Spartansburg.length; map.addOverlays(Sugar_Grove); centerByArray(Sugar_Grove, false, false); cntMarker += Sugar_Grove.length; map.addOverlays(Tidioute); centerByArray(Tidioute, false, false); cntMarker += Tidioute.length; map.addOverlays(Warren); centerByArray(Warren, false, false); cntMarker += Warren.length; map.addOverlays(Youngsville); centerByArray(Youngsville, false, false); cntMarker += Youngsville.length; centerByArray(Clarendon,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'); } }