function addMarkers()
{
mySelect = document.getElementById('selection');
Bow = [];Anacortes = [];Burlington = [];Mount_Vernon = [];_N_Burlington_Blvd = [];Sedro_woolley = [];Clear_Lake = [];Concrete = [];Edison = [];La_Conner = [];_Lyman_Avenue = [];mySelect.options[mySelect.options.length] = new Option("Anacortes schools",'all=Anacortes');
mySelect.options[mySelect.options.length] = new Option("Bow schools",'all=Bow');
mySelect.options[mySelect.options.length] = new Option("Burlington schools",'all=Burlington');
mySelect.options[mySelect.options.length] = new Option("Clear Lake schools",'all=Clear_Lake');
mySelect.options[mySelect.options.length] = new Option("Concrete schools",'all=Concrete');
mySelect.options[mySelect.options.length] = new Option("Edison schools",'all=Edison');
mySelect.options[mySelect.options.length] = new Option("La Conner schools",'all=La_Conner');
mySelect.options[mySelect.options.length] = new Option("Mount Vernon schools",'all=Mount_Vernon');
mySelect.options[mySelect.options.length] = new Option("Sedro woolley schools",'all=Sedro_woolley');
mySelect.options[mySelect.options.length] = new Option(" Lyman Avenue schools",'all=_Lyman_Avenue');
mySelect.options[mySelect.options.length] = new Option(" N Burlington Blvd schools",'all=_N_Burlington_Blvd');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Bow[Bow.length] = createMarker(new GPoint(-122.37734222,48.50878143),"
",iconRd);
mySelect.options[mySelect.options.length] = new Option("Allen Elementary School",'Bow=' + Bow.length);
Anacortes[Anacortes.length] = createMarker(new GPoint(-122.62220764,48.50818634),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Anacortes High School",'Anacortes=' + Anacortes.length);
Anacortes[Anacortes.length] = createMarker(new GPoint(-122.61770630,48.50433731),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Anacortes Middle School",'Anacortes=' + Anacortes.length);
Burlington[Burlington.length] = createMarker(new GPoint(-122.41777039,48.48703766),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Bay View Elementary School",'Burlington=' + Burlington.length);
Burlington[Burlington.length] = createMarker(new GPoint(-122.32279968,48.47563553),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Becc Elementary School",'Burlington=' + Burlington.length);
Mount_Vernon[Mount_Vernon.length] = createMarker(new GPoint(-122.24079132,48.40133667),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Big Lake Elementary School",'Mount_Vernon=' + Mount_Vernon.length);
_N_Burlington_Blvd[_N_Burlington_Blvd.length] = createMarker(new GPoint(-122.33580780,48.47724533),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Burlington Edison High School",'_N_Burlington_Blvd=' + _N_Burlington_Blvd.length);
_N_Burlington_Blvd[_N_Burlington_Blvd.length] = createMarker(new GPoint(-102.00432400,39.10388600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Burlington-edison Alternative School",'_N_Burlington_Blvd=' + _N_Burlington_Blvd.length);
Sedro_woolley[Sedro_woolley.length] = createMarker(new GPoint(-122.22541809,48.51196289),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Cascade Middle School",'Sedro_woolley=' + Sedro_woolley.length);
Mount_Vernon[Mount_Vernon.length] = createMarker(new GPoint(-122.29689026,48.44266129),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Centennial Elementary School",'Mount_Vernon=' + Mount_Vernon.length);
Sedro_woolley[Sedro_woolley.length] = createMarker(new GPoint(-122.23147583,48.50136185),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Central Elementary School",'Sedro_woolley=' + Sedro_woolley.length);
Clear_Lake[Clear_Lake.length] = createMarker(new GPoint(-122.23014069,48.46697998),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Clear Lake Elementary School",'Clear_Lake=' + Clear_Lake.length);
Concrete[Concrete.length] = createMarker(new GPoint(-121.75930786,48.53115463),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Concrete Elementary School",'Concrete=' + Concrete.length);
Concrete[Concrete.length] = createMarker(new GPoint(-121.75900400,48.53810000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Concrete High School",'Concrete=' + Concrete.length);
Concrete[Concrete.length] = createMarker(new GPoint(-121.75614929,48.53139114),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Concrete Middle School",'Concrete=' + Concrete.length);
Mount_Vernon[Mount_Vernon.length] = createMarker(new GPoint(-122.31901550,48.34076309),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Conway School",'Mount_Vernon=' + Mount_Vernon.length);
Anacortes[Anacortes.length] = createMarker(new GPoint(-122.61770630,48.50436401),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Cooperatives",'Anacortes=' + Anacortes.length);
Anacortes[Anacortes.length] = createMarker(new GPoint(-122.63349915,48.49499893),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Decatur Elementary School",'Anacortes=' + Anacortes.length);
Edison[Edison.length] = createMarker(new GPoint(-122.44039154,48.56129456),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Edison Elementary School",'Edison=' + Edison.length);
Sedro_woolley[Sedro_woolley.length] = createMarker(new GPoint(-122.22058868,48.51509857),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Evergreen Elementary School",'Sedro_woolley=' + Sedro_woolley.length);
Anacortes[Anacortes.length] = createMarker(new GPoint(-122.58319855,48.43519974),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Fidalgo Elementary School",'Anacortes=' + Anacortes.length);
Anacortes[Anacortes.length] = createMarker(new GPoint(-122.62189484,48.50206375),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Island View Elementary School",'Anacortes=' + Anacortes.length);
Mount_Vernon[Mount_Vernon.length] = createMarker(new GPoint(-122.31875610,48.40661621),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Jefferson Elementary School",'Mount_Vernon=' + Mount_Vernon.length);
La_Conner[La_Conner.length] = createMarker(new GPoint(-122.49041748,48.39212036),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("La Conner Elementary School",'La_Conner=' + La_Conner.length);
La_Conner[La_Conner.length] = createMarker(new GPoint(-122.49041748,48.39212036),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("La Conner High School",'La_Conner=' + La_Conner.length);
La_Conner[La_Conner.length] = createMarker(new GPoint(-121.81536102,47.86310959),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("La Conner Middle School",'La_Conner=' + La_Conner.length);
Mount_Vernon[Mount_Vernon.length] = createMarker(new GPoint(-122.31319427,48.43143845),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("La Venture Middle School",'Mount_Vernon=' + Mount_Vernon.length);
Anacortes[Anacortes.length] = createMarker(new GPoint(-122.61259460,48.49945450),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Learning Opportunity Center",'Anacortes=' + Anacortes.length);
Mount_Vernon[Mount_Vernon.length] = createMarker(new GPoint(-122.32780457,48.41552353),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Lincoln Elementary School",'Mount_Vernon=' + Mount_Vernon.length);
Mount_Vernon[Mount_Vernon.length] = createMarker(new GPoint(-122.31309509,48.41299057),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Little Mountain Elementary School",'Mount_Vernon=' + Mount_Vernon.length);
Burlington[Burlington.length] = createMarker(new GPoint(-122.31929016,48.46935272),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Lucille Umbarger Elementary School",'Burlington=' + Burlington.length);
_Lyman_Avenue[_Lyman_Avenue.length] = createMarker(new GPoint(-122.05735779,48.52733994),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Lyman Elementary School",'_Lyman_Avenue=' + _Lyman_Avenue.length);
Mount_Vernon[Mount_Vernon.length] = createMarker(new GPoint(-122.32953644,48.42863846),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Madison Elementary School",'Mount_Vernon=' + Mount_Vernon.length);
Sedro_woolley[Sedro_woolley.length] = createMarker(new GPoint(-122.22949219,48.49993515),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Mary Purcell Elementary School",'Sedro_woolley=' + Sedro_woolley.length);
Mount_Vernon[Mount_Vernon.length] = createMarker(new GPoint(-122.31184387,48.41346359),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Mount Baker Middle School",'Mount_Vernon=' + Mount_Vernon.length);
Anacortes[Anacortes.length] = createMarker(new GPoint(-122.61932373,48.48786163),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Mount Erie Elementary School",'Anacortes=' + Anacortes.length);
Mount_Vernon[Mount_Vernon.length] = createMarker(new GPoint(-122.32941437,48.42336273),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Mount Vernon High School",'Mount_Vernon=' + Mount_Vernon.length);
Mount_Vernon[Mount_Vernon.length] = createMarker(new GPoint(-122.32605743,48.42123795),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Mount Vernon Special Ed",'Mount_Vernon=' + Mount_Vernon.length);
Anacortes[Anacortes.length] = createMarker(new GPoint(-122.61770630,48.50436401),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Parent Partner Program",'Anacortes=' + Anacortes.length);
Anacortes[Anacortes.length] = createMarker(new GPoint(-122.62220764,48.50818634),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Running Start High School",'Anacortes=' + Anacortes.length);
Sedro_woolley[Sedro_woolley.length] = createMarker(new GPoint(-122.22559357,48.58594894),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Samish Elementary School",'Sedro_woolley=' + Sedro_woolley.length);
Anacortes[Anacortes.length] = createMarker(new GPoint(-122.61249542,48.50751495),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Secret Harbor High School",'Anacortes=' + Anacortes.length);
Sedro_woolley[Sedro_woolley.length] = createMarker(new GPoint(-122.23728943,48.50027847),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Sedro Woolley Senior High School",'Sedro_woolley=' + Sedro_woolley.length);
Sedro_woolley[Sedro_woolley.length] = createMarker(new GPoint(-122.25269318,48.50753784),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Sedro Woolley Special Programs",'Sedro_woolley=' + Sedro_woolley.length);
Mount_Vernon[Mount_Vernon.length] = createMarker(new GPoint(-122.33640289,48.41813660),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Skagit Co Detention Center",'Mount_Vernon=' + Mount_Vernon.length);
Mount_Vernon[Mount_Vernon.length] = createMarker(new GPoint(-122.31334900,48.42124300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Skagit Family Learning Center Mvsd",'Mount_Vernon=' + Mount_Vernon.length);
Concrete[Concrete.length] = createMarker(new GPoint(-121.84568024,48.54076004),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Skagit River School House",'Concrete=' + Concrete.length);
Burlington[Burlington.length] = createMarker(new GPoint(-122.32279968,48.47563553),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Sparc Elementary School",'Burlington=' + Burlington.length);
Sedro_woolley[Sedro_woolley.length] = createMarker(new GPoint(-122.22759247,48.50343704),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("State Street High School",'Sedro_woolley=' + Sedro_woolley.length);
Concrete[Concrete.length] = createMarker(new GPoint(-121.75930786,48.53115463),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Twin Cedars High School",'Concrete=' + Concrete.length);
Mount_Vernon[Mount_Vernon.length] = createMarker(new GPoint(-122.34735107,48.42076111),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Washington Elementary School",'Mount_Vernon=' + Mount_Vernon.length);
Burlington[Burlington.length] = createMarker(new GPoint(-122.34116364,48.47676849),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("West View Elementary School",'Burlington=' + Burlington.length);
Anacortes[Anacortes.length] = createMarker(new GPoint(-122.61752319,48.51257324),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Whitney Elementary School",'Anacortes=' + Anacortes.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(Anacortes);
map.removeOverlays(Bow);
map.removeOverlays(Burlington);
map.removeOverlays(Clear_Lake);
map.removeOverlays(Concrete);
map.removeOverlays(Edison);
map.removeOverlays(La_Conner);
map.removeOverlays(Mount_Vernon);
map.removeOverlays(Sedro_woolley);
map.removeOverlays(_Lyman_Avenue);
map.removeOverlays(_N_Burlington_Blvd);
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(Bow);map.removeOverlays(Anacortes);
map.removeOverlays(Bow);
map.removeOverlays(Burlington);
map.removeOverlays(Clear_Lake);
map.removeOverlays(Concrete);
map.removeOverlays(Edison);
map.removeOverlays(La_Conner);
map.removeOverlays(Mount_Vernon);
map.removeOverlays(Sedro_woolley);
map.removeOverlays(_Lyman_Avenue);
map.removeOverlays(_N_Burlington_Blvd);
map.addOverlays(Anacortes);
centerByArray(Anacortes, false, false);
cntMarker += Anacortes.length;
map.addOverlays(Bow);
centerByArray(Bow, false, false);
cntMarker += Bow.length;
map.addOverlays(Burlington);
centerByArray(Burlington, false, false);
cntMarker += Burlington.length;
map.addOverlays(Clear_Lake);
centerByArray(Clear_Lake, false, false);
cntMarker += Clear_Lake.length;
map.addOverlays(Concrete);
centerByArray(Concrete, false, false);
cntMarker += Concrete.length;
map.addOverlays(Edison);
centerByArray(Edison, false, false);
cntMarker += Edison.length;
map.addOverlays(La_Conner);
centerByArray(La_Conner, false, false);
cntMarker += La_Conner.length;
map.addOverlays(Mount_Vernon);
centerByArray(Mount_Vernon, false, false);
cntMarker += Mount_Vernon.length;
map.addOverlays(Sedro_woolley);
centerByArray(Sedro_woolley, false, false);
cntMarker += Sedro_woolley.length;
map.addOverlays(_Lyman_Avenue);
centerByArray(_Lyman_Avenue, false, false);
cntMarker += _Lyman_Avenue.length;
map.addOverlays(_N_Burlington_Blvd);
centerByArray(_N_Burlington_Blvd, false, false);
cntMarker += _N_Burlington_Blvd.length;
centerByArray(Bow,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');
}
}