function addMarkers()
{
mySelect = document.getElementById('selection');
Bloomington = [];Ellettsville = [];Stinesville = [];Unionville = [];mySelect.options[mySelect.options.length] = new Option("Bloomington schools",'all=Bloomington');
mySelect.options[mySelect.options.length] = new Option("Ellettsville schools",'all=Ellettsville');
mySelect.options[mySelect.options.length] = new Option("Stinesville schools",'all=Stinesville');
mySelect.options[mySelect.options.length] = new Option("Unionville schools",'all=Unionville');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Bloomington[Bloomington.length] = createMarker(new GPoint(-86.54217529,39.18653870),"
",iconRd);
mySelect.options[mySelect.options.length] = new Option("Arlington Heights Elementary School",'Bloomington=' + Bloomington.length);
Bloomington[Bloomington.length] = createMarker(new GPoint(-86.54092407,39.17078781),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Aurora Alternative School",'Bloomington=' + Bloomington.length);
Bloomington[Bloomington.length] = createMarker(new GPoint(-86.50563049,39.16085815),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Binford Elementary School",'Bloomington=' + Bloomington.length);
Bloomington[Bloomington.length] = createMarker(new GPoint(-86.54753113,39.20400620),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bloomington High School North",'Bloomington=' + Bloomington.length);
Bloomington[Bloomington.length] = createMarker(new GPoint(-86.53123474,39.14275742),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bloomington High School South",'Bloomington=' + Bloomington.length);
Bloomington[Bloomington.length] = createMarker(new GPoint(-86.54131317,39.14116287),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Broadview Elementary School",'Bloomington=' + Bloomington.length);
Bloomington[Bloomington.length] = createMarker(new GPoint(-86.50801849,39.13930511),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Childs Elementary School",'Bloomington=' + Bloomington.length);
Bloomington[Bloomington.length] = createMarker(new GPoint(-86.53507996,39.11123657),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Clear Creek Elementary School",'Bloomington=' + Bloomington.length);
Bloomington[Bloomington.length] = createMarker(new GPoint(-86.46881866,39.12889862),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Eagle View Jr-sr High School",'Bloomington=' + Bloomington.length);
Ellettsville[Ellettsville.length] = createMarker(new GPoint(-86.62400055,39.23434067),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Edgewood Early Childhood Cntr Elementary School",'Ellettsville=' + Ellettsville.length);
Ellettsville[Ellettsville.length] = createMarker(new GPoint(-86.63838196,39.23278046),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Edgewood High School",'Ellettsville=' + Ellettsville.length);
Bloomington[Bloomington.length] = createMarker(new GPoint(-86.46881866,39.12889862),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Edgewood Intermediate School",'Bloomington=' + Bloomington.length);
Ellettsville[Ellettsville.length] = createMarker(new GPoint(-86.62400055,39.23434067),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Edgewood Junior High School",'Ellettsville=' + Ellettsville.length);
Bloomington[Bloomington.length] = createMarker(new GPoint(-86.46881866,39.12889862),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Edgewood Primary School",'Bloomington=' + Bloomington.length);
Ellettsville[Ellettsville.length] = createMarker(new GPoint(-86.62161255,39.23024750),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Ellettsville Elementary School",'Ellettsville=' + Ellettsville.length);
Bloomington[Bloomington.length] = createMarker(new GPoint(-86.54026031,39.16936111),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Fairview Elementary School",'Bloomington=' + Bloomington.length);
Ellettsville[Ellettsville.length] = createMarker(new GPoint(-86.61878204,39.22496033),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Forest Hills Spec Educ Coop",'Ellettsville=' + Ellettsville.length);
Bloomington[Bloomington.length] = createMarker(new GPoint(-86.59647369,39.14223099),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Grandview Elementary School",'Bloomington=' + Bloomington.length);
Bloomington[Bloomington.length] = createMarker(new GPoint(-86.59187317,39.15676117),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Highland Park Elementary School",'Bloomington=' + Bloomington.length);
Bloomington[Bloomington.length] = createMarker(new GPoint(-86.46881866,39.12889862),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Hoosier Hills Career Center",'Bloomington=' + Bloomington.length);
Bloomington[Bloomington.length] = createMarker(new GPoint(-86.51073456,39.12301636),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Jackson Creek Middle School",'Bloomington=' + Bloomington.length);
Bloomington[Bloomington.length] = createMarker(new GPoint(-86.52136230,39.03039932),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Lakeview Elementary School",'Bloomington=' + Bloomington.length);
Bloomington[Bloomington.length] = createMarker(new GPoint(-86.54302216,39.12183762),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Lora L Batchelor Middle School",'Bloomington=' + Bloomington.length);
Bloomington[Bloomington.length] = createMarker(new GPoint(-86.51578522,39.21543884),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Marlin Elementary School",'Bloomington=' + Bloomington.length);
Bloomington[Bloomington.length] = createMarker(new GPoint(-86.50714111,39.16086197),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Rogers Elementary School",'Bloomington=' + Bloomington.length);
Stinesville[Stinesville.length] = createMarker(new GPoint(-86.63002014,39.23878098),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Stinesville Elementary School",'Stinesville=' + Stinesville.length);
Bloomington[Bloomington.length] = createMarker(new GPoint(-86.54735800,39.14285300),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Summit Elementary School",'Bloomington=' + Bloomington.length);
Bloomington[Bloomington.length] = createMarker(new GPoint(-86.52568054,39.15169144),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Templeton Elementary School",'Bloomington=' + Bloomington.length);
Bloomington[Bloomington.length] = createMarker(new GPoint(-86.54726410,39.17755127),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Tri-north Middle School",'Bloomington=' + Bloomington.length);
Unionville[Unionville.length] = createMarker(new GPoint(-86.41606140,39.22991943),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Unionville Elementary School",'Unionville=' + Unionville.length);
Bloomington[Bloomington.length] = createMarker(new GPoint(-86.48157501,39.17527008),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("University Elementary School",'Bloomington=' + Bloomington.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(Bloomington);
map.removeOverlays(Ellettsville);
map.removeOverlays(Stinesville);
map.removeOverlays(Unionville);
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(Bloomington);map.removeOverlays(Bloomington);
map.removeOverlays(Ellettsville);
map.removeOverlays(Stinesville);
map.removeOverlays(Unionville);
map.addOverlays(Bloomington);
centerByArray(Bloomington, false, false);
cntMarker += Bloomington.length;
map.addOverlays(Ellettsville);
centerByArray(Ellettsville, false, false);
cntMarker += Ellettsville.length;
map.addOverlays(Stinesville);
centerByArray(Stinesville, false, false);
cntMarker += Stinesville.length;
map.addOverlays(Unionville);
centerByArray(Unionville, false, false);
cntMarker += Unionville.length;
centerByArray(Bloomington,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');
}
}