function addMarkers()
{
mySelect = document.getElementById('selection');
Cle_Elum = [];Cle_Eum = [];Ellensburg = [];Easton = [];Kittitas = [];_N_Thorp_Hwy = [];mySelect.options[mySelect.options.length] = new Option("Cle Elum schools",'all=Cle_Elum');
mySelect.options[mySelect.options.length] = new Option("Cle Eum schools",'all=Cle_Eum');
mySelect.options[mySelect.options.length] = new Option("Easton schools",'all=Easton');
mySelect.options[mySelect.options.length] = new Option("Ellensburg schools",'all=Ellensburg');
mySelect.options[mySelect.options.length] = new Option("Kittitas schools",'all=Kittitas');
mySelect.options[mySelect.options.length] = new Option(" N Thorp Hwy schools",'all=_N_Thorp_Hwy');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Cle_Elum[Cle_Elum.length] = createMarker(new GPoint(-120.93788147,47.19667816),"
",iconRd);
mySelect.options[mySelect.options.length] = new Option("Cle Elum Roslyn Elementary School",'Cle_Elum=' + Cle_Elum.length);
Cle_Eum[Cle_Eum.length] = createMarker(new GPoint(-120.98506165,47.21249771),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Cle Elum Roslyn High School",'Cle_Eum=' + Cle_Eum.length);
Cle_Elum[Cle_Elum.length] = createMarker(new GPoint(-120.93724700,47.19286900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Cle Elum-roslyn Alternative School",'Cle_Elum=' + Cle_Elum.length);
Ellensburg[Ellensburg.length] = createMarker(new GPoint(-120.57080078,46.97007370),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Damman Elementary School",'Ellensburg=' + Ellensburg.length);
Easton[Easton.length] = createMarker(new GPoint(-121.17649078,47.23680496),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Easton School",'Easton=' + Easton.length);
Ellensburg[Ellensburg.length] = createMarker(new GPoint(-119.98761749,46.94430161),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Ellensburg Developmental Preschool",'Ellensburg=' + Ellensburg.length);
Ellensburg[Ellensburg.length] = createMarker(new GPoint(-120.52819061,46.99471283),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Ellensburg High School",'Ellensburg=' + Ellensburg.length);
Kittitas[Kittitas.length] = createMarker(new GPoint(-120.41889954,46.98812103),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Kittitas Elementary School",'Kittitas=' + Kittitas.length);
Kittitas[Kittitas.length] = createMarker(new GPoint(-120.41889954,46.98812103),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Kittitas High School",'Kittitas=' + Kittitas.length);
Ellensburg[Ellensburg.length] = createMarker(new GPoint(-120.54008484,46.99137115),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Lincoln Elementary School",'Ellensburg=' + Ellensburg.length);
Ellensburg[Ellensburg.length] = createMarker(new GPoint(-120.54277802,46.99227905),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Morgan Middle School",'Ellensburg=' + Ellensburg.length);
Ellensburg[Ellensburg.length] = createMarker(new GPoint(-120.55835724,47.00673676),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Mt. Stuart Elementary School",'Ellensburg=' + Ellensburg.length);
Ellensburg[Ellensburg.length] = createMarker(new GPoint(-120.32044983,47.01578140),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Parke Creek Treatment Center",'Ellensburg=' + Ellensburg.length);
_N_Thorp_Hwy[_N_Thorp_Hwy.length] = createMarker(new GPoint(-120.94149780,47.08000183),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Thorp Elementary & Jr Senior High School",'_N_Thorp_Hwy=' + _N_Thorp_Hwy.length);
Ellensburg[Ellensburg.length] = createMarker(new GPoint(-120.52464294,46.99482727),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Valley View Elementary School",'Ellensburg=' + Ellensburg.length);
Cle_Elum[Cle_Elum.length] = createMarker(new GPoint(-120.98506165,47.21250916),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Walter Strom Middle School",'Cle_Elum=' + Cle_Elum.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(Cle_Elum);
map.removeOverlays(Cle_Eum);
map.removeOverlays(Easton);
map.removeOverlays(Ellensburg);
map.removeOverlays(Kittitas);
map.removeOverlays(_N_Thorp_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(Cle_Elum);map.removeOverlays(Cle_Elum);
map.removeOverlays(Cle_Eum);
map.removeOverlays(Easton);
map.removeOverlays(Ellensburg);
map.removeOverlays(Kittitas);
map.removeOverlays(_N_Thorp_Hwy);
map.addOverlays(Cle_Elum);
centerByArray(Cle_Elum, false, false);
cntMarker += Cle_Elum.length;
map.addOverlays(Cle_Eum);
centerByArray(Cle_Eum, false, false);
cntMarker += Cle_Eum.length;
map.addOverlays(Easton);
centerByArray(Easton, false, false);
cntMarker += Easton.length;
map.addOverlays(Ellensburg);
centerByArray(Ellensburg, false, false);
cntMarker += Ellensburg.length;
map.addOverlays(Kittitas);
centerByArray(Kittitas, false, false);
cntMarker += Kittitas.length;
map.addOverlays(_N_Thorp_Hwy);
centerByArray(_N_Thorp_Hwy, false, false);
cntMarker += _N_Thorp_Hwy.length;
centerByArray(Cle_Elum,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');
}
}