function addMarkers()
{
mySelect = document.getElementById('selection');
Florence = [];Burlington = [];Hebron = [];Covington = [];Union = [];Verona = [];Walton = [];mySelect.options[mySelect.options.length] = new Option("Burlington schools",'all=Burlington');
mySelect.options[mySelect.options.length] = new Option("Covington schools",'all=Covington');
mySelect.options[mySelect.options.length] = new Option("Florence schools",'all=Florence');
mySelect.options[mySelect.options.length] = new Option("Hebron schools",'all=Hebron');
mySelect.options[mySelect.options.length] = new Option("Union schools",'all=Union');
mySelect.options[mySelect.options.length] = new Option("Verona schools",'all=Verona');
mySelect.options[mySelect.options.length] = new Option("Walton schools",'all=Walton');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Florence[Florence.length] = createMarker(new GPoint(-84.66050720,38.98846054),"
",iconRd);
mySelect.options[mySelect.options.length] = new Option("A M Yealey Elementary School",'Florence=' + Florence.length);
Florence[Florence.length] = createMarker(new GPoint(-84.63029480,39.00562668),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Boone County High School",'Florence=' + Florence.length);
Burlington[Burlington.length] = createMarker(new GPoint(-84.72071838,39.02907944),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Burlington Elementary School",'Burlington=' + Burlington.length);
Burlington[Burlington.length] = createMarker(new GPoint(-84.70361100,39.01167700),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Camp Ernst Middle School",'Burlington=' + Burlington.length);
Hebron[Hebron.length] = createMarker(new GPoint(-84.69268036,39.06112671),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Chester Goodridge Elementary School",'Hebron=' + Hebron.length);
Covington[Covington.length] = createMarker(new GPoint(-84.52931213,39.04944611),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Children/adolescent Partial Alternative Elementary School",'Covington=' + Covington.length);
Hebron[Hebron.length] = createMarker(new GPoint(-84.69329071,39.06098938),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Conner High School",'Hebron=' + Hebron.length);
Hebron[Hebron.length] = createMarker(new GPoint(-84.69972992,39.05995178),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Conner Middle School",'Hebron=' + Hebron.length);
Florence[Florence.length] = createMarker(new GPoint(-84.62607574,38.99752808),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Erpenbeck Elementary School",'Florence=' + Florence.length);
Florence[Florence.length] = createMarker(new GPoint(-84.62930298,39.00231552),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Florence Elementary School",'Florence=' + Florence.length);
Union[Union.length] = createMarker(new GPoint(-84.67526200,38.93232400),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Gray Middle School",'Union=' + Union.length);
Florence[Florence.length] = createMarker(new GPoint(-84.61712646,38.99047852),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Hillard Collins Elementary School",'Florence=' + Florence.length);
Burlington[Burlington.length] = createMarker(new GPoint(-84.82622528,38.98363113),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Kelly Elementary School",'Burlington=' + Burlington.length);
Union[Union.length] = createMarker(new GPoint(-84.67540741,38.93210602),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Larry A. Ryle High School",'Union=' + Union.length);
Burlington[Burlington.length] = createMarker(new GPoint(-84.73203278,39.03502655),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Maplewood Children's Home Alternative",'Burlington=' + Burlington.length);
Burlington[Burlington.length] = createMarker(new GPoint(-84.73203278,39.03502655),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Maplewood Home Alternative High School",'Burlington=' + Burlington.length);
Union[Union.length] = createMarker(new GPoint(-84.68065643,38.91722107),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("New Haven Elementary School",'Union=' + Union.length);
Hebron[Hebron.length] = createMarker(new GPoint(-84.73307037,39.11312485),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("North Pointe Elementary School",'Hebron=' + Hebron.length);
Florence[Florence.length] = createMarker(new GPoint(-84.65183258,38.98159409),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Ockerman Elementary School",'Florence=' + Florence.length);
Florence[Florence.length] = createMarker(new GPoint(-84.65296300,38.98043400),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Ockerman Middle School",'Florence=' + Florence.length);
Florence[Florence.length] = createMarker(new GPoint(-84.63099400,39.00085000),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Rector A Jones Middle School",'Florence=' + Florence.length);
Burlington[Burlington.length] = createMarker(new GPoint(-84.70127869,39.02631378),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Stephens Elementary School",'Burlington=' + Burlington.length);
Verona[Verona.length] = createMarker(new GPoint(-84.67184448,38.82045364),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Walton-verona Elementary School",'Verona=' + Verona.length);
Walton[Walton.length] = createMarker(new GPoint(-84.61782837,38.86408997),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Walton-verona High School",'Walton=' + Walton.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(Burlington);
map.removeOverlays(Covington);
map.removeOverlays(Florence);
map.removeOverlays(Hebron);
map.removeOverlays(Union);
map.removeOverlays(Verona);
map.removeOverlays(Walton);
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(Florence);map.removeOverlays(Burlington);
map.removeOverlays(Covington);
map.removeOverlays(Florence);
map.removeOverlays(Hebron);
map.removeOverlays(Union);
map.removeOverlays(Verona);
map.removeOverlays(Walton);
map.addOverlays(Burlington);
centerByArray(Burlington, false, false);
cntMarker += Burlington.length;
map.addOverlays(Covington);
centerByArray(Covington, false, false);
cntMarker += Covington.length;
map.addOverlays(Florence);
centerByArray(Florence, false, false);
cntMarker += Florence.length;
map.addOverlays(Hebron);
centerByArray(Hebron, false, false);
cntMarker += Hebron.length;
map.addOverlays(Union);
centerByArray(Union, false, false);
cntMarker += Union.length;
map.addOverlays(Verona);
centerByArray(Verona, false, false);
cntMarker += Verona.length;
map.addOverlays(Walton);
centerByArray(Walton, false, false);
cntMarker += Walton.length;
centerByArray(Florence,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');
}
}