function addMarkers()
{
mySelect = document.getElementById('selection');
Pomona = [];Richmond = [];Ottawa = [];Wellsville = [];Williamsburg = [];mySelect.options[mySelect.options.length] = new Option("Ottawa schools",'all=Ottawa');
mySelect.options[mySelect.options.length] = new Option("Pomona schools",'all=Pomona');
mySelect.options[mySelect.options.length] = new Option("Richmond schools",'all=Richmond');
mySelect.options[mySelect.options.length] = new Option("Wellsville schools",'all=Wellsville');
mySelect.options[mySelect.options.length] = new Option("Williamsburg schools",'all=Williamsburg');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Pomona[Pomona.length] = createMarker(new GPoint(-95.45165253,38.70310593),"
",iconRd);
mySelect.options[mySelect.options.length] = new Option("Appanoose Elementary School",'Pomona=' + Pomona.length);
Richmond[Richmond.length] = createMarker(new GPoint(-95.19200897,38.46302414),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Central Heights Elementary School",'Richmond=' + Richmond.length);
Richmond[Richmond.length] = createMarker(new GPoint(-95.19200897,38.46302414),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Central Heights High School",'Richmond=' + Richmond.length);
Ottawa[Ottawa.length] = createMarker(new GPoint(-95.27717590,38.59579086),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Eisenhower Elementary School",'Ottawa=' + Ottawa.length);
Ottawa[Ottawa.length] = createMarker(new GPoint(-95.27387238,38.60803223),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Eugene Field Elementary School",'Ottawa=' + Ottawa.length);
Ottawa[Ottawa.length] = createMarker(new GPoint(-95.26372528,38.59885025),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Garfield Elementary School",'Ottawa=' + Ottawa.length);
Ottawa[Ottawa.length] = createMarker(new GPoint(-95.26282501,38.61124802),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Hawthorne Elementary School",'Ottawa=' + Ottawa.length);
Ottawa[Ottawa.length] = createMarker(new GPoint(-95.26587677,38.62645721),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Lincoln Elementary School",'Ottawa=' + Ottawa.length);
Ottawa[Ottawa.length] = createMarker(new GPoint(-95.27717590,38.59857178),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Ottawa Middle School",'Ottawa=' + Ottawa.length);
Ottawa[Ottawa.length] = createMarker(new GPoint(-95.27724457,38.60064697),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Ottawa Senior High School",'Ottawa=' + Ottawa.length);
Pomona[Pomona.length] = createMarker(new GPoint(-95.44606018,38.60890579),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Pomona Elementary School",'Pomona=' + Pomona.length);
Pomona[Pomona.length] = createMarker(new GPoint(-95.44606781,38.60839844),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Pomona High School",'Pomona=' + Pomona.length);
Wellsville[Wellsville.length] = createMarker(new GPoint(-95.04699707,38.67599869),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Wellsville Elementary School",'Wellsville=' + Wellsville.length);
Wellsville[Wellsville.length] = createMarker(new GPoint(-95.08427429,38.71832275),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Wellsville High School",'Wellsville=' + Wellsville.length);
Wellsville[Wellsville.length] = createMarker(new GPoint(-95.08447266,38.71833420),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Wellsville Middle School",'Wellsville=' + Wellsville.length);
Williamsburg[Williamsburg.length] = createMarker(new GPoint(-95.44249725,38.46129990),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("West Franklin Learning Center Elementary (charter)",'Williamsburg=' + Williamsburg.length);
Williamsburg[Williamsburg.length] = createMarker(new GPoint(-95.43879700,38.48089981),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("West Franklin Learning Center Elementary - Charter",'Williamsburg=' + Williamsburg.length);
Williamsburg[Williamsburg.length] = createMarker(new GPoint(-95.43879700,38.48089981),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("West Franklin Learning Center High - Charter",'Williamsburg=' + Williamsburg.length);
Williamsburg[Williamsburg.length] = createMarker(new GPoint(-95.46527100,38.47999191),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("West Franklin Learning Center High School",'Williamsburg=' + Williamsburg.length);
Williamsburg[Williamsburg.length] = createMarker(new GPoint(-95.43879700,38.48089981),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Williamsburg Elementary School",'Williamsburg=' + Williamsburg.length);
Williamsburg[Williamsburg.length] = createMarker(new GPoint(-95.43879700,38.48089981),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Williamsburg High School",'Williamsburg=' + Williamsburg.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(Ottawa);
map.removeOverlays(Pomona);
map.removeOverlays(Richmond);
map.removeOverlays(Wellsville);
map.removeOverlays(Williamsburg);
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(Pomona);map.removeOverlays(Ottawa);
map.removeOverlays(Pomona);
map.removeOverlays(Richmond);
map.removeOverlays(Wellsville);
map.removeOverlays(Williamsburg);
map.addOverlays(Ottawa);
centerByArray(Ottawa, false, false);
cntMarker += Ottawa.length;
map.addOverlays(Pomona);
centerByArray(Pomona, false, false);
cntMarker += Pomona.length;
map.addOverlays(Richmond);
centerByArray(Richmond, false, false);
cntMarker += Richmond.length;
map.addOverlays(Wellsville);
centerByArray(Wellsville, false, false);
cntMarker += Wellsville.length;
map.addOverlays(Williamsburg);
centerByArray(Williamsburg, false, false);
cntMarker += Williamsburg.length;
centerByArray(Pomona,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');
}
}