function addMarkers()
{
mySelect = document.getElementById('selection');
Midland = [];Coleman = [];Hope = [];Sanford = [];mySelect.options[mySelect.options.length] = new Option("Coleman schools",'all=Coleman');
mySelect.options[mySelect.options.length] = new Option("Hope schools",'all=Hope');
mySelect.options[mySelect.options.length] = new Option("Midland schools",'all=Midland');
mySelect.options[mySelect.options.length] = new Option("Sanford schools",'all=Sanford');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Midland[Midland.length] = createMarker(new GPoint(-84.21627808,43.64533615),"
",iconRd);
mySelect.options[mySelect.options.length] = new Option("Adams Elementary School",'Midland=' + Midland.length);
Midland[Midland.length] = createMarker(new GPoint(-84.19371033,43.62553787),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Ashman Alternative Ed. Ii--m.s.",'Midland=' + Midland.length);
Midland[Midland.length] = createMarker(new GPoint(-84.24741364,43.58234787),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Bullock Creek Elementary School",'Midland=' + Midland.length);
Midland[Midland.length] = createMarker(new GPoint(-84.29055023,43.56487274),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bullock Creek High School",'Midland=' + Midland.length);
Midland[Midland.length] = createMarker(new GPoint(-84.29055023,43.56487274),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Bullock Creek Middle School",'Midland=' + Midland.length);
Midland[Midland.length] = createMarker(new GPoint(-84.24343872,43.62070465),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Carpenter School",'Midland=' + Midland.length);
Midland[Midland.length] = createMarker(new GPoint(-84.23548889,43.61771774),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Central Middle School",'Midland=' + Midland.length);
Midland[Midland.length] = createMarker(new GPoint(-84.19690704,43.63215256),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Chestnut Hill School",'Midland=' + Midland.length);
Midland[Midland.length] = createMarker(new GPoint(-84.28259277,43.61614609),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Chippewassee School",'Midland=' + Midland.length);
Coleman[Coleman.length] = createMarker(new GPoint(-84.55999756,43.74340057),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Coleman Elementary School",'Coleman=' + Coleman.length);
Coleman[Coleman.length] = createMarker(new GPoint(-84.55999756,43.74340057),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Coleman High School",'Coleman=' + Coleman.length);
Coleman[Coleman.length] = createMarker(new GPoint(-84.55999756,43.74340057),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Coleman Middle School",'Coleman=' + Coleman.length);
Midland[Midland.length] = createMarker(new GPoint(-84.27667999,43.64779282),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Cook Elementary School",'Midland=' + Midland.length);
Midland[Midland.length] = createMarker(new GPoint(-84.22682953,43.61963654),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Eastlawn School",'Midland=' + Midland.length);
Midland[Midland.length] = createMarker(new GPoint(-84.40912628,43.58919525),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Floyd School",'Midland=' + Midland.length);
Midland[Midland.length] = createMarker(new GPoint(-84.27389526,43.64116287),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("H.h. Dow High School",'Midland=' + Midland.length);
Hope[Hope.length] = createMarker(new GPoint(-84.36866760,43.76998520),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Hillside Early Childhood Center",'Hope=' + Hope.length);
Midland[Midland.length] = createMarker(new GPoint(-84.23225403,43.64804459),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Jefferson Middle School",'Midland=' + Midland.length);
Midland[Midland.length] = createMarker(new GPoint(-84.22731018,43.61903381),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Leiphart High School--alt. Ed.",'Midland=' + Midland.length);
Midland[Midland.length] = createMarker(new GPoint(-84.19029236,43.60293579),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Longview Elementary School",'Midland=' + Midland.length);
Midland[Midland.length] = createMarker(new GPoint(-84.22708893,43.63292313),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Mcesa And Sugnet School Classroom Programs",'Midland=' + Midland.length);
Sanford[Sanford.length] = createMarker(new GPoint(-84.36838531,43.70934296),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Meridian Elementary School",'Sanford=' + Sanford.length);
Sanford[Sanford.length] = createMarker(new GPoint(-84.38031006,43.67287064),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Meridian High School",'Sanford=' + Sanford.length);
Sanford[Sanford.length] = createMarker(new GPoint(-84.36838531,43.71310806),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Meridian Junior High School",'Sanford=' + Sanford.length);
Midland[Midland.length] = createMarker(new GPoint(-84.18054199,43.56863022),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Midland Academy Of Advanced & Creative Studies",'Midland=' + Midland.length);
Midland[Midland.length] = createMarker(new GPoint(-84.21330261,43.61963654),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Midland High School",'Midland=' + Midland.length);
Midland[Midland.length] = createMarker(new GPoint(-84.23849487,43.77033997),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Mills Elementary School",'Midland=' + Midland.length);
Midland[Midland.length] = createMarker(new GPoint(-84.21119690,43.63147736),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Northeast Middle School",'Midland=' + Midland.length);
Midland[Midland.length] = createMarker(new GPoint(-84.20864868,43.61963654),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Parkdale Elementary School",'Midland=' + Midland.length);
Sanford[Sanford.length] = createMarker(new GPoint(-84.36849213,43.70138168),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Perkins Community Center",'Sanford=' + Sanford.length);
Midland[Midland.length] = createMarker(new GPoint(-84.29499054,43.59725189),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Pine River Elementary School",'Midland=' + Midland.length);
Midland[Midland.length] = createMarker(new GPoint(-84.21374512,43.63348389),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Plymouth Elementary School",'Midland=' + Midland.length);
Sanford[Sanford.length] = createMarker(new GPoint(-84.40640259,43.76752090),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Sanford Elementary School",'Sanford=' + Sanford.length);
Midland[Midland.length] = createMarker(new GPoint(-84.23985291,43.64952469),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Siebert School",'Midland=' + Midland.length);
Midland[Midland.length] = createMarker(new GPoint(-84.23399353,43.61530685),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Special Education Services",'Midland=' + Midland.length);
Midland[Midland.length] = createMarker(new GPoint(-84.33069611,43.61132050),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Windover High School",'Midland=' + Midland.length);
Midland[Midland.length] = createMarker(new GPoint(-84.25930786,43.64773560),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Woodcrest Elementary School",'Midland=' + Midland.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(Coleman);
map.removeOverlays(Hope);
map.removeOverlays(Midland);
map.removeOverlays(Sanford);
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(Midland);map.removeOverlays(Coleman);
map.removeOverlays(Hope);
map.removeOverlays(Midland);
map.removeOverlays(Sanford);
map.addOverlays(Coleman);
centerByArray(Coleman, false, false);
cntMarker += Coleman.length;
map.addOverlays(Hope);
centerByArray(Hope, false, false);
cntMarker += Hope.length;
map.addOverlays(Midland);
centerByArray(Midland, false, false);
cntMarker += Midland.length;
map.addOverlays(Sanford);
centerByArray(Sanford, false, false);
cntMarker += Sanford.length;
centerByArray(Midland,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');
}
}