function addMarkers()
{
mySelect = document.getElementById('selection');
Waconia = [];Chanhassen = [];Chaska = [];Norwood_Young_America = [];Carver = [];Excelsior = [];Victoria = [];Watertown = [];mySelect.options[mySelect.options.length] = new Option("Carver schools",'all=Carver');
mySelect.options[mySelect.options.length] = new Option("Chanhassen schools",'all=Chanhassen');
mySelect.options[mySelect.options.length] = new Option("Chaska schools",'all=Chaska');
mySelect.options[mySelect.options.length] = new Option("Excelsior schools",'all=Excelsior');
mySelect.options[mySelect.options.length] = new Option("Norwood Young America schools",'all=Norwood_Young_America');
mySelect.options[mySelect.options.length] = new Option("Victoria schools",'all=Victoria');
mySelect.options[mySelect.options.length] = new Option("Waconia schools",'all=Waconia');
mySelect.options[mySelect.options.length] = new Option("Watertown schools",'all=Watertown');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Waconia[Waconia.length] = createMarker(new GPoint(-93.79389191,44.85017014),"
",iconRd);
mySelect.options[mySelect.options.length] = new Option("Bayview Elementary School",'Waconia=' + Waconia.length);
Chanhassen[Chanhassen.length] = createMarker(new GPoint(-93.54113007,44.86246490),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Bluff Creek Elementary School",'Chanhassen=' + Chanhassen.length);
Chaska[Chaska.length] = createMarker(new GPoint(-93.60182400,44.78719500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Carver Alc High School",'Chaska=' + Chaska.length);
Chaska[Chaska.length] = createMarker(new GPoint(-93.58078766,44.84170151),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Carver County Targeted Services",'Chaska=' + Chaska.length);
Chaska[Chaska.length] = createMarker(new GPoint(-93.59643555,44.78796387),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Carver-scott Educational Coop.",'Chaska=' + Chaska.length);
Norwood_Young_America[Norwood_Young_America.length] = createMarker(new GPoint(-93.92579651,44.76290131),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Central Elementary School",'Norwood_Young_America=' + Norwood_Young_America.length);
Norwood_Young_America[Norwood_Young_America.length] = createMarker(new GPoint(-93.92579651,44.76290131),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Central Middle School",'Norwood_Young_America=' + Norwood_Young_America.length);
Norwood_Young_America[Norwood_Young_America.length] = createMarker(new GPoint(-93.92579651,44.76290131),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Central Senior High School",'Norwood_Young_America=' + Norwood_Young_America.length);
Chanhassen[Chanhassen.length] = createMarker(new GPoint(-93.53613281,44.86516190),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Chanhassen Elementary School",'Chanhassen=' + Chanhassen.length);
Chaska[Chaska.length] = createMarker(new GPoint(-93.60153198,44.80849838),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Chaska Elementary School",'Chaska=' + Chaska.length);
Chaska[Chaska.length] = createMarker(new GPoint(-93.59523773,44.80516052),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Chaska Mid. East Middle School",'Chaska=' + Chaska.length);
Chaska[Chaska.length] = createMarker(new GPoint(-93.58458710,44.80553436),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Chaska Mid. West Middle School",'Chaska=' + Chaska.length);
Chaska[Chaska.length] = createMarker(new GPoint(-93.59786987,44.82785034),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Chaska Senior High School",'Chaska=' + Chaska.length);
Waconia[Waconia.length] = createMarker(new GPoint(-93.78916400,44.84772000),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Clearwater Middle School",'Waconia=' + Waconia.length);
Chaska[Chaska.length] = createMarker(new GPoint(-93.63210297,44.81940842),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Clover Ridge Elementary School",'Chaska=' + Chaska.length);
Chaska[Chaska.length] = createMarker(new GPoint(-93.57611084,44.84174347),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Csec Alc C Ind High School",'Chaska=' + Chaska.length);
Chaska[Chaska.length] = createMarker(new GPoint(-93.58078766,44.84170151),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Csec Alc C Sb High School",'Chaska=' + Chaska.length);
Chaska[Chaska.length] = createMarker(new GPoint(-93.60182400,44.78719500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Csec Alc Juvenile Alternitive",'Chaska=' + Chaska.length);
Chaska[Chaska.length] = createMarker(new GPoint(-93.60182400,44.78719500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Csec Alc Newlemont",'Chaska=' + Chaska.length);
Chaska[Chaska.length] = createMarker(new GPoint(-93.60182400,44.78719500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Csec Alc S Ind",'Chaska=' + Chaska.length);
Chaska[Chaska.length] = createMarker(new GPoint(-93.60182400,44.78719500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Csec Alc S Sb",'Chaska=' + Chaska.length);
Chaska[Chaska.length] = createMarker(new GPoint(-93.60182400,44.78719500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Csec Alc S Shak 720",'Chaska=' + Chaska.length);
Chaska[Chaska.length] = createMarker(new GPoint(-93.60182400,44.78719500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Csec Alc West Carver",'Chaska=' + Chaska.length);
Chaska[Chaska.length] = createMarker(new GPoint(-93.58078766,44.84170151),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Csec Alc Westonka High School",'Chaska=' + Chaska.length);
Chaska[Chaska.length] = createMarker(new GPoint(-93.60182400,44.78719500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Csec Haven",'Chaska=' + Chaska.length);
Chaska[Chaska.length] = createMarker(new GPoint(-93.58078766,44.84170151),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Csec Special Ed West Carver",'Chaska=' + Chaska.length);
Chaska[Chaska.length] = createMarker(new GPoint(-93.58176000,44.84217600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Csec Special Ed. Spring Lake",'Chaska=' + Chaska.length);
Chaska[Chaska.length] = createMarker(new GPoint(-93.60990143,44.81320190),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Csec Special Ed. Waconia Middle School",'Chaska=' + Chaska.length);
Chaska[Chaska.length] = createMarker(new GPoint(-93.58078766,44.84170151),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Csec Special Ed. Westonka",'Chaska=' + Chaska.length);
Chaska[Chaska.length] = createMarker(new GPoint(-93.60182400,44.78719500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Csec Targeted Services Shak 720",'Chaska=' + Chaska.length);
Chaska[Chaska.length] = createMarker(new GPoint(-93.60848999,44.82543945),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Early Childhood Center",'Chaska=' + Chaska.length);
Carver[Carver.length] = createMarker(new GPoint(-93.68400574,44.72051239),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("East Union Elementary School",'Carver=' + Carver.length);
Chaska[Chaska.length] = createMarker(new GPoint(-93.56553650,44.82586288),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Jonathan Elementary School",'Chaska=' + Chaska.length);
Excelsior[Excelsior.length] = createMarker(new GPoint(-93.58118439,44.88775635),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Minnetonka West Middle School",'Excelsior=' + Excelsior.length);
Chaska[Chaska.length] = createMarker(new GPoint(-93.57375336,44.82286453),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Pioneer Ridge Freshmen Center",'Chaska=' + Chaska.length);
Chaska[Chaska.length] = createMarker(new GPoint(-93.57611084,44.84174347),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Scott Alc High School",'Chaska=' + Chaska.length);
Chaska[Chaska.length] = createMarker(new GPoint(-93.57611084,44.84174347),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Scott County Targeted Services",'Chaska=' + Chaska.length);
Waconia[Waconia.length] = createMarker(new GPoint(-93.78935242,44.84536362),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Southview Elementary School",'Waconia=' + Waconia.length);
Chaska[Chaska.length] = createMarker(new GPoint(-93.59500122,44.84447861),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Unique Learners Elementary School",'Chaska=' + Chaska.length);
Victoria[Victoria.length] = createMarker(new GPoint(-10.00000000,10.00000000),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Victoria Elementary School",'Victoria=' + Victoria.length);
Waconia[Waconia.length] = createMarker(new GPoint(-93.80873871,44.83670807),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Waconia Senior High School",'Waconia=' + Waconia.length);
Watertown[Watertown.length] = createMarker(new GPoint(-93.84500122,44.95899963),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Watertown Senior High School",'Watertown=' + Watertown.length);
Watertown[Watertown.length] = createMarker(new GPoint(-93.84500122,44.95899963),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Watertown-mayer Elementary School",'Watertown=' + Watertown.length);
Watertown[Watertown.length] = createMarker(new GPoint(-93.84500122,44.95899963),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Watertown-mayer Middle School",'Watertown=' + Watertown.length);
Chaska[Chaska.length] = createMarker(new GPoint(-93.59722137,44.82506943),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("World Learner Charter School",'Chaska=' + Chaska.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(Carver);
map.removeOverlays(Chanhassen);
map.removeOverlays(Chaska);
map.removeOverlays(Excelsior);
map.removeOverlays(Norwood_Young_America);
map.removeOverlays(Victoria);
map.removeOverlays(Waconia);
map.removeOverlays(Watertown);
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(Waconia);map.removeOverlays(Carver);
map.removeOverlays(Chanhassen);
map.removeOverlays(Chaska);
map.removeOverlays(Excelsior);
map.removeOverlays(Norwood_Young_America);
map.removeOverlays(Victoria);
map.removeOverlays(Waconia);
map.removeOverlays(Watertown);
map.addOverlays(Carver);
centerByArray(Carver, false, false);
cntMarker += Carver.length;
map.addOverlays(Chanhassen);
centerByArray(Chanhassen, false, false);
cntMarker += Chanhassen.length;
map.addOverlays(Chaska);
centerByArray(Chaska, false, false);
cntMarker += Chaska.length;
map.addOverlays(Excelsior);
centerByArray(Excelsior, false, false);
cntMarker += Excelsior.length;
map.addOverlays(Norwood_Young_America);
centerByArray(Norwood_Young_America, false, false);
cntMarker += Norwood_Young_America.length;
map.addOverlays(Victoria);
centerByArray(Victoria, false, false);
cntMarker += Victoria.length;
map.addOverlays(Waconia);
centerByArray(Waconia, false, false);
cntMarker += Waconia.length;
map.addOverlays(Watertown);
centerByArray(Watertown, false, false);
cntMarker += Watertown.length;
centerByArray(Waconia,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');
}
}