function addMarkers()
{
mySelect = document.getElementById('selection');
Red_Wing = [];Cannon_Falls = [];Kenyon = [];Goodhue = [];Wanamingo = [];Pine_Island = [];Zumbrota = [];mySelect.options[mySelect.options.length] = new Option("Cannon Falls schools",'all=Cannon_Falls');
mySelect.options[mySelect.options.length] = new Option("Goodhue schools",'all=Goodhue');
mySelect.options[mySelect.options.length] = new Option("Kenyon schools",'all=Kenyon');
mySelect.options[mySelect.options.length] = new Option("Pine Island schools",'all=Pine_Island');
mySelect.options[mySelect.options.length] = new Option("Red Wing schools",'all=Red_Wing');
mySelect.options[mySelect.options.length] = new Option("Wanamingo schools",'all=Wanamingo');
mySelect.options[mySelect.options.length] = new Option("Zumbrota schools",'all=Zumbrota');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Red_Wing[Red_Wing.length] = createMarker(new GPoint(-92.62809753,44.56677246),"
",iconRd);
mySelect.options[mySelect.options.length] = new Option("Burnside Elementary School",'Red_Wing=' + Red_Wing.length);
Cannon_Falls[Cannon_Falls.length] = createMarker(new GPoint(-92.91408539,44.51071167),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Cannon Falls Elementary School",'Cannon_Falls=' + Cannon_Falls.length);
Cannon_Falls[Cannon_Falls.length] = createMarker(new GPoint(-92.91166687,44.51070786),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Cannon Falls Secondary School",'Cannon_Falls=' + Cannon_Falls.length);
Red_Wing[Red_Wing.length] = createMarker(new GPoint(-92.52654266,44.56636047),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Colvill Family Education Center",'Red_Wing=' + Red_Wing.length);
Red_Wing[Red_Wing.length] = createMarker(new GPoint(-92.55000305,44.54869843),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Correctional Facility-red Wing High School",'Red_Wing=' + Red_Wing.length);
Kenyon[Kenyon.length] = createMarker(new GPoint(-92.97869873,44.26810074),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Expelled Students",'Kenyon=' + Kenyon.length);
Cannon_Falls[Cannon_Falls.length] = createMarker(new GPoint(-92.83099365,44.39880371),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Goodhue County Ed. District High School",'Cannon_Falls=' + Cannon_Falls.length);
Goodhue[Goodhue.length] = createMarker(new GPoint(-92.61679840,44.40790176),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Goodhue Elementary School",'Goodhue=' + Goodhue.length);
Goodhue[Goodhue.length] = createMarker(new GPoint(-92.61679840,44.40790176),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Goodhue Secondary School",'Goodhue=' + Goodhue.length);
Red_Wing[Red_Wing.length] = createMarker(new GPoint(-92.55207062,44.55897141),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Jefferson Elementary School",'Red_Wing=' + Red_Wing.length);
Kenyon[Kenyon.length] = createMarker(new GPoint(-92.99010468,44.26723862),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Kenyon-wanamingo Alternative",'Kenyon=' + Kenyon.length);
Wanamingo[Wanamingo.length] = createMarker(new GPoint(-92.78770447,44.30390549),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Kenyon-wanamingo Elementary School",'Wanamingo=' + Wanamingo.length);
Kenyon[Kenyon.length] = createMarker(new GPoint(-92.99010468,44.26723862),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Kenyon-wanamingo Middle School",'Kenyon=' + Kenyon.length);
Kenyon[Kenyon.length] = createMarker(new GPoint(-92.99010468,44.26723862),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Kenyon-wanamingo Senior High School",'Kenyon=' + Kenyon.length);
Red_Wing[Red_Wing.length] = createMarker(new GPoint(-92.56746400,44.55643300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Mcf-redwing Maginnis High School",'Red_Wing=' + Red_Wing.length);
Pine_Island[Pine_Island.length] = createMarker(new GPoint(-92.65499878,44.19810104),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Pi/zm Alp High School",'Pine_Island=' + Pine_Island.length);
Pine_Island[Pine_Island.length] = createMarker(new GPoint(-92.65499878,44.19810104),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Pine Island Elementary School",'Pine_Island=' + Pine_Island.length);
Pine_Island[Pine_Island.length] = createMarker(new GPoint(-92.65470123,44.19120026),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Pine Island Middle School",'Pine_Island=' + Pine_Island.length);
Pine_Island[Pine_Island.length] = createMarker(new GPoint(-92.65499878,44.19810104),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Pine Island Secondary School",'Pine_Island=' + Pine_Island.length);
Zumbrota[Zumbrota.length] = createMarker(new GPoint(-92.66913300,44.28948500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Pine Island/zumbrota-mazeppa Alp",'Zumbrota=' + Zumbrota.length);
Red_Wing[Red_Wing.length] = createMarker(new GPoint(-92.63738251,44.56956482),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Red Wing Alc High School",'Red_Wing=' + Red_Wing.length);
Red_Wing[Red_Wing.length] = createMarker(new GPoint(-92.53435400,44.56658500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Red Wing High School Alc Day Program",'Red_Wing=' + Red_Wing.length);
Red_Wing[Red_Wing.length] = createMarker(new GPoint(-92.51816300,44.53401800),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Red Wing Middle Level Day Alc",'Red_Wing=' + Red_Wing.length);
Red_Wing[Red_Wing.length] = createMarker(new GPoint(-92.52130127,44.53960037),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Red Wing Senior High School",'Red_Wing=' + Red_Wing.length);
Red_Wing[Red_Wing.length] = createMarker(new GPoint(-92.51816300,44.53401800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Red Wing Targeted Services",'Red_Wing=' + Red_Wing.length);
Red_Wing[Red_Wing.length] = createMarker(new GPoint(-92.54220581,44.55029297),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Sunnyside Elementary School",'Red_Wing=' + Red_Wing.length);
Red_Wing[Red_Wing.length] = createMarker(new GPoint(-92.63738251,44.56956482),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Tower View Opportunity Program Alc High School",'Red_Wing=' + Red_Wing.length);
Red_Wing[Red_Wing.length] = createMarker(new GPoint(-92.54325867,44.54399872),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Twin Bluff Middle School",'Red_Wing=' + Red_Wing.length);
Red_Wing[Red_Wing.length] = createMarker(new GPoint(-92.52069855,44.56589890),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Walter Maginnis High School",'Red_Wing=' + Red_Wing.length);
Zumbrota[Zumbrota.length] = createMarker(new GPoint(-92.67424011,44.29067612),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Zumbrota-mazeppa Elementary School",'Zumbrota=' + Zumbrota.length);
Zumbrota[Zumbrota.length] = createMarker(new GPoint(-92.67382812,44.29156876),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Zumbrota-mazeppa Senior High School",'Zumbrota=' + Zumbrota.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(Cannon_Falls);
map.removeOverlays(Goodhue);
map.removeOverlays(Kenyon);
map.removeOverlays(Pine_Island);
map.removeOverlays(Red_Wing);
map.removeOverlays(Wanamingo);
map.removeOverlays(Zumbrota);
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(Red_Wing);map.removeOverlays(Cannon_Falls);
map.removeOverlays(Goodhue);
map.removeOverlays(Kenyon);
map.removeOverlays(Pine_Island);
map.removeOverlays(Red_Wing);
map.removeOverlays(Wanamingo);
map.removeOverlays(Zumbrota);
map.addOverlays(Cannon_Falls);
centerByArray(Cannon_Falls, false, false);
cntMarker += Cannon_Falls.length;
map.addOverlays(Goodhue);
centerByArray(Goodhue, false, false);
cntMarker += Goodhue.length;
map.addOverlays(Kenyon);
centerByArray(Kenyon, false, false);
cntMarker += Kenyon.length;
map.addOverlays(Pine_Island);
centerByArray(Pine_Island, false, false);
cntMarker += Pine_Island.length;
map.addOverlays(Red_Wing);
centerByArray(Red_Wing, false, false);
cntMarker += Red_Wing.length;
map.addOverlays(Wanamingo);
centerByArray(Wanamingo, false, false);
cntMarker += Wanamingo.length;
map.addOverlays(Zumbrota);
centerByArray(Zumbrota, false, false);
cntMarker += Zumbrota.length;
centerByArray(Red_Wing,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');
}
}