function addMarkers() { mySelect = document.getElementById('selection'); Bridgeport = [];Beckley = [];Barboursville = [];Frametown = [];Frankford = [];Glen_Dale = [];Kenova = [];Pineville = [];Ravenswood = [];Williamson = [];Scott_Depot = [];Wheeling = [];Morgantown = [];Weirton = [];Williamstown = [];mySelect.options[mySelect.options.length] = new Option("Barboursville schools",'all=Barboursville'); mySelect.options[mySelect.options.length] = new Option("Beckley schools",'all=Beckley'); mySelect.options[mySelect.options.length] = new Option("Bridgeport schools",'all=Bridgeport'); mySelect.options[mySelect.options.length] = new Option("Frametown schools",'all=Frametown'); mySelect.options[mySelect.options.length] = new Option("Frankford schools",'all=Frankford'); mySelect.options[mySelect.options.length] = new Option("Glen Dale schools",'all=Glen_Dale'); mySelect.options[mySelect.options.length] = new Option("Kenova schools",'all=Kenova'); mySelect.options[mySelect.options.length] = new Option("Morgantown schools",'all=Morgantown'); mySelect.options[mySelect.options.length] = new Option("Pineville schools",'all=Pineville'); mySelect.options[mySelect.options.length] = new Option("Ravenswood schools",'all=Ravenswood'); mySelect.options[mySelect.options.length] = new Option("Scott Depot schools",'all=Scott_Depot'); mySelect.options[mySelect.options.length] = new Option("Weirton schools",'all=Weirton'); mySelect.options[mySelect.options.length] = new Option("Wheeling schools",'all=Wheeling'); mySelect.options[mySelect.options.length] = new Option("Williamson schools",'all=Williamson'); mySelect.options[mySelect.options.length] = new Option("Williamstown schools",'all=Williamstown'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Bridgeport[Bridgeport.length] = createMarker(new GPoint(-80.26235199,39.29010010),"
Bridgeport High School
515 Johnson Ave
Bridgeport, WV 26330

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Bridgeport High School",'Bridgeport=' + Bridgeport.length); Beckley[Beckley.length] = createMarker(new GPoint(-81.21173859,37.78689194),"
Crescent Elementary School
205 Crescent Rd
Beckley, WV 25801

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Crescent Elementary School",'Beckley=' + Beckley.length); Barboursville[Barboursville.length] = createMarker(new GPoint(-82.33392334,38.38394165),"
Davis Creek Elementary School
6330 Davis Creek Road
Barboursville, WV 25504

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Davis Creek Elementary School",'Barboursville=' + Barboursville.length); Frametown[Frametown.length] = createMarker(new GPoint(-80.85864258,38.63782120),"
Frametown Elementary School
Hc 61 Box 14
Frametown, WV 26623

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Frametown Elementary School",'Frametown=' + Frametown.length); Frankford[Frankford.length] = createMarker(new GPoint(-80.38352203,37.92351151),"
Frankford Elementary School
Pirate Cove Educational Park
Frankford, WV 24938

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Frankford Elementary School",'Frankford=' + Frankford.length); Glen_Dale[Glen_Dale.length] = createMarker(new GPoint(-80.75421906,39.94166183),"
John Marshall High School
1300 Wheeling Ave
Glen Dale, WV 26038

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("John Marshall High School",'Glen_Dale=' + Glen_Dale.length); Kenova[Kenova.length] = createMarker(new GPoint(-82.57781982,38.40001678),"
Kenova Elementary School
1400 Poplar St
Kenova, WV 25530

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Kenova Elementary School",'Kenova=' + Kenova.length); Pineville[Pineville.length] = createMarker(new GPoint(-81.53500366,37.57839966),"
Pineville Middle School
Po Box 470
Pineville, WV 24874

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Pineville Middle School",'Pineville=' + Pineville.length); Ravenswood[Ravenswood.length] = createMarker(new GPoint(-81.75930786,38.95029068),"
Ravenswood Middle School
409 Sycamore St
Ravenswood, WV 26164

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Ravenswood Middle School",'Ravenswood=' + Ravenswood.length); Williamson[Williamson.length] = createMarker(new GPoint(-82.28911591,37.66950989),"
Riverside Elementary School
5 Parkway Drive
Williamson, WV 25661

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Riverside Elementary School",'Williamson=' + Williamson.length); Scott_Depot[Scott_Depot.length] = createMarker(new GPoint(-81.91078186,38.44757080),"
Scott Teays Elementary School
4308 Teays Valley Rd
Scott Depot, WV 25560

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Scott Teays Elementary School",'Scott_Depot=' + Scott_Depot.length); Wheeling[Wheeling.length] = createMarker(new GPoint(-80.67498016,40.06081772),"
Steenrod Elementary School
100 Clarks Ln
Wheeling, WV 26003

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Steenrod Elementary School",'Wheeling=' + Wheeling.length); Morgantown[Morgantown.length] = createMarker(new GPoint(-79.97088623,39.65302658),"
Suncrest Middle School
360 Baldwin St
Morgantown, WV 26505

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Suncrest Middle School",'Morgantown=' + Morgantown.length); Wheeling[Wheeling.length] = createMarker(new GPoint(-80.69989777,40.11339951),"
Warwood Middle School
150 Viking Drive
Wheeling, WV 26003

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Warwood Middle School",'Wheeling=' + Wheeling.length); Weirton[Weirton.length] = createMarker(new GPoint(-80.57111359,40.41848755),"
Weirton Heights Elementary School
160 S 12th St
Weirton, WV 26062

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Weirton Heights Elementary School",'Weirton=' + Weirton.length); Williamstown[Williamstown.length] = createMarker(new GPoint(-81.45358276,39.40285492),"
Williamstown Elementary School
418 Williams Ave
Williamstown, WV 26187

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Williamstown Elementary School",'Williamstown=' + Williamstown.length); map.removeOverlays(Barboursville); map.removeOverlays(Beckley); map.removeOverlays(Bridgeport); map.removeOverlays(Frametown); map.removeOverlays(Frankford); map.removeOverlays(Glen_Dale); map.removeOverlays(Kenova); map.removeOverlays(Morgantown); map.removeOverlays(Pineville); map.removeOverlays(Ravenswood); map.removeOverlays(Scott_Depot); map.removeOverlays(Weirton); map.removeOverlays(Wheeling); map.removeOverlays(Williamson); map.removeOverlays(Williamstown); setTimeout(function(){map.addOverlays(Barboursville)},1000); setTimeout(function(){map.addOverlays(Beckley)},1000); setTimeout(function(){map.addOverlays(Bridgeport)},1000); setTimeout(function(){map.addOverlays(Frametown)},1000); setTimeout(function(){map.addOverlays(Frankford)},1000); setTimeout(function(){map.addOverlays(Glen_Dale)},1000); setTimeout(function(){map.addOverlays(Kenova)},1000); setTimeout(function(){map.addOverlays(Morgantown)},1000); setTimeout(function(){map.addOverlays(Pineville)},1000); setTimeout(function(){map.addOverlays(Ravenswood)},1000); setTimeout(function(){map.addOverlays(Scott_Depot)},1000); setTimeout(function(){map.addOverlays(Weirton)},1000); setTimeout(function(){map.addOverlays(Wheeling)},1000); setTimeout(function(){map.addOverlays(Williamson)},1000); setTimeout(function(){map.addOverlays(Williamstown)},1000); maxLng = -79.97088623; maxLat = 40.41848755; minLng = -82.57781982; minLat = 37.57839966; reCenterMap(); } // 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(Barboursville); map.removeOverlays(Beckley); map.removeOverlays(Bridgeport); map.removeOverlays(Frametown); map.removeOverlays(Frankford); map.removeOverlays(Glen_Dale); map.removeOverlays(Kenova); map.removeOverlays(Morgantown); map.removeOverlays(Pineville); map.removeOverlays(Ravenswood); map.removeOverlays(Scott_Depot); map.removeOverlays(Weirton); map.removeOverlays(Wheeling); map.removeOverlays(Williamson); map.removeOverlays(Williamstown); 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(Bridgeport);map.removeOverlays(Barboursville); map.removeOverlays(Beckley); map.removeOverlays(Bridgeport); map.removeOverlays(Frametown); map.removeOverlays(Frankford); map.removeOverlays(Glen_Dale); map.removeOverlays(Kenova); map.removeOverlays(Morgantown); map.removeOverlays(Pineville); map.removeOverlays(Ravenswood); map.removeOverlays(Scott_Depot); map.removeOverlays(Weirton); map.removeOverlays(Wheeling); map.removeOverlays(Williamson); map.removeOverlays(Williamstown); map.addOverlays(Barboursville); centerByArray(Barboursville, false, false); cntMarker += Barboursville.length; map.addOverlays(Beckley); centerByArray(Beckley, false, false); cntMarker += Beckley.length; map.addOverlays(Bridgeport); centerByArray(Bridgeport, false, false); cntMarker += Bridgeport.length; map.addOverlays(Frametown); centerByArray(Frametown, false, false); cntMarker += Frametown.length; map.addOverlays(Frankford); centerByArray(Frankford, false, false); cntMarker += Frankford.length; map.addOverlays(Glen_Dale); centerByArray(Glen_Dale, false, false); cntMarker += Glen_Dale.length; map.addOverlays(Kenova); centerByArray(Kenova, false, false); cntMarker += Kenova.length; map.addOverlays(Morgantown); centerByArray(Morgantown, false, false); cntMarker += Morgantown.length; map.addOverlays(Pineville); centerByArray(Pineville, false, false); cntMarker += Pineville.length; map.addOverlays(Ravenswood); centerByArray(Ravenswood, false, false); cntMarker += Ravenswood.length; map.addOverlays(Scott_Depot); centerByArray(Scott_Depot, false, false); cntMarker += Scott_Depot.length; map.addOverlays(Weirton); centerByArray(Weirton, false, false); cntMarker += Weirton.length; map.addOverlays(Wheeling); centerByArray(Wheeling, false, false); cntMarker += Wheeling.length; map.addOverlays(Williamson); centerByArray(Williamson, false, false); cntMarker += Williamson.length; map.addOverlays(Williamstown); centerByArray(Williamstown, false, false); cntMarker += Williamstown.length; centerByArray(Bridgeport,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///88206,88409,88525,88787,88259,88087,88631,88064,88167,88719,88613,88197,88567,88569,88491,88771,/all'); } }