function addMarkers()
{
mySelect = document.getElementById('selection');
Olympia = [];Lacey = [];Yelm = [];Tumwater = [];Rochester = [];Littlerock = [];Centralia = [];Tenino = [];Rainier = [];_Yelm_Hwy_Se = [];_Yelm_Ave_W = [];mySelect.options[mySelect.options.length] = new Option("Centralia schools",'all=Centralia');
mySelect.options[mySelect.options.length] = new Option("Lacey schools",'all=Lacey');
mySelect.options[mySelect.options.length] = new Option("Littlerock schools",'all=Littlerock');
mySelect.options[mySelect.options.length] = new Option("Olympia schools",'all=Olympia');
mySelect.options[mySelect.options.length] = new Option("Rainier schools",'all=Rainier');
mySelect.options[mySelect.options.length] = new Option("Rochester schools",'all=Rochester');
mySelect.options[mySelect.options.length] = new Option("Tenino schools",'all=Tenino');
mySelect.options[mySelect.options.length] = new Option("Tumwater schools",'all=Tumwater');
mySelect.options[mySelect.options.length] = new Option("Yelm schools",'all=Yelm');
mySelect.options[mySelect.options.length] = new Option(" Yelm Ave W schools",'all=_Yelm_Ave_W');
mySelect.options[mySelect.options.length] = new Option(" Yelm Hwy Se schools",'all=_Yelm_Hwy_Se');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Olympia[Olympia.length] = createMarker(new GPoint(-122.94502258,46.97578812),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("A G West Black Hills High School",'Olympia=' + Olympia.length);
Olympia[Olympia.length] = createMarker(new GPoint(-122.88790131,47.04398346),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Avanti High School",'Olympia=' + Olympia.length);
Olympia[Olympia.length] = createMarker(new GPoint(-122.96239200,46.98227300),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Black Lake Elementary School",'Olympia=' + Olympia.length);
Olympia[Olympia.length] = createMarker(new GPoint(-122.88599396,47.13623810),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Boston Harbor Elementary School",'Olympia=' + Olympia.length);
Olympia[Olympia.length] = createMarker(new GPoint(-122.93456268,47.05146408),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Capital High School",'Olympia=' + Olympia.length);
Olympia[Olympia.length] = createMarker(new GPoint(-122.86470032,47.00566483),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Centennial Elementary School",'Olympia=' + Olympia.length);
Lacey[Lacey.length] = createMarker(new GPoint(-122.82798004,47.05396271),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Chinook Middle School",'Lacey=' + Lacey.length);
Olympia[Olympia.length] = createMarker(new GPoint(-122.83359528,46.96146393),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("East Olympia Elementary School",'Olympia=' + Olympia.length);
Lacey[Lacey.length] = createMarker(new GPoint(-122.75883484,47.02019119),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Evergreen Forest Elementary School",'Lacey=' + Lacey.length);
Yelm[Yelm.length] = createMarker(new GPoint(-122.58947754,46.94188690),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Fort Stevens Elementary School",'Yelm=' + Yelm.length);
Olympia[Olympia.length] = createMarker(new GPoint(-122.91916656,47.04758072),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Garfield Elementary School",'Olympia=' + Olympia.length);
Tumwater[Tumwater.length] = createMarker(new GPoint(-122.92819977,46.96743774),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("George Washington Bush Middle School",'Tumwater=' + Tumwater.length);
Rochester[Rochester.length] = createMarker(new GPoint(-123.04594421,46.79443359),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Grand Mound Elementary School",'Rochester=' + Rochester.length);
Olympia[Olympia.length] = createMarker(new GPoint(-123.01918793,47.07971573),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Griffin Elementary School",'Olympia=' + Olympia.length);
Rochester[Rochester.length] = createMarker(new GPoint(-123.09097290,46.82166290),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("H.e.a.r.t. High School",'Rochester=' + Rochester.length);
Lacey[Lacey.length] = createMarker(new GPoint(-122.82240295,46.98686218),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Horizons Elementary School",'Lacey=' + Lacey.length);
Olympia[Olympia.length] = createMarker(new GPoint(-122.92780304,47.05173874),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Jefferson Middle School",'Olympia=' + Olympia.length);
Olympia[Olympia.length] = createMarker(new GPoint(-122.89923096,47.03796005),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Julia Butler Hansen Elementary School",'Olympia=' + Olympia.length);
Lacey[Lacey.length] = createMarker(new GPoint(-122.82296753,47.01341248),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Komachin Middle School",'Lacey=' + Lacey.length);
Lacey[Lacey.length] = createMarker(new GPoint(-122.80366516,47.03038788),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Lacey Elementary School",'Lacey=' + Lacey.length);
Yelm[Yelm.length] = createMarker(new GPoint(-122.48721900,46.85119500),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Lackamas Elementary School",'Yelm=' + Yelm.length);
Lacey[Lacey.length] = createMarker(new GPoint(-122.80139160,47.00654221),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Lakes Elementary School",'Lacey=' + Lacey.length);
Olympia[Olympia.length] = createMarker(new GPoint(-122.92656708,47.07076645),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Leland P Brown Elementary School",'Olympia=' + Olympia.length);
Olympia[Olympia.length] = createMarker(new GPoint(-122.89919281,47.03006363),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Lincoln Elementary School",'Olympia=' + Olympia.length);
Littlerock[Littlerock.length] = createMarker(new GPoint(-123.01678467,46.90246964),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Littlerock Elementary School",'Littlerock=' + Littlerock.length);
Lacey[Lacey.length] = createMarker(new GPoint(-122.77870178,47.04693604),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Lydia Hawk Elementary School",'Lacey=' + Lacey.length);
Olympia[Olympia.length] = createMarker(new GPoint(-122.88595581,47.04409409),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Madison Elementary School",'Olympia=' + Olympia.length);
Centralia[Centralia.length] = createMarker(new GPoint(-123.02696991,46.79352188),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Maple Lane School",'Centralia=' + Centralia.length);
Olympia[Olympia.length] = createMarker(new GPoint(-122.85621643,47.01823807),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Mckenny Elementary School",'Olympia=' + Olympia.length);
Olympia[Olympia.length] = createMarker(new GPoint(-122.97745300,47.13350300),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Mclane Elementary School",'Olympia=' + Olympia.length);
Lacey[Lacey.length] = createMarker(new GPoint(-122.74153137,47.04746246),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Meadows Elementary School",'Lacey=' + Lacey.length);
Tumwater[Tumwater.length] = createMarker(new GPoint(-122.91062164,47.00511551),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Michael T Simmons Elementary School",'Tumwater=' + Tumwater.length);
Yelm[Yelm.length] = createMarker(new GPoint(-122.56269836,46.89960098),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Mill Pond Intermediate School",'Yelm=' + Yelm.length);
Lacey[Lacey.length] = createMarker(new GPoint(-122.82309723,47.02956390),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Mountain View Elementary School",'Lacey=' + Lacey.length);
Tumwater[Tumwater.length] = createMarker(new GPoint(-122.91319300,46.98200700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("New Market High School",'Tumwater=' + Tumwater.length);
Lacey[Lacey.length] = createMarker(new GPoint(-122.76844025,47.04603577),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Nisqually Middle School",'Lacey=' + Lacey.length);
Lacey[Lacey.length] = createMarker(new GPoint(-122.83340454,47.05154037),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("North Thurston High School",'Lacey=' + Lacey.length);
Olympia[Olympia.length] = createMarker(new GPoint(-122.88498688,47.01673889),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Olympia High School",'Olympia=' + Olympia.length);
Lacey[Lacey.length] = createMarker(new GPoint(-122.78049469,47.05857086),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Olympic View Elementary School",'Lacey=' + Lacey.length);
Tenino[Tenino.length] = createMarker(new GPoint(-122.84851837,46.85744476),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Parkside Elementary School",'Tenino=' + Tenino.length);
Tumwater[Tumwater.length] = createMarker(new GPoint(-122.90947723,47.00355911),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Peter G Schmidt Elementary School",'Tumwater=' + Tumwater.length);
Olympia[Olympia.length] = createMarker(new GPoint(-122.87943268,47.01976395),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Pioneer Elementary School",'Olympia=' + Olympia.length);
Lacey[Lacey.length] = createMarker(new GPoint(-122.82730103,47.06195831),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Pleasant Glade Elementary School",'Lacey=' + Lacey.length);
Rainier[Rainier.length] = createMarker(new GPoint(-122.68713379,46.88808060),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Rainier Middle School",'Rainier=' + Rainier.length);
Rainier[Rainier.length] = createMarker(new GPoint(-122.69148254,46.88253021),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Rainier Primary School",'Rainier=' + Rainier.length);
Rainier[Rainier.length] = createMarker(new GPoint(-122.69014740,46.88620377),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Rainier Senior High School",'Rainier=' + Rainier.length);
Olympia[Olympia.length] = createMarker(new GPoint(-122.88966370,47.06291962),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Reeves Middle School",'Olympia=' + Olympia.length);
Lacey[Lacey.length] = createMarker(new GPoint(-122.74993134,47.05952835),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("River Ridge High School",'Lacey=' + Lacey.length);
Rochester[Rochester.length] = createMarker(new GPoint(-123.04820251,46.80096054),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Rochester High School",'Rochester=' + Rochester.length);
Rochester[Rochester.length] = createMarker(new GPoint(-123.09069824,46.82193756),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Rochester Middle School",'Rochester=' + Rochester.length);
Rochester[Rochester.length] = createMarker(new GPoint(-123.09604645,46.82193756),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Rochester Primary School",'Rochester=' + Rochester.length);
Olympia[Olympia.length] = createMarker(new GPoint(-122.88455963,47.05706406),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Roosevelt Elementary School",'Olympia=' + Olympia.length);
Olympia[Olympia.length] = createMarker(new GPoint(-122.94502258,46.97578812),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Secondary Options",'Olympia=' + Olympia.length);
Lacey[Lacey.length] = createMarker(new GPoint(-122.77249908,47.02976227),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Seven Oaks Elementary School",'Lacey=' + Lacey.length);
Lacey[Lacey.length] = createMarker(new GPoint(-122.83390045,47.08640671),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("South Bay Elementary School",'Lacey=' + Lacey.length);
Lacey[Lacey.length] = createMarker(new GPoint(-122.80429840,46.99993515),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("South Sound High School",'Lacey=' + Lacey.length);
_Yelm_Hwy_Se[_Yelm_Hwy_Se.length] = createMarker(new GPoint(-122.56269836,46.89960098),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Southworth Elementary School",'_Yelm_Hwy_Se=' + _Yelm_Hwy_Se.length);
Tenino[Tenino.length] = createMarker(new GPoint(-122.84660339,46.86220169),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Tenino Elementary School",'Tenino=' + Tenino.length);
Tenino[Tenino.length] = createMarker(new GPoint(-122.85624695,46.85813141),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Tenino High School",'Tenino=' + Tenino.length);
Tenino[Tenino.length] = createMarker(new GPoint(-122.84660339,46.86220169),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Tenino Middle School",'Tenino=' + Tenino.length);
Olympia[Olympia.length] = createMarker(new GPoint(-122.95332336,47.06325150),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Thurgood Marshall Middle School",'Olympia=' + Olympia.length);
Tumwater[Tumwater.length] = createMarker(new GPoint(-122.91008759,47.03135681),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Thurs Co Juv Dept/tumwater West E",'Tumwater=' + Tumwater.length);
Lacey[Lacey.length] = createMarker(new GPoint(-122.80220032,47.00743484),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Timberline High School",'Lacey=' + Lacey.length);
Tumwater[Tumwater.length] = createMarker(new GPoint(-122.91492462,46.98553848),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Tumwater High School",'Tumwater=' + Tumwater.length);
Tumwater[Tumwater.length] = createMarker(new GPoint(-122.92199707,47.01818848),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Tumwater Hill Elementary School",'Tumwater=' + Tumwater.length);
Tumwater[Tumwater.length] = createMarker(new GPoint(-122.92420197,46.99165726),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Tumwater Middle School",'Tumwater=' + Tumwater.length);
Tumwater[Tumwater.length] = createMarker(new GPoint(-122.91320038,46.96707916),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Vocational Skills Center New Market",'Tumwater=' + Tumwater.length);
Olympia[Olympia.length] = createMarker(new GPoint(-122.70430756,47.06691360),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Wa He Lut Indian School",'Olympia=' + Olympia.length);
Olympia[Olympia.length] = createMarker(new GPoint(-122.87300110,47.02006149),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Washington Middle School",'Olympia=' + Olympia.length);
Lacey[Lacey.length] = createMarker(new GPoint(-122.78013611,47.00534439),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Woodland Elementary School",'Lacey=' + Lacey.length);
Yelm[Yelm.length] = createMarker(new GPoint(-122.56269836,46.89960098),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Yelm Extension School",'Yelm=' + Yelm.length);
_Yelm_Ave_W[_Yelm_Ave_W.length] = createMarker(new GPoint(-122.62261963,46.95046234),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Yelm High School 12",'_Yelm_Ave_W=' + _Yelm_Ave_W.length);
_Yelm_Ave_W[_Yelm_Ave_W.length] = createMarker(new GPoint(-122.61026764,46.94422150),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Yelm Middle School",'_Yelm_Ave_W=' + _Yelm_Ave_W.length);
Yelm[Yelm.length] = createMarker(new GPoint(-122.58963776,46.92706299),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Yelm Prairie Elementary School",'Yelm=' + Yelm.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(Centralia);
map.removeOverlays(Lacey);
map.removeOverlays(Littlerock);
map.removeOverlays(Olympia);
map.removeOverlays(Rainier);
map.removeOverlays(Rochester);
map.removeOverlays(Tenino);
map.removeOverlays(Tumwater);
map.removeOverlays(Yelm);
map.removeOverlays(_Yelm_Ave_W);
map.removeOverlays(_Yelm_Hwy_Se);
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(Olympia);map.removeOverlays(Centralia);
map.removeOverlays(Lacey);
map.removeOverlays(Littlerock);
map.removeOverlays(Olympia);
map.removeOverlays(Rainier);
map.removeOverlays(Rochester);
map.removeOverlays(Tenino);
map.removeOverlays(Tumwater);
map.removeOverlays(Yelm);
map.removeOverlays(_Yelm_Ave_W);
map.removeOverlays(_Yelm_Hwy_Se);
map.addOverlays(Centralia);
centerByArray(Centralia, false, false);
cntMarker += Centralia.length;
map.addOverlays(Lacey);
centerByArray(Lacey, false, false);
cntMarker += Lacey.length;
map.addOverlays(Littlerock);
centerByArray(Littlerock, false, false);
cntMarker += Littlerock.length;
map.addOverlays(Olympia);
centerByArray(Olympia, false, false);
cntMarker += Olympia.length;
map.addOverlays(Rainier);
centerByArray(Rainier, false, false);
cntMarker += Rainier.length;
map.addOverlays(Rochester);
centerByArray(Rochester, false, false);
cntMarker += Rochester.length;
map.addOverlays(Tenino);
centerByArray(Tenino, false, false);
cntMarker += Tenino.length;
map.addOverlays(Tumwater);
centerByArray(Tumwater, false, false);
cntMarker += Tumwater.length;
map.addOverlays(Yelm);
centerByArray(Yelm, false, false);
cntMarker += Yelm.length;
map.addOverlays(_Yelm_Ave_W);
centerByArray(_Yelm_Ave_W, false, false);
cntMarker += _Yelm_Ave_W.length;
map.addOverlays(_Yelm_Hwy_Se);
centerByArray(_Yelm_Hwy_Se, false, false);
cntMarker += _Yelm_Hwy_Se.length;
centerByArray(Olympia,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');
}
}