function addMarkers()
{
mySelect = document.getElementById('selection');
Newark = [];Red_Creek = [];Clyde = [];Wolcott = [];Ontario_Center = [];Walworth = [];Williamson = [];Lyons = [];Macedon = [];Marion = [];North_Rose = [];Palmyra = [];Savannah = [];Sodus = [];mySelect.options[mySelect.options.length] = new Option("Clyde schools",'all=Clyde');
mySelect.options[mySelect.options.length] = new Option("Lyons schools",'all=Lyons');
mySelect.options[mySelect.options.length] = new Option("Macedon schools",'all=Macedon');
mySelect.options[mySelect.options.length] = new Option("Marion schools",'all=Marion');
mySelect.options[mySelect.options.length] = new Option("Newark schools",'all=Newark');
mySelect.options[mySelect.options.length] = new Option("North Rose schools",'all=North_Rose');
mySelect.options[mySelect.options.length] = new Option("Ontario Center schools",'all=Ontario_Center');
mySelect.options[mySelect.options.length] = new Option("Palmyra schools",'all=Palmyra');
mySelect.options[mySelect.options.length] = new Option("Red Creek schools",'all=Red_Creek');
mySelect.options[mySelect.options.length] = new Option("Savannah schools",'all=Savannah');
mySelect.options[mySelect.options.length] = new Option("Sodus schools",'all=Sodus');
mySelect.options[mySelect.options.length] = new Option("Walworth schools",'all=Walworth');
mySelect.options[mySelect.options.length] = new Option("Williamson schools",'all=Williamson');
mySelect.options[mySelect.options.length] = new Option("Wolcott schools",'all=Wolcott');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Newark[Newark.length] = createMarker(new GPoint(-77.08197021,43.03889465),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Boces Ontar-senec-yates-cayuga-wayne",'Newark=' + Newark.length);
Red_Creek[Red_Creek.length] = createMarker(new GPoint(-76.72400665,43.24618149),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Butler Corr Facil",'Red_Creek=' + Red_Creek.length);
Clyde[Clyde.length] = createMarker(new GPoint(-76.87280273,43.07680130),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Clyde Elementary School",'Clyde=' + Clyde.length);
Clyde[Clyde.length] = createMarker(new GPoint(-76.86726379,43.08798981),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Clyde Junior Senior High School",'Clyde=' + Clyde.length);
Wolcott[Wolcott.length] = createMarker(new GPoint(-76.81452942,43.21166992),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Florentine Hendrick Elementary School",'Wolcott=' + Wolcott.length);
Ontario_Center[Ontario_Center.length] = createMarker(new GPoint(-77.30609894,43.22579956),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Freewill Elementary School",'Ontario_Center=' + Ontario_Center.length);
Walworth[Walworth.length] = createMarker(new GPoint(-77.30618286,43.12011337),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Gananda / R A Cirillo High School",'Walworth=' + Walworth.length);
Walworth[Walworth.length] = createMarker(new GPoint(-77.31278229,43.12046432),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Gananda / R Mann Elementary School",'Walworth=' + Walworth.length);
Walworth[Walworth.length] = createMarker(new GPoint(-77.30765533,43.12348557),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Gananda Middle School",'Walworth=' + Walworth.length);
Williamson[Williamson.length] = createMarker(new GPoint(-77.08668518,43.27146530),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Lake Avenue Group Home",'Williamson=' + Williamson.length);
Newark[Newark.length] = createMarker(new GPoint(-77.09530640,43.05754471),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Lincoln Elementary School",'Newark=' + Newark.length);
Lyons[Lyons.length] = createMarker(new GPoint(-76.99120331,43.06556320),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Lyons Elementary School",'Lyons=' + Lyons.length);
Lyons[Lyons.length] = createMarker(new GPoint(-76.98828125,43.06380463),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Lyons Middle School",'Lyons=' + Lyons.length);
Lyons[Lyons.length] = createMarker(new GPoint(-76.98828125,43.06380463),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Lyons Senior High School",'Lyons=' + Lyons.length);
Macedon[Macedon.length] = createMarker(new GPoint(-77.30324554,43.06761169),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Macedon Elementary School",'Macedon=' + Macedon.length);
Red_Creek[Red_Creek.length] = createMarker(new GPoint(-76.72052765,43.24081039),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Margaret W. Cuyler Elementary School",'Red_Creek=' + Red_Creek.length);
Marion[Marion.length] = createMarker(new GPoint(-77.18751526,43.14444351),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Marion Elementary School",'Marion=' + Marion.length);
Marion[Marion.length] = createMarker(new GPoint(-77.19400024,43.17392349),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Marion Junior Senior High School",'Marion=' + Marion.length);
Newark[Newark.length] = createMarker(new GPoint(-77.10648346,43.03707504),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Newark Middle School",'Newark=' + Newark.length);
Newark[Newark.length] = createMarker(new GPoint(-77.10653687,43.03779602),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Newark Senior High School",'Newark=' + Newark.length);
Newark[Newark.length] = createMarker(new GPoint(-77.10046387,43.04559708),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Norman R. Kelley Intermediate School",'Newark=' + Newark.length);
North_Rose[North_Rose.length] = createMarker(new GPoint(-76.88780975,43.18964767),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("North Rose Elementary School",'North_Rose=' + North_Rose.length);
Wolcott[Wolcott.length] = createMarker(new GPoint(-76.82980347,43.19236755),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("North Rose-wolcott High School",'Wolcott=' + Wolcott.length);
Wolcott[Wolcott.length] = createMarker(new GPoint(-76.81502533,43.21791840),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("North Rose-wolcott Middle School",'Wolcott=' + Wolcott.length);
Ontario_Center[Ontario_Center.length] = createMarker(new GPoint(-77.30609894,43.22579956),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Ontario Elementary School",'Ontario_Center=' + Ontario_Center.length);
Ontario_Center[Ontario_Center.length] = createMarker(new GPoint(-77.30609894,43.22579956),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Ontario Primary School",'Ontario_Center=' + Ontario_Center.length);
Palmyra[Palmyra.length] = createMarker(new GPoint(-77.23347473,43.06299973),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Palmyra Elementary School",'Palmyra=' + Palmyra.length);
Palmyra[Palmyra.length] = createMarker(new GPoint(-77.24423218,43.05751038),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Palmyra-macedon Middle School",'Palmyra=' + Palmyra.length);
Palmyra[Palmyra.length] = createMarker(new GPoint(-77.24424744,43.05776978),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Palmyra-macedon Senior High School",'Palmyra=' + Palmyra.length);
Newark[Newark.length] = createMarker(new GPoint(-77.10292053,43.03964996),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Perkins Elementary School",'Newark=' + Newark.length);
Red_Creek[Red_Creek.length] = createMarker(new GPoint(-76.72009277,43.23865891),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Red Creek High School",'Red_Creek=' + Red_Creek.length);
Red_Creek[Red_Creek.length] = createMarker(new GPoint(-76.72045898,43.24008942),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Red Creek Middle School",'Red_Creek=' + Red_Creek.length);
Walworth[Walworth.length] = createMarker(new GPoint(-77.27250900,43.13851500),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Richard Mann Elementary School",'Walworth=' + Walworth.length);
Savannah[Savannah.length] = createMarker(new GPoint(-76.75669861,43.08509827),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Savannah Elementary School",'Savannah=' + Savannah.length);
Sodus[Sodus.length] = createMarker(new GPoint(-77.04660034,43.22570038),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Sodus High School",'Sodus=' + Sodus.length);
Sodus[Sodus.length] = createMarker(new GPoint(-77.04660034,43.22570038),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Sodus Intermediate School",'Sodus=' + Sodus.length);
Sodus[Sodus.length] = createMarker(new GPoint(-77.04660034,43.22570038),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Sodus Middle School",'Sodus=' + Sodus.length);
Sodus[Sodus.length] = createMarker(new GPoint(-77.04660034,43.22570038),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Sodus Primary School",'Sodus=' + Sodus.length);
Ontario_Center[Ontario_Center.length] = createMarker(new GPoint(-77.30609894,43.22579956),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Wayne Central Middle School",'Ontario_Center=' + Ontario_Center.length);
Ontario_Center[Ontario_Center.length] = createMarker(new GPoint(-77.30589400,43.22630000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Wayne Senior High School",'Ontario_Center=' + Ontario_Center.length);
Williamson[Williamson.length] = createMarker(new GPoint(-77.18064117,43.21984100),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Williamson Elementary School",'Williamson=' + Williamson.length);
Williamson[Williamson.length] = createMarker(new GPoint(-77.18193054,43.22220993),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Williamson Middle School",'Williamson=' + Williamson.length);
Williamson[Williamson.length] = createMarker(new GPoint(-77.17199707,43.24710083),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Williamson Senior High School",'Williamson=' + Williamson.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(Clyde);
map.removeOverlays(Lyons);
map.removeOverlays(Macedon);
map.removeOverlays(Marion);
map.removeOverlays(Newark);
map.removeOverlays(North_Rose);
map.removeOverlays(Ontario_Center);
map.removeOverlays(Palmyra);
map.removeOverlays(Red_Creek);
map.removeOverlays(Savannah);
map.removeOverlays(Sodus);
map.removeOverlays(Walworth);
map.removeOverlays(Williamson);
map.removeOverlays(Wolcott);
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(Newark);map.removeOverlays(Clyde);
map.removeOverlays(Lyons);
map.removeOverlays(Macedon);
map.removeOverlays(Marion);
map.removeOverlays(Newark);
map.removeOverlays(North_Rose);
map.removeOverlays(Ontario_Center);
map.removeOverlays(Palmyra);
map.removeOverlays(Red_Creek);
map.removeOverlays(Savannah);
map.removeOverlays(Sodus);
map.removeOverlays(Walworth);
map.removeOverlays(Williamson);
map.removeOverlays(Wolcott);
map.addOverlays(Clyde);
centerByArray(Clyde, false, false);
cntMarker += Clyde.length;
map.addOverlays(Lyons);
centerByArray(Lyons, false, false);
cntMarker += Lyons.length;
map.addOverlays(Macedon);
centerByArray(Macedon, false, false);
cntMarker += Macedon.length;
map.addOverlays(Marion);
centerByArray(Marion, false, false);
cntMarker += Marion.length;
map.addOverlays(Newark);
centerByArray(Newark, false, false);
cntMarker += Newark.length;
map.addOverlays(North_Rose);
centerByArray(North_Rose, false, false);
cntMarker += North_Rose.length;
map.addOverlays(Ontario_Center);
centerByArray(Ontario_Center, false, false);
cntMarker += Ontario_Center.length;
map.addOverlays(Palmyra);
centerByArray(Palmyra, false, false);
cntMarker += Palmyra.length;
map.addOverlays(Red_Creek);
centerByArray(Red_Creek, false, false);
cntMarker += Red_Creek.length;
map.addOverlays(Savannah);
centerByArray(Savannah, false, false);
cntMarker += Savannah.length;
map.addOverlays(Sodus);
centerByArray(Sodus, false, false);
cntMarker += Sodus.length;
map.addOverlays(Walworth);
centerByArray(Walworth, false, false);
cntMarker += Walworth.length;
map.addOverlays(Williamson);
centerByArray(Williamson, false, false);
cntMarker += Williamson.length;
map.addOverlays(Wolcott);
centerByArray(Wolcott, false, false);
cntMarker += Wolcott.length;
centerByArray(Newark,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');
}
}