function addMarkers()
{
mySelect = document.getElementById('selection');
Middlefield = [];Burton = [];Chardon = [];East_Claridon = [];Chagrin_Falls = [];Huntsburg = [];Thompson = [];Newbury = [];Parkman = [];Chesterland = [];Novelty = [];mySelect.options[mySelect.options.length] = new Option("Burton schools",'all=Burton');
mySelect.options[mySelect.options.length] = new Option("Chagrin Falls schools",'all=Chagrin_Falls');
mySelect.options[mySelect.options.length] = new Option("Chardon schools",'all=Chardon');
mySelect.options[mySelect.options.length] = new Option("Chesterland schools",'all=Chesterland');
mySelect.options[mySelect.options.length] = new Option("East Claridon schools",'all=East_Claridon');
mySelect.options[mySelect.options.length] = new Option("Huntsburg schools",'all=Huntsburg');
mySelect.options[mySelect.options.length] = new Option("Middlefield schools",'all=Middlefield');
mySelect.options[mySelect.options.length] = new Option("Newbury schools",'all=Newbury');
mySelect.options[mySelect.options.length] = new Option("Novelty schools",'all=Novelty');
mySelect.options[mySelect.options.length] = new Option("Parkman schools",'all=Parkman');
mySelect.options[mySelect.options.length] = new Option("Thompson schools",'all=Thompson');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Middlefield[Middlefield.length] = createMarker(new GPoint(-81.04399872,41.44889832),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("A J Jordak Elementary School",'Middlefield=' + Middlefield.length);
Burton[Burton.length] = createMarker(new GPoint(-81.16390228,41.44400024),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Berkshire High School",'Burton=' + Burton.length);
Burton[Burton.length] = createMarker(new GPoint(-81.14952087,41.46713638),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Burton Elementary School",'Burton=' + Burton.length);
Middlefield[Middlefield.length] = createMarker(new GPoint(-81.04399872,41.44889832),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Cardinal High School",'Middlefield=' + Middlefield.length);
Middlefield[Middlefield.length] = createMarker(new GPoint(-81.04399872,41.44889832),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Cardinal Middle School",'Middlefield=' + Middlefield.length);
Chardon[Chardon.length] = createMarker(new GPoint(-81.20024109,41.58963776),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Chardon High School",'Chardon=' + Chardon.length);
Chardon[Chardon.length] = createMarker(new GPoint(-81.20555115,41.59054947),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Chardon Middle School",'Chardon=' + Chardon.length);
East_Claridon[East_Claridon.length] = createMarker(new GPoint(-81.11579895,41.53250122),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Claridon Elementary School",'East_Claridon=' + East_Claridon.length);
Chagrin_Falls[Chagrin_Falls.length] = createMarker(new GPoint(-81.33946228,41.38237762),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Early Learning Center Elementary School",'Chagrin_Falls=' + Chagrin_Falls.length);
Chagrin_Falls[Chagrin_Falls.length] = createMarker(new GPoint(-81.34225464,41.43153763),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Gurney Elementary School",'Chagrin_Falls=' + Chagrin_Falls.length);
Chardon[Chardon.length] = createMarker(new GPoint(-81.14453888,41.60550308),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Hambden Elementary School",'Chardon=' + Chardon.length);
Huntsburg[Huntsburg.length] = createMarker(new GPoint(-81.07730103,41.53369904),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Huntsburg Elementary School",'Huntsburg=' + Huntsburg.length);
Chagrin_Falls[Chagrin_Falls.length] = createMarker(new GPoint(-81.30773163,41.39332962),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Kenston High School",'Chagrin_Falls=' + Chagrin_Falls.length);
Chagrin_Falls[Chagrin_Falls.length] = createMarker(new GPoint(-81.30772400,41.39344025),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Kenston Middle School",'Chagrin_Falls=' + Chagrin_Falls.length);
Thompson[Thompson.length] = createMarker(new GPoint(-81.06233978,41.64183807),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Ledgemont Elementary School",'Thompson=' + Thompson.length);
Thompson[Thompson.length] = createMarker(new GPoint(-81.04639435,41.69014740),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Ledgemont High School",'Thompson=' + Thompson.length);
Chardon[Chardon.length] = createMarker(new GPoint(-81.19881439,41.58995819),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Maple Elementary School",'Chardon=' + Chardon.length);
Middlefield[Middlefield.length] = createMarker(new GPoint(-81.06997681,41.46198273),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Middlefield Educational Center",'Middlefield=' + Middlefield.length);
Chardon[Chardon.length] = createMarker(new GPoint(-81.21627045,41.52396774),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Munson Elementary School",'Chardon=' + Chardon.length);
Newbury[Newbury.length] = createMarker(new GPoint(-81.24404907,41.46458054),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Newbury Elementary School",'Newbury=' + Newbury.length);
Newbury[Newbury.length] = createMarker(new GPoint(-81.24404907,41.46458054),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Newbury High School",'Newbury=' + Newbury.length);
Chardon[Chardon.length] = createMarker(new GPoint(-81.20220947,41.58233643),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Park Elementary School",'Chardon=' + Chardon.length);
Parkman[Parkman.length] = createMarker(new GPoint(-81.06649780,41.37229919),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Parkman Elementary School",'Parkman=' + Parkman.length);
Chagrin_Falls[Chagrin_Falls.length] = createMarker(new GPoint(-81.30599213,41.38796234),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Paul S Gardiner Elementary School",'Chagrin_Falls=' + Chagrin_Falls.length);
Chesterland[Chesterland.length] = createMarker(new GPoint(-81.36307526,41.54790497),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Robert C Lindsey Elementary School",'Chesterland=' + Chesterland.length);
Chagrin_Falls[Chagrin_Falls.length] = createMarker(new GPoint(-81.29945374,41.39638519),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Timmons Elementary School",'Chagrin_Falls=' + Chagrin_Falls.length);
Burton[Burton.length] = createMarker(new GPoint(-81.14384460,41.39569855),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Troy Elementary School",'Burton=' + Burton.length);
Chesterland[Chesterland.length] = createMarker(new GPoint(-81.33924866,41.50287628),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("West Geauga High School",'Chesterland=' + Chesterland.length);
Chesterland[Chesterland.length] = createMarker(new GPoint(-81.33480072,41.50721741),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("West Geauga Middle School",'Chesterland=' + Chesterland.length);
Novelty[Novelty.length] = createMarker(new GPoint(-81.36238098,41.49402237),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Westwood Elementary School",'Novelty=' + Novelty.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(Burton);
map.removeOverlays(Chagrin_Falls);
map.removeOverlays(Chardon);
map.removeOverlays(Chesterland);
map.removeOverlays(East_Claridon);
map.removeOverlays(Huntsburg);
map.removeOverlays(Middlefield);
map.removeOverlays(Newbury);
map.removeOverlays(Novelty);
map.removeOverlays(Parkman);
map.removeOverlays(Thompson);
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(Middlefield);map.removeOverlays(Burton);
map.removeOverlays(Chagrin_Falls);
map.removeOverlays(Chardon);
map.removeOverlays(Chesterland);
map.removeOverlays(East_Claridon);
map.removeOverlays(Huntsburg);
map.removeOverlays(Middlefield);
map.removeOverlays(Newbury);
map.removeOverlays(Novelty);
map.removeOverlays(Parkman);
map.removeOverlays(Thompson);
map.addOverlays(Burton);
centerByArray(Burton, false, false);
cntMarker += Burton.length;
map.addOverlays(Chagrin_Falls);
centerByArray(Chagrin_Falls, false, false);
cntMarker += Chagrin_Falls.length;
map.addOverlays(Chardon);
centerByArray(Chardon, false, false);
cntMarker += Chardon.length;
map.addOverlays(Chesterland);
centerByArray(Chesterland, false, false);
cntMarker += Chesterland.length;
map.addOverlays(East_Claridon);
centerByArray(East_Claridon, false, false);
cntMarker += East_Claridon.length;
map.addOverlays(Huntsburg);
centerByArray(Huntsburg, false, false);
cntMarker += Huntsburg.length;
map.addOverlays(Middlefield);
centerByArray(Middlefield, false, false);
cntMarker += Middlefield.length;
map.addOverlays(Newbury);
centerByArray(Newbury, false, false);
cntMarker += Newbury.length;
map.addOverlays(Novelty);
centerByArray(Novelty, false, false);
cntMarker += Novelty.length;
map.addOverlays(Parkman);
centerByArray(Parkman, false, false);
cntMarker += Parkman.length;
map.addOverlays(Thompson);
centerByArray(Thompson, false, false);
cntMarker += Thompson.length;
centerByArray(Middlefield,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');
}
}