function addMarkers() { mySelect = document.getElementById('selection'); Brodhead = [];Paintsville = [];Henderson = [];Louisville = [];Ashland = [];Hanson = [];Fort_Thomas = [];Bowling_Green = [];Williamstown = [];Martin = [];Morgantown = [];Paint_Lick = [];Sacramento = [];Salyersville = [];Owensboro = [];Beaver_Dam = [];Summer_Shade = [];Lexington = [];Richmond = [];Whitesville = [];mySelect.options[mySelect.options.length] = new Option("Ashland schools",'all=Ashland'); mySelect.options[mySelect.options.length] = new Option("Beaver Dam schools",'all=Beaver_Dam'); mySelect.options[mySelect.options.length] = new Option("Bowling Green schools",'all=Bowling_Green'); mySelect.options[mySelect.options.length] = new Option("Brodhead schools",'all=Brodhead'); mySelect.options[mySelect.options.length] = new Option("Fort Thomas schools",'all=Fort_Thomas'); mySelect.options[mySelect.options.length] = new Option("Hanson schools",'all=Hanson'); mySelect.options[mySelect.options.length] = new Option("Henderson schools",'all=Henderson'); mySelect.options[mySelect.options.length] = new Option("Lexington schools",'all=Lexington'); mySelect.options[mySelect.options.length] = new Option("Louisville schools",'all=Louisville'); mySelect.options[mySelect.options.length] = new Option("Martin schools",'all=Martin'); mySelect.options[mySelect.options.length] = new Option("Morgantown schools",'all=Morgantown'); mySelect.options[mySelect.options.length] = new Option("Owensboro schools",'all=Owensboro'); mySelect.options[mySelect.options.length] = new Option("Paint Lick schools",'all=Paint_Lick'); mySelect.options[mySelect.options.length] = new Option("Paintsville schools",'all=Paintsville'); mySelect.options[mySelect.options.length] = new Option("Richmond schools",'all=Richmond'); mySelect.options[mySelect.options.length] = new Option("Sacramento schools",'all=Sacramento'); mySelect.options[mySelect.options.length] = new Option("Salyersville schools",'all=Salyersville'); mySelect.options[mySelect.options.length] = new Option("Summer Shade schools",'all=Summer_Shade'); mySelect.options[mySelect.options.length] = new Option("Whitesville schools",'all=Whitesville'); mySelect.options[mySelect.options.length] = new Option("Williamstown schools",'all=Williamstown'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Brodhead[Brodhead.length] = createMarker(new GPoint(-84.41998291,37.40404129),"
",iconRd); mySelect.options[mySelect.options.length] = new Option("Brodhead Elementary School",'Brodhead=' + Brodhead.length); Paintsville[Paintsville.length] = createMarker(new GPoint(-82.77787018,37.80966568),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Central Elementary School",'Paintsville=' + Paintsville.length); Henderson[Henderson.length] = createMarker(new GPoint(-87.54834747,37.82551193),"",iconRd); mySelect.options[mySelect.options.length] = new Option("East Heights Elementary School",'Henderson=' + Henderson.length); Louisville[Louisville.length] = createMarker(new GPoint(-85.67770386,38.25261307),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Field Elementary School",'Louisville=' + Louisville.length); Louisville[Louisville.length] = createMarker(new GPoint(-85.62184143,38.22660828),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Greathouse Shryock Trad Elementary School",'Louisville=' + Louisville.length); Ashland[Ashland.length] = createMarker(new GPoint(-82.65740204,38.46343994),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Hager Elementary School",'Ashland=' + Ashland.length); Hanson[Hanson.length] = createMarker(new GPoint(-87.47467804,37.41736221),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Hanson Elementary School",'Hanson=' + Hanson.length); Fort_Thomas[Fort_Thomas.length] = createMarker(new GPoint(-84.45104980,39.08402634),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Highlands High School",'Fort_Thomas=' + Fort_Thomas.length); Bowling_Green[Bowling_Green.length] = createMarker(new GPoint(-86.48088074,36.94954681),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Lost River Elementary School",'Bowling_Green=' + Bowling_Green.length); Williamstown[Williamstown.length] = createMarker(new GPoint(-84.58286285,38.59666824),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Mason Corinth Elementary School",'Williamstown=' + Williamstown.length); Martin[Martin.length] = createMarker(new GPoint(-82.81684113,37.56346512),"",iconRd); mySelect.options[mySelect.options.length] = new Option("May Valley Elementary School",'Martin=' + Martin.length); Morgantown[Morgantown.length] = createMarker(new GPoint(-86.68038940,37.23030853),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Morgantown Elementary School",'Morgantown=' + Morgantown.length); Fort_Thomas[Fort_Thomas.length] = createMarker(new GPoint(-84.45354462,39.07649231),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Moyer Elementary School",'Fort_Thomas=' + Fort_Thomas.length); Paint_Lick[Paint_Lick.length] = createMarker(new GPoint(-84.47107697,37.58785248),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Paint Lick Elementary School",'Paint_Lick=' + Paint_Lick.length); Bowling_Green[Bowling_Green.length] = createMarker(new GPoint(-86.41726685,36.98411179),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Potter Gray Elementary School",'Bowling_Green=' + Bowling_Green.length); Sacramento[Sacramento.length] = createMarker(new GPoint(-87.26448059,37.41186905),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Sacramento Elementary School",'Sacramento=' + Sacramento.length); Salyersville[Salyersville.length] = createMarker(new GPoint(-83.06375122,37.73672104),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Salyersville Elementary School",'Salyersville=' + Salyersville.length); Owensboro[Owensboro.length] = createMarker(new GPoint(-87.11299896,37.77371979),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Sorgho Elementary School",'Owensboro=' + Owensboro.length); Beaver_Dam[Beaver_Dam.length] = createMarker(new GPoint(-86.81044006,37.34743500),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Southern Elementary School",'Beaver_Dam=' + Beaver_Dam.length); Summer_Shade[Summer_Shade.length] = createMarker(new GPoint(-85.70711517,36.88276291),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Summer Shade Elementary School",'Summer_Shade=' + Summer_Shade.length); Lexington[Lexington.length] = createMarker(new GPoint(-84.50699615,37.96356201),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Veterans Park Elementary School",'Lexington=' + Lexington.length); Owensboro[Owensboro.length] = createMarker(new GPoint(-87.11299896,37.77371979),"",iconRd); mySelect.options[mySelect.options.length] = new Option("West Louisville Elementary School",'Owensboro=' + Owensboro.length); Richmond[Richmond.length] = createMarker(new GPoint(-84.31925964,37.77613449),"",iconRd); mySelect.options[mySelect.options.length] = new Option("White Hall Elementary School",'Richmond=' + Richmond.length); Whitesville[Whitesville.length] = createMarker(new GPoint(-86.86972046,37.68257904),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Whitesville Elementary School",'Whitesville=' + Whitesville.length); map.removeOverlays(Ashland); map.removeOverlays(Beaver_Dam); map.removeOverlays(Bowling_Green); map.removeOverlays(Brodhead); map.removeOverlays(Fort_Thomas); map.removeOverlays(Hanson); map.removeOverlays(Henderson); map.removeOverlays(Lexington); map.removeOverlays(Louisville); map.removeOverlays(Martin); map.removeOverlays(Morgantown); map.removeOverlays(Owensboro); map.removeOverlays(Paint_Lick); map.removeOverlays(Paintsville); map.removeOverlays(Richmond); map.removeOverlays(Sacramento); map.removeOverlays(Salyersville); map.removeOverlays(Summer_Shade); map.removeOverlays(Whitesville); map.removeOverlays(Williamstown); setTimeout(function(){map.addOverlays(Ashland)},1000); setTimeout(function(){map.addOverlays(Beaver_Dam)},1000); setTimeout(function(){map.addOverlays(Bowling_Green)},1000); setTimeout(function(){map.addOverlays(Brodhead)},1000); setTimeout(function(){map.addOverlays(Fort_Thomas)},1000); setTimeout(function(){map.addOverlays(Hanson)},1000); setTimeout(function(){map.addOverlays(Henderson)},1000); setTimeout(function(){map.addOverlays(Lexington)},1000); setTimeout(function(){map.addOverlays(Louisville)},1000); setTimeout(function(){map.addOverlays(Martin)},1000); setTimeout(function(){map.addOverlays(Morgantown)},1000); setTimeout(function(){map.addOverlays(Owensboro)},1000); setTimeout(function(){map.addOverlays(Paint_Lick)},1000); setTimeout(function(){map.addOverlays(Paintsville)},1000); setTimeout(function(){map.addOverlays(Richmond)},1000); setTimeout(function(){map.addOverlays(Sacramento)},1000); setTimeout(function(){map.addOverlays(Salyersville)},1000); setTimeout(function(){map.addOverlays(Summer_Shade)},1000); setTimeout(function(){map.addOverlays(Whitesville)},1000); setTimeout(function(){map.addOverlays(Williamstown)},1000); maxLng = -82.65740204; maxLat = 39.08402634; minLng = -87.54834747; minLat = 36.88276291; 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(Ashland); map.removeOverlays(Beaver_Dam); map.removeOverlays(Bowling_Green); map.removeOverlays(Brodhead); map.removeOverlays(Fort_Thomas); map.removeOverlays(Hanson); map.removeOverlays(Henderson); map.removeOverlays(Lexington); map.removeOverlays(Louisville); map.removeOverlays(Martin); map.removeOverlays(Morgantown); map.removeOverlays(Owensboro); map.removeOverlays(Paint_Lick); map.removeOverlays(Paintsville); map.removeOverlays(Richmond); map.removeOverlays(Sacramento); map.removeOverlays(Salyersville); map.removeOverlays(Summer_Shade); map.removeOverlays(Whitesville); 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(Brodhead);map.removeOverlays(Ashland); map.removeOverlays(Beaver_Dam); map.removeOverlays(Bowling_Green); map.removeOverlays(Brodhead); map.removeOverlays(Fort_Thomas); map.removeOverlays(Hanson); map.removeOverlays(Henderson); map.removeOverlays(Lexington); map.removeOverlays(Louisville); map.removeOverlays(Martin); map.removeOverlays(Morgantown); map.removeOverlays(Owensboro); map.removeOverlays(Paint_Lick); map.removeOverlays(Paintsville); map.removeOverlays(Richmond); map.removeOverlays(Sacramento); map.removeOverlays(Salyersville); map.removeOverlays(Summer_Shade); map.removeOverlays(Whitesville); map.removeOverlays(Williamstown); map.addOverlays(Ashland); centerByArray(Ashland, false, false); cntMarker += Ashland.length; map.addOverlays(Beaver_Dam); centerByArray(Beaver_Dam, false, false); cntMarker += Beaver_Dam.length; map.addOverlays(Bowling_Green); centerByArray(Bowling_Green, false, false); cntMarker += Bowling_Green.length; map.addOverlays(Brodhead); centerByArray(Brodhead, false, false); cntMarker += Brodhead.length; map.addOverlays(Fort_Thomas); centerByArray(Fort_Thomas, false, false); cntMarker += Fort_Thomas.length; map.addOverlays(Hanson); centerByArray(Hanson, false, false); cntMarker += Hanson.length; map.addOverlays(Henderson); centerByArray(Henderson, false, false); cntMarker += Henderson.length; map.addOverlays(Lexington); centerByArray(Lexington, false, false); cntMarker += Lexington.length; map.addOverlays(Louisville); centerByArray(Louisville, false, false); cntMarker += Louisville.length; map.addOverlays(Martin); centerByArray(Martin, false, false); cntMarker += Martin.length; map.addOverlays(Morgantown); centerByArray(Morgantown, false, false); cntMarker += Morgantown.length; map.addOverlays(Owensboro); centerByArray(Owensboro, false, false); cntMarker += Owensboro.length; map.addOverlays(Paint_Lick); centerByArray(Paint_Lick, false, false); cntMarker += Paint_Lick.length; map.addOverlays(Paintsville); centerByArray(Paintsville, false, false); cntMarker += Paintsville.length; map.addOverlays(Richmond); centerByArray(Richmond, false, false); cntMarker += Richmond.length; map.addOverlays(Sacramento); centerByArray(Sacramento, false, false); cntMarker += Sacramento.length; map.addOverlays(Salyersville); centerByArray(Salyersville, false, false); cntMarker += Salyersville.length; map.addOverlays(Summer_Shade); centerByArray(Summer_Shade, false, false); cntMarker += Summer_Shade.length; map.addOverlays(Whitesville); centerByArray(Whitesville, false, false); cntMarker += Whitesville.length; map.addOverlays(Williamstown); centerByArray(Williamstown, false, false); cntMarker += Williamstown.length; centerByArray(Brodhead,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///32565,32141,33210,33427,32217,33339,32567,32714,32695,32514,32829,32739,32545,32280,32421,32424,32583,32907,33053,33129,33065,33154,32425,32597,/all'); } }