function addMarkers()
{
mySelect = document.getElementById('selection');
Corydon = [];Central = [];Lanesville = [];Palmyra = [];New_Middletown = [];Ramsey = [];Elizabeth = [];mySelect.options[mySelect.options.length] = new Option("Central schools",'all=Central');
mySelect.options[mySelect.options.length] = new Option("Corydon schools",'all=Corydon');
mySelect.options[mySelect.options.length] = new Option("Elizabeth schools",'all=Elizabeth');
mySelect.options[mySelect.options.length] = new Option("Lanesville schools",'all=Lanesville');
mySelect.options[mySelect.options.length] = new Option("New Middletown schools",'all=New_Middletown');
mySelect.options[mySelect.options.length] = new Option("Palmyra schools",'all=Palmyra');
mySelect.options[mySelect.options.length] = new Option("Ramsey schools",'all=Ramsey');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Corydon[Corydon.length] = createMarker(new GPoint(-86.12750244,38.20999908),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Corydon Central High School",'Corydon=' + Corydon.length);
Corydon[Corydon.length] = createMarker(new GPoint(-86.11544037,38.20056152),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Corydon Central Junior High School",'Corydon=' + Corydon.length);
Corydon[Corydon.length] = createMarker(new GPoint(-86.12094116,38.20732498),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Corydon Elementary School",'Corydon=' + Corydon.length);
Corydon[Corydon.length] = createMarker(new GPoint(-86.12184143,38.20175171),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Corydon Intermediate School",'Corydon=' + Corydon.length);
Corydon[Corydon.length] = createMarker(new GPoint(-86.16619873,38.20824051),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Harrison County Spec Ed Coop",'Corydon=' + Corydon.length);
Central[Central.length] = createMarker(new GPoint(-86.17508698,38.10043716),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Heth-washington Elementary School",'Central=' + Central.length);
Lanesville[Lanesville.length] = createMarker(new GPoint(-85.98782349,38.23808289),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Lanesville Elementary School",'Lanesville=' + Lanesville.length);
Lanesville[Lanesville.length] = createMarker(new GPoint(-85.98782349,38.23808289),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Lanesville Junior Senior High School",'Lanesville=' + Lanesville.length);
Palmyra[Palmyra.length] = createMarker(new GPoint(-86.09999847,38.40489960),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Morgan Elementary School",'Palmyra=' + Palmyra.length);
New_Middletown[New_Middletown.length] = createMarker(new GPoint(-86.04492187,38.12717819),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("New Middletown Elementary School",'New_Middletown=' + New_Middletown.length);
Ramsey[Ramsey.length] = createMarker(new GPoint(-86.14453125,38.32658386),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("North Harrison Elementary School",'Ramsey=' + Ramsey.length);
Ramsey[Ramsey.length] = createMarker(new GPoint(-86.16609955,38.31069946),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("North Harrison High School",'Ramsey=' + Ramsey.length);
Ramsey[Ramsey.length] = createMarker(new GPoint(-86.14654541,38.32111359),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("North Harrison Middle School",'Ramsey=' + Ramsey.length);
Ramsey[Ramsey.length] = createMarker(new GPoint(-86.16609955,38.31069946),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("North Harrison Upper Elementary School",'Ramsey=' + Ramsey.length);
Elizabeth[Elizabeth.length] = createMarker(new GPoint(-86.00402832,38.08256149),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("South Central Elementary School",'Elizabeth=' + Elizabeth.length);
Elizabeth[Elizabeth.length] = createMarker(new GPoint(-86.00302124,38.08256149),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("South Central Junior & Senior High School",'Elizabeth=' + Elizabeth.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(Central);
map.removeOverlays(Corydon);
map.removeOverlays(Elizabeth);
map.removeOverlays(Lanesville);
map.removeOverlays(New_Middletown);
map.removeOverlays(Palmyra);
map.removeOverlays(Ramsey);
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(Corydon);map.removeOverlays(Central);
map.removeOverlays(Corydon);
map.removeOverlays(Elizabeth);
map.removeOverlays(Lanesville);
map.removeOverlays(New_Middletown);
map.removeOverlays(Palmyra);
map.removeOverlays(Ramsey);
map.addOverlays(Central);
centerByArray(Central, false, false);
cntMarker += Central.length;
map.addOverlays(Corydon);
centerByArray(Corydon, false, false);
cntMarker += Corydon.length;
map.addOverlays(Elizabeth);
centerByArray(Elizabeth, false, false);
cntMarker += Elizabeth.length;
map.addOverlays(Lanesville);
centerByArray(Lanesville, false, false);
cntMarker += Lanesville.length;
map.addOverlays(New_Middletown);
centerByArray(New_Middletown, false, false);
cntMarker += New_Middletown.length;
map.addOverlays(Palmyra);
centerByArray(Palmyra, false, false);
cntMarker += Palmyra.length;
map.addOverlays(Ramsey);
centerByArray(Ramsey, false, false);
cntMarker += Ramsey.length;
centerByArray(Corydon,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');
}
}