function addMarkers() { mySelect = document.getElementById('selection'); Apollo = [];Spring_Church = [];Leechburg = [];Dayton = [];Kittanning = [];Elderton = [];Ford_City = [];Freeport = [];North_Apollo = [];Rural_Valley = [];Cowansville = [];mySelect.options[mySelect.options.length] = new Option("Apollo schools",'all=Apollo'); mySelect.options[mySelect.options.length] = new Option("Cowansville schools",'all=Cowansville'); mySelect.options[mySelect.options.length] = new Option("Dayton schools",'all=Dayton'); mySelect.options[mySelect.options.length] = new Option("Elderton schools",'all=Elderton'); mySelect.options[mySelect.options.length] = new Option("Ford City schools",'all=Ford_City'); mySelect.options[mySelect.options.length] = new Option("Freeport schools",'all=Freeport'); mySelect.options[mySelect.options.length] = new Option("Kittanning schools",'all=Kittanning'); mySelect.options[mySelect.options.length] = new Option("Leechburg schools",'all=Leechburg'); mySelect.options[mySelect.options.length] = new Option("North Apollo schools",'all=North_Apollo'); mySelect.options[mySelect.options.length] = new Option("Rural Valley schools",'all=Rural_Valley'); mySelect.options[mySelect.options.length] = new Option("Spring Church schools",'all=Spring_Church'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Apollo[Apollo.length] = createMarker(new GPoint(-79.56256104,40.58303452),"
",iconRd); mySelect.options[mySelect.options.length] = new Option("Apollo Elementary School",'Apollo=' + Apollo.length); Spring_Church[Spring_Church.length] = createMarker(new GPoint(-80.42910004,41.83702087),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Apollo-ridge Elementary School",'Spring_Church=' + Spring_Church.length); Spring_Church[Spring_Church.length] = createMarker(new GPoint(-79.48935699,40.60655975),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Apollo-ridge High School",'Spring_Church=' + Spring_Church.length); Spring_Church[Spring_Church.length] = createMarker(new GPoint(-79.48935699,40.60655975),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Apollo-ridge Middle School",'Spring_Church=' + Spring_Church.length); Leechburg[Leechburg.length] = createMarker(new GPoint(-79.60446930,40.62868881),"",iconRd); mySelect.options[mySelect.options.length] = new Option("David Leech Elementary School",'Leechburg=' + Leechburg.length); Dayton[Dayton.length] = createMarker(new GPoint(-79.24109650,40.88238144),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Dayton Elementary School",'Dayton=' + Dayton.length); Kittanning[Kittanning.length] = createMarker(new GPoint(-79.58892059,40.83243942),"",iconRd); mySelect.options[mySelect.options.length] = new Option("East Franklin Elementary School",'Kittanning=' + Kittanning.length); Elderton[Elderton.length] = createMarker(new GPoint(-79.34153748,40.69477844),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Elderton Elementary School",'Elderton=' + Elderton.length); Elderton[Elderton.length] = createMarker(new GPoint(-79.34153748,40.69477844),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Elderton Junior Senior High School",'Elderton=' + Elderton.length); Ford_City[Ford_City.length] = createMarker(new GPoint(-79.53014374,40.77222061),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Ford City Junior Senior High School",'Ford_City=' + Ford_City.length); Freeport[Freeport.length] = createMarker(new GPoint(-79.68736267,40.67462158),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Freeport Area Junior High School",'Freeport=' + Freeport.length); Freeport[Freeport.length] = createMarker(new GPoint(-79.66320038,40.70230103),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Freeport Area Senior High School",'Freeport=' + Freeport.length); Freeport[Freeport.length] = createMarker(new GPoint(-79.68639374,40.67342758),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Freeport Kdg Center",'Freeport=' + Freeport.length); Kittanning[Kittanning.length] = createMarker(new GPoint(-79.52002716,40.81648636),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Kittanning Area Middle School",'Kittanning=' + Kittanning.length); Kittanning[Kittanning.length] = createMarker(new GPoint(-79.52716827,40.83052826),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Kittanning Senior High School",'Kittanning=' + Kittanning.length); Kittanning[Kittanning.length] = createMarker(new GPoint(-79.51999664,40.81560135),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Kittanning Township Elementary School",'Kittanning=' + Kittanning.length); Leechburg[Leechburg.length] = createMarker(new GPoint(-79.59912109,40.63228607),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Leechburg Area High School",'Leechburg=' + Leechburg.length); Leechburg[Leechburg.length] = createMarker(new GPoint(-79.59912109,40.63228607),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Leechburg Area Middle School",'Leechburg=' + Leechburg.length); Ford_City[Ford_City.length] = createMarker(new GPoint(-79.52072906,40.76521301),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Lenape Elementary School",'Ford_City=' + Ford_City.length); Ford_City[Ford_City.length] = createMarker(new GPoint(-79.52298737,40.76778030),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Lenape Technical High School",'Ford_City=' + Ford_City.length); North_Apollo[North_Apollo.length] = createMarker(new GPoint(-79.55580139,40.59609985),"",iconRd); mySelect.options[mySelect.options.length] = new Option("North Apollo Elementary School",'North_Apollo=' + North_Apollo.length); Kittanning[Kittanning.length] = createMarker(new GPoint(-79.51999664,40.81560135),"",iconRd); mySelect.options[mySelect.options.length] = new Option("North Buffalo Elementary School",'Kittanning=' + Kittanning.length); Rural_Valley[Rural_Valley.length] = createMarker(new GPoint(-79.28890228,40.78369904),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Shannock Valley Elementary School",'Rural_Valley=' + Rural_Valley.length); Freeport[Freeport.length] = createMarker(new GPoint(-79.66904449,40.70141602),"",iconRd); mySelect.options[mySelect.options.length] = new Option("South Buffalo Elementary School",'Freeport=' + Freeport.length); Cowansville[Cowansville.length] = createMarker(new GPoint(-79.58866882,40.88727951),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Sugarcreek Elementary School",'Cowansville=' + Cowansville.length); Spring_Church[Spring_Church.length] = createMarker(new GPoint(-79.41120148,40.62229919),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Sunnyside Elementary School",'Spring_Church=' + Spring_Church.length); Kittanning[Kittanning.length] = createMarker(new GPoint(-79.60116577,40.83263016),"",iconRd); mySelect.options[mySelect.options.length] = new Option("West Hills Elementary School",'Kittanning=' + Kittanning.length); Rural_Valley[Rural_Valley.length] = createMarker(new GPoint(-79.28890228,40.78369904),"",iconGr); mySelect.options[mySelect.options.length] = new Option("West Shamokin Junior Senior High School",'Rural_Valley=' + Rural_Valley.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(Apollo); map.removeOverlays(Cowansville); map.removeOverlays(Dayton); map.removeOverlays(Elderton); map.removeOverlays(Ford_City); map.removeOverlays(Freeport); map.removeOverlays(Kittanning); map.removeOverlays(Leechburg); map.removeOverlays(North_Apollo); map.removeOverlays(Rural_Valley); map.removeOverlays(Spring_Church); 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(Apollo);map.removeOverlays(Apollo); map.removeOverlays(Cowansville); map.removeOverlays(Dayton); map.removeOverlays(Elderton); map.removeOverlays(Ford_City); map.removeOverlays(Freeport); map.removeOverlays(Kittanning); map.removeOverlays(Leechburg); map.removeOverlays(North_Apollo); map.removeOverlays(Rural_Valley); map.removeOverlays(Spring_Church); map.addOverlays(Apollo); centerByArray(Apollo, false, false); cntMarker += Apollo.length; map.addOverlays(Cowansville); centerByArray(Cowansville, false, false); cntMarker += Cowansville.length; map.addOverlays(Dayton); centerByArray(Dayton, false, false); cntMarker += Dayton.length; map.addOverlays(Elderton); centerByArray(Elderton, false, false); cntMarker += Elderton.length; map.addOverlays(Ford_City); centerByArray(Ford_City, false, false); cntMarker += Ford_City.length; map.addOverlays(Freeport); centerByArray(Freeport, false, false); cntMarker += Freeport.length; map.addOverlays(Kittanning); centerByArray(Kittanning, false, false); cntMarker += Kittanning.length; map.addOverlays(Leechburg); centerByArray(Leechburg, false, false); cntMarker += Leechburg.length; map.addOverlays(North_Apollo); centerByArray(North_Apollo, false, false); cntMarker += North_Apollo.length; map.addOverlays(Rural_Valley); centerByArray(Rural_Valley, false, false); cntMarker += Rural_Valley.length; map.addOverlays(Spring_Church); centerByArray(Spring_Church, false, false); cntMarker += Spring_Church.length; centerByArray(Apollo,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'); } }