function addMarkers()
{
mySelect = document.getElementById('selection');
Albany = [];Muncie = [];Daleville = [];Eaton = [];Gaston = [];Selma = [];Yorktown = [];mySelect.options[mySelect.options.length] = new Option("Albany schools",'all=Albany');
mySelect.options[mySelect.options.length] = new Option("Daleville schools",'all=Daleville');
mySelect.options[mySelect.options.length] = new Option("Eaton schools",'all=Eaton');
mySelect.options[mySelect.options.length] = new Option("Gaston schools",'all=Gaston');
mySelect.options[mySelect.options.length] = new Option("Muncie schools",'all=Muncie');
mySelect.options[mySelect.options.length] = new Option("Selma schools",'all=Selma');
mySelect.options[mySelect.options.length] = new Option("Yorktown schools",'all=Yorktown');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Albany[Albany.length] = createMarker(new GPoint(-85.24468231,40.29983521),"
",iconRd);
mySelect.options[mySelect.options.length] = new Option("Albany Elementary School",'Albany=' + Albany.length);
Muncie[Muncie.length] = createMarker(new GPoint(-85.40906525,40.19778442),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Burris Laboratory School",'Muncie=' + Muncie.length);
Muncie[Muncie.length] = createMarker(new GPoint(-85.34052277,40.19683838),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Claypool Elementary School",'Muncie=' + Muncie.length);
Muncie[Muncie.length] = createMarker(new GPoint(-85.38645935,40.19453812),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Cowan Elementary School",'Muncie=' + Muncie.length);
Muncie[Muncie.length] = createMarker(new GPoint(-85.39375305,40.10760117),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Cowan High School",'Muncie=' + Muncie.length);
Daleville[Daleville.length] = createMarker(new GPoint(-85.55548096,40.11679459),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Daleville Elementary School",'Daleville=' + Daleville.length);
Daleville[Daleville.length] = createMarker(new GPoint(-85.55548096,40.11864471),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Daleville Jr/sr High School",'Daleville=' + Daleville.length);
Muncie[Muncie.length] = createMarker(new GPoint(-85.38645935,40.19453812),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Delta High School",'Muncie=' + Muncie.length);
Muncie[Muncie.length] = createMarker(new GPoint(-85.38645935,40.19453812),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Delta Middle School",'Muncie=' + Muncie.length);
Muncie[Muncie.length] = createMarker(new GPoint(-85.38645935,40.19453812),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Desoto Elementary School",'Muncie=' + Muncie.length);
Eaton[Eaton.length] = createMarker(new GPoint(-85.35066986,40.34020996),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Eaton Elementary School",'Eaton=' + Eaton.length);
Muncie[Muncie.length] = createMarker(new GPoint(-85.38151550,40.18106461),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Garfield Elementary School",'Muncie=' + Muncie.length);
Gaston[Gaston.length] = createMarker(new GPoint(-85.51339722,40.32030106),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Gaston Elementary School",'Gaston=' + Gaston.length);
Muncie[Muncie.length] = createMarker(new GPoint(-85.36737823,40.16475296),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Grissom Elementary School",'Muncie=' + Muncie.length);
Gaston[Gaston.length] = createMarker(new GPoint(-85.50113678,40.31375122),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Harrison Elementary School",'Gaston=' + Gaston.length);
Muncie[Muncie.length] = createMarker(new GPoint(-85.38645935,40.19453812),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("In Aca For Sci Math & Humanities High School",'Muncie=' + Muncie.length);
Muncie[Muncie.length] = createMarker(new GPoint(-85.36531830,40.20763779),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Longfellow Elementary School",'Muncie=' + Muncie.length);
Muncie[Muncie.length] = createMarker(new GPoint(-85.41865540,40.22566223),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Mitchell Elementary School",'Muncie=' + Muncie.length);
Muncie[Muncie.length] = createMarker(new GPoint(-85.42940521,40.18916321),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Morrison-mock School",'Muncie=' + Muncie.length);
Muncie[Muncie.length] = createMarker(new GPoint(-85.34481812,40.10681915),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Muncie Area Career Center",'Muncie=' + Muncie.length);
Muncie[Muncie.length] = createMarker(new GPoint(-85.38648224,40.20145035),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Muncie Central High School",'Muncie=' + Muncie.length);
Muncie[Muncie.length] = createMarker(new GPoint(-85.37178040,40.16375732),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Muncie Southside High School",'Muncie=' + Muncie.length);
Muncie[Muncie.length] = createMarker(new GPoint(-85.39514160,40.22436142),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("North View Elementary School",'Muncie=' + Muncie.length);
Muncie[Muncie.length] = createMarker(new GPoint(-85.41135406,40.21149063),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Northside Middle School",'Muncie=' + Muncie.length);
Selma[Selma.length] = createMarker(new GPoint(-85.27624512,40.14933777),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Perry Elementary School",'Selma=' + Selma.length);
Yorktown[Yorktown.length] = createMarker(new GPoint(-85.49228668,40.18546295),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Pleasant View Elementary School",'Yorktown=' + Yorktown.length);
Muncie[Muncie.length] = createMarker(new GPoint(-85.37250519,40.26236343),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Royerton Elementary School",'Muncie=' + Muncie.length);
Selma[Selma.length] = createMarker(new GPoint(-85.26799774,40.16339874),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Selma Elementary School",'Selma=' + Selma.length);
Selma[Selma.length] = createMarker(new GPoint(-85.26860046,40.19155884),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Selma Middle School",'Selma=' + Selma.length);
Muncie[Muncie.length] = createMarker(new GPoint(-85.38832092,40.17684937),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("South View Elementary School",'Muncie=' + Muncie.length);
Muncie[Muncie.length] = createMarker(new GPoint(-85.42395782,40.20836258),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Storer Elementary School",'Muncie=' + Muncie.length);
Muncie[Muncie.length] = createMarker(new GPoint(-85.35041809,40.17843628),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Sutton Elementary School",'Muncie=' + Muncie.length);
Selma[Selma.length] = createMarker(new GPoint(-85.26860046,40.19155884),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Wapahani High School",'Selma=' + Selma.length);
Muncie[Muncie.length] = createMarker(new GPoint(-85.37599945,40.19451904),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Washington-carver Elementary School",'Muncie=' + Muncie.length);
Gaston[Gaston.length] = createMarker(new GPoint(-85.50113678,40.31375122),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Wes-del Middle/senior High School",'Gaston=' + Gaston.length);
Muncie[Muncie.length] = createMarker(new GPoint(-85.42578888,40.19546127),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("West View Elementary School",'Muncie=' + Muncie.length);
Muncie[Muncie.length] = createMarker(new GPoint(-85.42382050,40.17806244),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Wilson Middle School",'Muncie=' + Muncie.length);
Yorktown[Yorktown.length] = createMarker(new GPoint(-85.48999023,40.17640686),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Yorktown Elementary School",'Yorktown=' + Yorktown.length);
Yorktown[Yorktown.length] = createMarker(new GPoint(-85.50330353,40.18600082),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Yorktown High School",'Yorktown=' + Yorktown.length);
Yorktown[Yorktown.length] = createMarker(new GPoint(-85.49017334,40.17626953),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Yorktown Middle School",'Yorktown=' + Yorktown.length);
Muncie[Muncie.length] = createMarker(new GPoint(-85.42652893,40.18156815),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Youth Opportunity Center",'Muncie=' + Muncie.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(Albany);
map.removeOverlays(Daleville);
map.removeOverlays(Eaton);
map.removeOverlays(Gaston);
map.removeOverlays(Muncie);
map.removeOverlays(Selma);
map.removeOverlays(Yorktown);
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(Albany);map.removeOverlays(Albany);
map.removeOverlays(Daleville);
map.removeOverlays(Eaton);
map.removeOverlays(Gaston);
map.removeOverlays(Muncie);
map.removeOverlays(Selma);
map.removeOverlays(Yorktown);
map.addOverlays(Albany);
centerByArray(Albany, false, false);
cntMarker += Albany.length;
map.addOverlays(Daleville);
centerByArray(Daleville, false, false);
cntMarker += Daleville.length;
map.addOverlays(Eaton);
centerByArray(Eaton, false, false);
cntMarker += Eaton.length;
map.addOverlays(Gaston);
centerByArray(Gaston, false, false);
cntMarker += Gaston.length;
map.addOverlays(Muncie);
centerByArray(Muncie, false, false);
cntMarker += Muncie.length;
map.addOverlays(Selma);
centerByArray(Selma, false, false);
cntMarker += Selma.length;
map.addOverlays(Yorktown);
centerByArray(Yorktown, false, false);
cntMarker += Yorktown.length;
centerByArray(Albany,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');
}
}