function addMarkers()
{
mySelect = document.getElementById('selection');
Bickleton = [];_Centerville_Hwy = [];White_Salmon = [];Dallesport = [];Glenwood = [];Goldendale = [];Klickitat = [];Lyle = [];Roosevelt = [];Trout_Lake = [];Wishram = [];mySelect.options[mySelect.options.length] = new Option("Bickleton schools",'all=Bickleton');
mySelect.options[mySelect.options.length] = new Option("Dallesport schools",'all=Dallesport');
mySelect.options[mySelect.options.length] = new Option("Glenwood schools",'all=Glenwood');
mySelect.options[mySelect.options.length] = new Option("Goldendale schools",'all=Goldendale');
mySelect.options[mySelect.options.length] = new Option("Klickitat schools",'all=Klickitat');
mySelect.options[mySelect.options.length] = new Option("Lyle schools",'all=Lyle');
mySelect.options[mySelect.options.length] = new Option("Roosevelt schools",'all=Roosevelt');
mySelect.options[mySelect.options.length] = new Option("Trout Lake schools",'all=Trout_Lake');
mySelect.options[mySelect.options.length] = new Option("White Salmon schools",'all=White_Salmon');
mySelect.options[mySelect.options.length] = new Option("Wishram schools",'all=Wishram');
mySelect.options[mySelect.options.length] = new Option(" Centerville Hwy schools",'all=_Centerville_Hwy');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Bickleton[Bickleton.length] = createMarker(new GPoint(-120.30249786,45.99776459),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bickleton Elementary & High School",'Bickleton=' + Bickleton.length);
_Centerville_Hwy[_Centerville_Hwy.length] = createMarker(new GPoint(-121.03718567,45.71604156),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Centerville Elementary School",'_Centerville_Hwy=' + _Centerville_Hwy.length);
White_Salmon[White_Salmon.length] = createMarker(new GPoint(-121.49355316,45.74236298),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Columbia High School",'White_Salmon=' + White_Salmon.length);
Dallesport[Dallesport.length] = createMarker(new GPoint(-121.17559814,45.61766434),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Dallesport Elementary School",'Dallesport=' + Dallesport.length);
Glenwood[Glenwood.length] = createMarker(new GPoint(-121.28959656,46.01922226),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Glenwood Elementary School",'Glenwood=' + Glenwood.length);
Glenwood[Glenwood.length] = createMarker(new GPoint(-121.28959656,46.01922226),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Glenwood Secondary",'Glenwood=' + Glenwood.length);
Goldendale[Goldendale.length] = createMarker(new GPoint(-120.81412506,45.81373596),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Goldendale High School",'Goldendale=' + Goldendale.length);
Goldendale[Goldendale.length] = createMarker(new GPoint(-120.81523895,45.81906128),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Goldendale Middle School",'Goldendale=' + Goldendale.length);
Goldendale[Goldendale.length] = createMarker(new GPoint(-120.81729889,45.81801987),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Goldendale Primary School",'Goldendale=' + Goldendale.length);
Goldendale[Goldendale.length] = createMarker(new GPoint(-120.81753000,45.81698200),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Goldendale Support Service Center",'Goldendale=' + Goldendale.length);
White_Salmon[White_Salmon.length] = createMarker(new GPoint(-121.48679352,45.73035049),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Hulan L Whitson Elementary School",'White_Salmon=' + White_Salmon.length);
Klickitat[Klickitat.length] = createMarker(new GPoint(-121.06030273,45.84199905),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Klickitat Elementary & High School",'Klickitat=' + Klickitat.length);
Lyle[Lyle.length] = createMarker(new GPoint(-121.28070068,45.69490051),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Lyle High School",'Lyle=' + Lyle.length);
Lyle[Lyle.length] = createMarker(new GPoint(-121.28262329,45.69514465),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Lyle Middle School",'Lyle=' + Lyle.length);
Roosevelt[Roosevelt.length] = createMarker(new GPoint(-120.21839905,45.74161911),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Roosevelt Elementary School",'Roosevelt=' + Roosevelt.length);
Trout_Lake[Trout_Lake.length] = createMarker(new GPoint(-121.51961517,45.99121475),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Trout Lake Elementary School",'Trout_Lake=' + Trout_Lake.length);
Trout_Lake[Trout_Lake.length] = createMarker(new GPoint(-121.51961517,45.99121475),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Trout Lake School",'Trout_Lake=' + Trout_Lake.length);
White_Salmon[White_Salmon.length] = createMarker(new GPoint(-121.49451447,45.73959351),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Wayne M Henkle Middle School",'White_Salmon=' + White_Salmon.length);
Wishram[Wishram.length] = createMarker(new GPoint(-120.96317291,45.66038895),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Wishram High And Elementary School",'Wishram=' + Wishram.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(Bickleton);
map.removeOverlays(Dallesport);
map.removeOverlays(Glenwood);
map.removeOverlays(Goldendale);
map.removeOverlays(Klickitat);
map.removeOverlays(Lyle);
map.removeOverlays(Roosevelt);
map.removeOverlays(Trout_Lake);
map.removeOverlays(White_Salmon);
map.removeOverlays(Wishram);
map.removeOverlays(_Centerville_Hwy);
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(Bickleton);map.removeOverlays(Bickleton);
map.removeOverlays(Dallesport);
map.removeOverlays(Glenwood);
map.removeOverlays(Goldendale);
map.removeOverlays(Klickitat);
map.removeOverlays(Lyle);
map.removeOverlays(Roosevelt);
map.removeOverlays(Trout_Lake);
map.removeOverlays(White_Salmon);
map.removeOverlays(Wishram);
map.removeOverlays(_Centerville_Hwy);
map.addOverlays(Bickleton);
centerByArray(Bickleton, false, false);
cntMarker += Bickleton.length;
map.addOverlays(Dallesport);
centerByArray(Dallesport, false, false);
cntMarker += Dallesport.length;
map.addOverlays(Glenwood);
centerByArray(Glenwood, false, false);
cntMarker += Glenwood.length;
map.addOverlays(Goldendale);
centerByArray(Goldendale, false, false);
cntMarker += Goldendale.length;
map.addOverlays(Klickitat);
centerByArray(Klickitat, false, false);
cntMarker += Klickitat.length;
map.addOverlays(Lyle);
centerByArray(Lyle, false, false);
cntMarker += Lyle.length;
map.addOverlays(Roosevelt);
centerByArray(Roosevelt, false, false);
cntMarker += Roosevelt.length;
map.addOverlays(Trout_Lake);
centerByArray(Trout_Lake, false, false);
cntMarker += Trout_Lake.length;
map.addOverlays(White_Salmon);
centerByArray(White_Salmon, false, false);
cntMarker += White_Salmon.length;
map.addOverlays(Wishram);
centerByArray(Wishram, false, false);
cntMarker += Wishram.length;
map.addOverlays(_Centerville_Hwy);
centerByArray(_Centerville_Hwy, false, false);
cntMarker += _Centerville_Hwy.length;
centerByArray(Bickleton,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');
}
}