function addMarkers()
{
mySelect = document.getElementById('selection');
Fergus_Falls = [];Battle_Lake = [];Dent = [];Perham = [];Henning = [];New_York_Mills = [];Parkers_Prairie = [];Alexandria = [];Pelican_Rapids = [];Underwood = [];mySelect.options[mySelect.options.length] = new Option("Alexandria schools",'all=Alexandria');
mySelect.options[mySelect.options.length] = new Option("Battle Lake schools",'all=Battle_Lake');
mySelect.options[mySelect.options.length] = new Option("Dent schools",'all=Dent');
mySelect.options[mySelect.options.length] = new Option("Fergus Falls schools",'all=Fergus_Falls');
mySelect.options[mySelect.options.length] = new Option("Henning schools",'all=Henning');
mySelect.options[mySelect.options.length] = new Option("New York Mills schools",'all=New_York_Mills');
mySelect.options[mySelect.options.length] = new Option("Parkers Prairie schools",'all=Parkers_Prairie');
mySelect.options[mySelect.options.length] = new Option("Pelican Rapids schools",'all=Pelican_Rapids');
mySelect.options[mySelect.options.length] = new Option("Perham schools",'all=Perham');
mySelect.options[mySelect.options.length] = new Option("Underwood schools",'all=Underwood');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Fergus_Falls[Fergus_Falls.length] = createMarker(new GPoint(-96.07759857,46.27516937),"
",iconRd);
mySelect.options[mySelect.options.length] = new Option("Adams Elementary School",'Fergus_Falls=' + Fergus_Falls.length);
Battle_Lake[Battle_Lake.length] = createMarker(new GPoint(-95.71859741,46.28308868),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Battle Lake Elementary School",'Battle_Lake=' + Battle_Lake.length);
Battle_Lake[Battle_Lake.length] = createMarker(new GPoint(-95.71859741,46.28308868),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Battle Lake Secondary School",'Battle_Lake=' + Battle_Lake.length);
Fergus_Falls[Fergus_Falls.length] = createMarker(new GPoint(-96.06890106,46.29219437),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Cleveland Elementary School",'Fergus_Falls=' + Fergus_Falls.length);
Dent[Dent.length] = createMarker(new GPoint(-95.78549957,46.54690170),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Dent Elementary School",'Dent=' + Dent.length);
Fergus_Falls[Fergus_Falls.length] = createMarker(new GPoint(-96.06095886,46.27430344),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Eisenhower Elementary School",'Fergus_Falls=' + Fergus_Falls.length);
Fergus_Falls[Fergus_Falls.length] = createMarker(new GPoint(-96.04920197,46.30690002),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Fergus Falls Altern. Program High School",'Fergus_Falls=' + Fergus_Falls.length);
Fergus_Falls[Fergus_Falls.length] = createMarker(new GPoint(-96.04920197,46.30690002),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Fergus Falls Area Sp. Ed. Coop.",'Fergus_Falls=' + Fergus_Falls.length);
Fergus_Falls[Fergus_Falls.length] = createMarker(new GPoint(-96.06501007,46.28944778),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Fergus Falls Middle School",'Fergus_Falls=' + Fergus_Falls.length);
Fergus_Falls[Fergus_Falls.length] = createMarker(new GPoint(-96.06841278,46.28882980),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Fergus Falls Senior High School",'Fergus_Falls=' + Fergus_Falls.length);
Fergus_Falls[Fergus_Falls.length] = createMarker(new GPoint(-96.07238900,46.27864000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("H.a.r.t. Program",'Fergus_Falls=' + Fergus_Falls.length);
Perham[Perham.length] = createMarker(new GPoint(-95.58013916,46.58737946),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Heart Of Lake Elementary School",'Perham=' + Perham.length);
Henning[Henning.length] = createMarker(new GPoint(-95.44920349,46.32820129),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Henning Elementary School",'Henning=' + Henning.length);
Henning[Henning.length] = createMarker(new GPoint(-95.44920349,46.32820129),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Henning Secondary School",'Henning=' + Henning.length);
Fergus_Falls[Fergus_Falls.length] = createMarker(new GPoint(-96.08706665,46.28761292),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Mckinley Elementary School",'Fergus_Falls=' + Fergus_Falls.length);
New_York_Mills[New_York_Mills.length] = createMarker(new GPoint(-95.39080048,46.53519821),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("New York Mills Elementary School",'New_York_Mills=' + New_York_Mills.length);
New_York_Mills[New_York_Mills.length] = createMarker(new GPoint(-95.39080048,46.53519821),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("New York Mills Secondary School",'New_York_Mills=' + New_York_Mills.length);
New_York_Mills[New_York_Mills.length] = createMarker(new GPoint(-95.37400055,46.53480148),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("New York Mills Ts Satellite",'New_York_Mills=' + New_York_Mills.length);
Parkers_Prairie[Parkers_Prairie.length] = createMarker(new GPoint(-95.31670380,46.15779877),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Parkers Prairie Elementary School",'Parkers_Prairie=' + Parkers_Prairie.length);
Parkers_Prairie[Parkers_Prairie.length] = createMarker(new GPoint(-95.31670380,46.15779877),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Parkers Prairie Secondary School",'Parkers_Prairie=' + Parkers_Prairie.length);
Alexandria[Alexandria.length] = createMarker(new GPoint(-95.37919700,45.88345100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Parkers Prairie Ts",'Alexandria=' + Alexandria.length);
Pelican_Rapids[Pelican_Rapids.length] = createMarker(new GPoint(-96.05989838,46.60979843),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Pelican Rapids Elementary School",'Pelican_Rapids=' + Pelican_Rapids.length);
Pelican_Rapids[Pelican_Rapids.length] = createMarker(new GPoint(-96.05989838,46.60979843),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Pelican Rapids Secondary School",'Pelican_Rapids=' + Pelican_Rapids.length);
Perham[Perham.length] = createMarker(new GPoint(-95.56539154,46.59902573),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Perham Area Learning Cntr.",'Perham=' + Perham.length);
Perham[Perham.length] = createMarker(new GPoint(-95.57258400,46.59447500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Perham Area Targeted Services",'Perham=' + Perham.length);
Perham[Perham.length] = createMarker(new GPoint(-95.57557678,46.59020615),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Perham Senior High School",'Perham=' + Perham.length);
Perham[Perham.length] = createMarker(new GPoint(-95.58405304,46.58583832),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Prairie Wind Middle School",'Perham=' + Perham.length);
Underwood[Underwood.length] = createMarker(new GPoint(-95.84140015,46.31729889),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Underwood Elementary School",'Underwood=' + Underwood.length);
Underwood[Underwood.length] = createMarker(new GPoint(-95.84140015,46.31729889),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Underwood Secondary School",'Underwood=' + Underwood.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(Alexandria);
map.removeOverlays(Battle_Lake);
map.removeOverlays(Dent);
map.removeOverlays(Fergus_Falls);
map.removeOverlays(Henning);
map.removeOverlays(New_York_Mills);
map.removeOverlays(Parkers_Prairie);
map.removeOverlays(Pelican_Rapids);
map.removeOverlays(Perham);
map.removeOverlays(Underwood);
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(Fergus_Falls);map.removeOverlays(Alexandria);
map.removeOverlays(Battle_Lake);
map.removeOverlays(Dent);
map.removeOverlays(Fergus_Falls);
map.removeOverlays(Henning);
map.removeOverlays(New_York_Mills);
map.removeOverlays(Parkers_Prairie);
map.removeOverlays(Pelican_Rapids);
map.removeOverlays(Perham);
map.removeOverlays(Underwood);
map.addOverlays(Alexandria);
centerByArray(Alexandria, false, false);
cntMarker += Alexandria.length;
map.addOverlays(Battle_Lake);
centerByArray(Battle_Lake, false, false);
cntMarker += Battle_Lake.length;
map.addOverlays(Dent);
centerByArray(Dent, false, false);
cntMarker += Dent.length;
map.addOverlays(Fergus_Falls);
centerByArray(Fergus_Falls, false, false);
cntMarker += Fergus_Falls.length;
map.addOverlays(Henning);
centerByArray(Henning, false, false);
cntMarker += Henning.length;
map.addOverlays(New_York_Mills);
centerByArray(New_York_Mills, false, false);
cntMarker += New_York_Mills.length;
map.addOverlays(Parkers_Prairie);
centerByArray(Parkers_Prairie, false, false);
cntMarker += Parkers_Prairie.length;
map.addOverlays(Pelican_Rapids);
centerByArray(Pelican_Rapids, false, false);
cntMarker += Pelican_Rapids.length;
map.addOverlays(Perham);
centerByArray(Perham, false, false);
cntMarker += Perham.length;
map.addOverlays(Underwood);
centerByArray(Underwood, false, false);
cntMarker += Underwood.length;
centerByArray(Fergus_Falls,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');
}
}