function addMarkers()
{
mySelect = document.getElementById('selection');
Little_Falls = [];Pierz = [];Randall = [];Swanville = [];Motley = [];Royalton = [];Upsala = [];mySelect.options[mySelect.options.length] = new Option("Little Falls schools",'all=Little_Falls');
mySelect.options[mySelect.options.length] = new Option("Motley schools",'all=Motley');
mySelect.options[mySelect.options.length] = new Option("Pierz schools",'all=Pierz');
mySelect.options[mySelect.options.length] = new Option("Randall schools",'all=Randall');
mySelect.options[mySelect.options.length] = new Option("Royalton schools",'all=Royalton');
mySelect.options[mySelect.options.length] = new Option("Swanville schools",'all=Swanville');
mySelect.options[mySelect.options.length] = new Option("Upsala schools",'all=Upsala');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Little_Falls[Little_Falls.length] = createMarker(new GPoint(-94.34796143,45.97568512),"
",iconBl);
mySelect.options[mySelect.options.length] = new Option("Community Middle School",'Little_Falls=' + Little_Falls.length);
Pierz[Pierz.length] = createMarker(new GPoint(-94.09804535,45.98031235),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Healy Secondary School",'Pierz=' + Pierz.length);
Randall[Randall.length] = createMarker(new GPoint(-94.51760101,46.09730148),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Knight Elementary School",'Randall=' + Randall.length);
Little_Falls[Little_Falls.length] = createMarker(new GPoint(-94.37759399,45.97486115),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Lincoln Elementary School",'Little_Falls=' + Little_Falls.length);
Little_Falls[Little_Falls.length] = createMarker(new GPoint(-94.35015869,45.97462463),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Lindbergh Elementary School",'Little_Falls=' + Little_Falls.length);
Little_Falls[Little_Falls.length] = createMarker(new GPoint(-94.35034943,45.97012711),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Little Falls Continuation Ed. High School",'Little_Falls=' + Little_Falls.length);
Little_Falls[Little_Falls.length] = createMarker(new GPoint(-94.35034943,45.97012711),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Little Falls Senior High School",'Little_Falls=' + Little_Falls.length);
Swanville[Swanville.length] = createMarker(new GPoint(-94.60970306,45.92200089),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Molly Creek Alc High School",'Swanville=' + Swanville.length);
Little_Falls[Little_Falls.length] = createMarker(new GPoint(-94.36070400,45.95072300),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Morrison County Learning Center",'Little_Falls=' + Little_Falls.length);
Motley[Motley.length] = createMarker(new GPoint(-94.61389923,46.30550003),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Motley Elementary School",'Motley=' + Motley.length);
Motley[Motley.length] = createMarker(new GPoint(-94.61389923,46.30550003),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Motley-staples Middle School",'Motley=' + Motley.length);
Pierz[Pierz.length] = createMarker(new GPoint(-94.09804535,45.98031235),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Pierz Alternative Program",'Pierz=' + Pierz.length);
Pierz[Pierz.length] = createMarker(new GPoint(-94.09809875,45.97971725),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Pioneer Elementary School",'Pierz=' + Pierz.length);
Royalton[Royalton.length] = createMarker(new GPoint(-94.26869965,45.84579849),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Royalton Elementary School",'Royalton=' + Royalton.length);
Royalton[Royalton.length] = createMarker(new GPoint(-94.26869965,45.84579849),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Royalton Secondary School",'Royalton=' + Royalton.length);
Little_Falls[Little_Falls.length] = createMarker(new GPoint(-94.36176700,45.97854800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Steps Transition",'Little_Falls=' + Little_Falls.length);
Little_Falls[Little_Falls.length] = createMarker(new GPoint(-94.36176700,45.97854800),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Success Program",'Little_Falls=' + Little_Falls.length);
Swanville[Swanville.length] = createMarker(new GPoint(-94.60970306,45.92200089),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Swanville Elementary School",'Swanville=' + Swanville.length);
Swanville[Swanville.length] = createMarker(new GPoint(-94.60970306,45.92200089),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Swanville Secondary School",'Swanville=' + Swanville.length);
Upsala[Upsala.length] = createMarker(new GPoint(-94.54969788,45.81230164),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Upsala Elementary School",'Upsala=' + Upsala.length);
Upsala[Upsala.length] = createMarker(new GPoint(-94.54969788,45.81230164),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Upsala Secondary School",'Upsala=' + Upsala.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(Little_Falls);
map.removeOverlays(Motley);
map.removeOverlays(Pierz);
map.removeOverlays(Randall);
map.removeOverlays(Royalton);
map.removeOverlays(Swanville);
map.removeOverlays(Upsala);
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(Little_Falls);map.removeOverlays(Little_Falls);
map.removeOverlays(Motley);
map.removeOverlays(Pierz);
map.removeOverlays(Randall);
map.removeOverlays(Royalton);
map.removeOverlays(Swanville);
map.removeOverlays(Upsala);
map.addOverlays(Little_Falls);
centerByArray(Little_Falls, false, false);
cntMarker += Little_Falls.length;
map.addOverlays(Motley);
centerByArray(Motley, false, false);
cntMarker += Motley.length;
map.addOverlays(Pierz);
centerByArray(Pierz, false, false);
cntMarker += Pierz.length;
map.addOverlays(Randall);
centerByArray(Randall, false, false);
cntMarker += Randall.length;
map.addOverlays(Royalton);
centerByArray(Royalton, false, false);
cntMarker += Royalton.length;
map.addOverlays(Swanville);
centerByArray(Swanville, false, false);
cntMarker += Swanville.length;
map.addOverlays(Upsala);
centerByArray(Upsala, false, false);
cntMarker += Upsala.length;
centerByArray(Little_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');
}
}