function addMarkers() { mySelect = document.getElementById('selection'); Franklin = [];Cooperstown = [];Seneca = [];Oil_City = [];Venus = [];Pleasantville = [];Polk = [];Kennerdell = [];Utica = [];Harrisville = [];mySelect.options[mySelect.options.length] = new Option("Cooperstown schools",'all=Cooperstown'); mySelect.options[mySelect.options.length] = new Option("Franklin schools",'all=Franklin'); mySelect.options[mySelect.options.length] = new Option("Harrisville schools",'all=Harrisville'); mySelect.options[mySelect.options.length] = new Option("Kennerdell schools",'all=Kennerdell'); mySelect.options[mySelect.options.length] = new Option("Oil City schools",'all=Oil_City'); mySelect.options[mySelect.options.length] = new Option("Pleasantville schools",'all=Pleasantville'); mySelect.options[mySelect.options.length] = new Option("Polk schools",'all=Polk'); mySelect.options[mySelect.options.length] = new Option("Seneca schools",'all=Seneca'); mySelect.options[mySelect.options.length] = new Option("Utica schools",'all=Utica'); mySelect.options[mySelect.options.length] = new Option("Venus schools",'all=Venus'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Franklin[Franklin.length] = createMarker(new GPoint(-79.82966614,41.39990997),"
",iconRd); mySelect.options[mySelect.options.length] = new Option("Central Elementary School",'Franklin=' + Franklin.length); Cooperstown[Cooperstown.length] = createMarker(new GPoint(-79.88069916,41.51190186),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Cooperstown Elementary School",'Cooperstown=' + Cooperstown.length); Seneca[Seneca.length] = createMarker(new GPoint(-79.70538330,41.36816406),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Cranberry Area Junior Senior High School",'Seneca=' + Seneca.length); Seneca[Seneca.length] = createMarker(new GPoint(-79.70538330,41.36816406),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Cranberry Elementary School",'Seneca=' + Seneca.length); Franklin[Franklin.length] = createMarker(new GPoint(-79.84570312,41.36948013),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Franklin Area High School",'Franklin=' + Franklin.length); Franklin[Franklin.length] = createMarker(new GPoint(-79.84570312,41.36948013),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Franklin Area Middle School",'Franklin=' + Franklin.length); Oil_City[Oil_City.length] = createMarker(new GPoint(-79.68539429,41.44245148),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Hasson Heights School",'Oil_City=' + Oil_City.length); Cooperstown[Cooperstown.length] = createMarker(new GPoint(-79.85997772,41.51369858),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Oakland School",'Cooperstown=' + Cooperstown.length); Oil_City[Oil_City.length] = createMarker(new GPoint(-79.68110657,41.43011093),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Oil City Area Middle School",'Oil_City=' + Oil_City.length); Oil_City[Oil_City.length] = createMarker(new GPoint(-79.68117523,41.43017197),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Oil City Senior High School",'Oil_City=' + Oil_City.length); Venus[Venus.length] = createMarker(new GPoint(-79.50170135,41.36759949),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Pinegrove Elementary School",'Venus=' + Venus.length); Oil_City[Oil_City.length] = createMarker(new GPoint(-79.71202850,41.40315247),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Pinoak Primary Center",'Oil_City=' + Oil_City.length); Pleasantville[Pleasantville.length] = createMarker(new GPoint(-79.58045197,41.59679031),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Pleasantville Elementary School",'Pleasantville=' + Pleasantville.length); Polk[Polk.length] = createMarker(new GPoint(-79.93589783,41.34769821),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Polk Elementary School",'Polk=' + Polk.length); Kennerdell[Kennerdell.length] = createMarker(new GPoint(-79.84056091,41.26657104),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Rockland Elementary School",'Kennerdell=' + Kennerdell.length); Franklin[Franklin.length] = createMarker(new GPoint(-79.82176971,41.40635300),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Rocky Grove Elementary School",'Franklin=' + Franklin.length); Franklin[Franklin.length] = createMarker(new GPoint(-79.82556915,41.41104889),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Rocky Grove Junior Senior High School",'Franklin=' + Franklin.length); Franklin[Franklin.length] = createMarker(new GPoint(-79.83847046,41.36260223),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Sandycreek Elementary School",'Franklin=' + Franklin.length); Franklin[Franklin.length] = createMarker(new GPoint(-79.82231903,41.38769531),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Seventh Street Elementary School",'Franklin=' + Franklin.length); Oil_City[Oil_City.length] = createMarker(new GPoint(-79.71246338,41.42193222),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Seventh Street School",'Oil_City=' + Oil_City.length); Oil_City[Oil_City.length] = createMarker(new GPoint(-79.72109985,41.42256927),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Smedley Street School",'Oil_City=' + Oil_City.length); Seneca[Seneca.length] = createMarker(new GPoint(-79.69427490,41.38665009),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Steffee Intrmd Center",'Seneca=' + Seneca.length); Franklin[Franklin.length] = createMarker(new GPoint(-79.88172150,41.42404175),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Sugarcreek Intrmd School",'Franklin=' + Franklin.length); Utica[Utica.length] = createMarker(new GPoint(-79.95783997,41.43481827),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Utica Elementary School",'Utica=' + Utica.length); Oil_City[Oil_City.length] = createMarker(new GPoint(-79.68759155,41.42568588),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Venango Technology Center",'Oil_City=' + Oil_City.length); Harrisville[Harrisville.length] = createMarker(new GPoint(-79.96956635,41.24320221),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Victory Elementary School",'Harrisville=' + Harrisville.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(Cooperstown); map.removeOverlays(Franklin); map.removeOverlays(Harrisville); map.removeOverlays(Kennerdell); map.removeOverlays(Oil_City); map.removeOverlays(Pleasantville); map.removeOverlays(Polk); map.removeOverlays(Seneca); map.removeOverlays(Utica); map.removeOverlays(Venus); 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(Franklin);map.removeOverlays(Cooperstown); map.removeOverlays(Franklin); map.removeOverlays(Harrisville); map.removeOverlays(Kennerdell); map.removeOverlays(Oil_City); map.removeOverlays(Pleasantville); map.removeOverlays(Polk); map.removeOverlays(Seneca); map.removeOverlays(Utica); map.removeOverlays(Venus); map.addOverlays(Cooperstown); centerByArray(Cooperstown, false, false); cntMarker += Cooperstown.length; map.addOverlays(Franklin); centerByArray(Franklin, false, false); cntMarker += Franklin.length; map.addOverlays(Harrisville); centerByArray(Harrisville, false, false); cntMarker += Harrisville.length; map.addOverlays(Kennerdell); centerByArray(Kennerdell, false, false); cntMarker += Kennerdell.length; map.addOverlays(Oil_City); centerByArray(Oil_City, false, false); cntMarker += Oil_City.length; map.addOverlays(Pleasantville); centerByArray(Pleasantville, false, false); cntMarker += Pleasantville.length; map.addOverlays(Polk); centerByArray(Polk, false, false); cntMarker += Polk.length; map.addOverlays(Seneca); centerByArray(Seneca, false, false); cntMarker += Seneca.length; map.addOverlays(Utica); centerByArray(Utica, false, false); cntMarker += Utica.length; map.addOverlays(Venus); centerByArray(Venus, false, false); cntMarker += Venus.length; centerByArray(Franklin,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'); } }