function addMarkers()
{
mySelect = document.getElementById('selection');
Lesueur = [];Cleveland = [];New_Prague = [];Elysian = [];Lecenter = [];Montgomery = [];Waterville = [];mySelect.options[mySelect.options.length] = new Option("Cleveland schools",'all=Cleveland');
mySelect.options[mySelect.options.length] = new Option("Elysian schools",'all=Elysian');
mySelect.options[mySelect.options.length] = new Option("Lecenter schools",'all=Lecenter');
mySelect.options[mySelect.options.length] = new Option("Lesueur schools",'all=Lesueur');
mySelect.options[mySelect.options.length] = new Option("Montgomery schools",'all=Montgomery');
mySelect.options[mySelect.options.length] = new Option("New Prague schools",'all=New_Prague');
mySelect.options[mySelect.options.length] = new Option("Waterville schools",'all=Waterville');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Lesueur[Lesueur.length] = createMarker(new GPoint(-93.91153717,44.45156479),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Area Adult Learning Cooperative",'Lesueur=' + Lesueur.length);
Cleveland[Cleveland.length] = createMarker(new GPoint(-93.81400299,44.30920029),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Cleveland Elementary School",'Cleveland=' + Cleveland.length);
Cleveland[Cleveland.length] = createMarker(new GPoint(-93.81400299,44.30920029),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Cleveland Secondary School",'Cleveland=' + Cleveland.length);
New_Prague[New_Prague.length] = createMarker(new GPoint(-93.57429504,44.55715561),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Community Services",'New_Prague=' + New_Prague.length);
Elysian[Elysian.length] = createMarker(new GPoint(-93.68158722,44.19895935),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Elysian Elementary School",'Elysian=' + Elysian.length);
Lecenter[Lecenter.length] = createMarker(new GPoint(-93.73548889,44.39213943),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Lecenter Elementary School",'Lecenter=' + Lecenter.length);
Lecenter[Lecenter.length] = createMarker(new GPoint(-93.73329926,44.39093781),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Lecenter Secondary School",'Lecenter=' + Lecenter.length);
Lesueur[Lesueur.length] = createMarker(new GPoint(-93.91603851,44.45991898),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Lesueur-henderson Secondary School",'Lesueur=' + Lesueur.length);
Montgomery[Montgomery.length] = createMarker(new GPoint(-93.58245087,44.43864059),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Montgomery-lonsdale Elementary School",'Montgomery=' + Montgomery.length);
Montgomery[Montgomery.length] = createMarker(new GPoint(-93.56759644,44.43080139),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Montgomery-lonsdale Int. Elementary School",'Montgomery=' + Montgomery.length);
Montgomery[Montgomery.length] = createMarker(new GPoint(-93.56759644,44.43080139),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Montgomery-lonsdale Secondary School",'Montgomery=' + Montgomery.length);
Montgomery[Montgomery.length] = createMarker(new GPoint(-93.58512900,44.43826500),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Mrvsec/montgomery Elementary School",'Montgomery=' + Montgomery.length);
Montgomery[Montgomery.length] = createMarker(new GPoint(-93.57964325,44.43869019),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Mrvsec/montgomery Middle School",'Montgomery=' + Montgomery.length);
New_Prague[New_Prague.length] = createMarker(new GPoint(-93.56716919,44.54147720),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Mrvsec/new Prague High School",'New_Prague=' + New_Prague.length);
New_Prague[New_Prague.length] = createMarker(new GPoint(-93.56716919,44.54147720),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Mrvsec/new Prague Int",'New_Prague=' + New_Prague.length);
New_Prague[New_Prague.length] = createMarker(new GPoint(-93.56716919,44.54147720),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Mrvsec/new Prague Middle School",'New_Prague=' + New_Prague.length);
New_Prague[New_Prague.length] = createMarker(new GPoint(-93.56679535,44.54079819),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("New Prague Primary",'New_Prague=' + New_Prague.length);
Lesueur[Lesueur.length] = createMarker(new GPoint(-93.91012573,44.45948029),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Park Elementary School",'Lesueur=' + Lesueur.length);
Waterville[Waterville.length] = createMarker(new GPoint(-93.56374359,44.21755219),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Waterville Elementary School",'Waterville=' + Waterville.length);
Waterville[Waterville.length] = createMarker(new GPoint(-93.56374359,44.21755219),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Waterville-elysian-morristown Senior High School",'Waterville=' + Waterville.length);
Lesueur[Lesueur.length] = createMarker(new GPoint(-93.91503000,44.46193000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Ziebarth Alternative Learning Ctr.",'Lesueur=' + Lesueur.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(Cleveland);
map.removeOverlays(Elysian);
map.removeOverlays(Lecenter);
map.removeOverlays(Lesueur);
map.removeOverlays(Montgomery);
map.removeOverlays(New_Prague);
map.removeOverlays(Waterville);
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(Lesueur);map.removeOverlays(Cleveland);
map.removeOverlays(Elysian);
map.removeOverlays(Lecenter);
map.removeOverlays(Lesueur);
map.removeOverlays(Montgomery);
map.removeOverlays(New_Prague);
map.removeOverlays(Waterville);
map.addOverlays(Cleveland);
centerByArray(Cleveland, false, false);
cntMarker += Cleveland.length;
map.addOverlays(Elysian);
centerByArray(Elysian, false, false);
cntMarker += Elysian.length;
map.addOverlays(Lecenter);
centerByArray(Lecenter, false, false);
cntMarker += Lecenter.length;
map.addOverlays(Lesueur);
centerByArray(Lesueur, false, false);
cntMarker += Lesueur.length;
map.addOverlays(Montgomery);
centerByArray(Montgomery, false, false);
cntMarker += Montgomery.length;
map.addOverlays(New_Prague);
centerByArray(New_Prague, false, false);
cntMarker += New_Prague.length;
map.addOverlays(Waterville);
centerByArray(Waterville, false, false);
cntMarker += Waterville.length;
centerByArray(Lesueur,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');
}
}