function addMarkers()
{
mySelect = document.getElementById('selection');
Attica = [];Bettsville = [];Tiffin = [];Bloomville = [];Fostoria = [];Wayne = [];Bascom = [];Mc_Cutchenville = [];Melmore = [];New_Riegel = [];Old_Fort = [];Republic = [];Bellevue = [];mySelect.options[mySelect.options.length] = new Option("Attica schools",'all=Attica');
mySelect.options[mySelect.options.length] = new Option("Bascom schools",'all=Bascom');
mySelect.options[mySelect.options.length] = new Option("Bellevue schools",'all=Bellevue');
mySelect.options[mySelect.options.length] = new Option("Bettsville schools",'all=Bettsville');
mySelect.options[mySelect.options.length] = new Option("Bloomville schools",'all=Bloomville');
mySelect.options[mySelect.options.length] = new Option("Fostoria schools",'all=Fostoria');
mySelect.options[mySelect.options.length] = new Option("Mc Cutchenville schools",'all=Mc_Cutchenville');
mySelect.options[mySelect.options.length] = new Option("Melmore schools",'all=Melmore');
mySelect.options[mySelect.options.length] = new Option("New Riegel schools",'all=New_Riegel');
mySelect.options[mySelect.options.length] = new Option("Old Fort schools",'all=Old_Fort');
mySelect.options[mySelect.options.length] = new Option("Republic schools",'all=Republic');
mySelect.options[mySelect.options.length] = new Option("Tiffin schools",'all=Tiffin');
mySelect.options[mySelect.options.length] = new Option("Wayne schools",'all=Wayne');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Attica[Attica.length] = createMarker(new GPoint(-82.88610077,41.06090164),"
",iconRd);
mySelect.options[mySelect.options.length] = new Option("Attica Elementary School",'Attica=' + Attica.length);
Bettsville[Bettsville.length] = createMarker(new GPoint(-83.23370361,41.24430084),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Bettsville Elementary School",'Bettsville=' + Bettsville.length);
Bettsville[Bettsville.length] = createMarker(new GPoint(-83.23370361,41.24430084),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bettsville High School",'Bettsville=' + Bettsville.length);
Bettsville[Bettsville.length] = createMarker(new GPoint(-83.23370361,41.24430084),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Bettsville Middle School",'Bettsville=' + Bettsville.length);
Tiffin[Tiffin.length] = createMarker(new GPoint(-83.17109200,41.09800600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bridges Community Academy",'Tiffin=' + Tiffin.length);
Bloomville[Bloomville.length] = createMarker(new GPoint(-83.01511383,41.04687881),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Buckeye North Elementary School",'Bloomville=' + Bloomville.length);
Tiffin[Tiffin.length] = createMarker(new GPoint(-83.11239624,41.13887787),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Clinton Elementary School",'Tiffin=' + Tiffin.length);
Tiffin[Tiffin.length] = createMarker(new GPoint(-83.17735291,41.10784531),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Columbian High School",'Tiffin=' + Tiffin.length);
Fostoria[Fostoria.length] = createMarker(new GPoint(-83.41499329,41.14923859),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Field Elementary School",'Fostoria=' + Fostoria.length);
Wayne[Wayne.length] = createMarker(new GPoint(-83.50431061,41.26948547),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Fostoria",'Wayne=' + Wayne.length);
Fostoria[Fostoria.length] = createMarker(new GPoint(-83.43125916,41.16674805),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Fostoria Middle School",'Fostoria=' + Fostoria.length);
Bascom[Bascom.length] = createMarker(new GPoint(-83.28520203,41.13270187),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Hopewell-loudon Local Elementary School",'Bascom=' + Bascom.length);
Bascom[Bascom.length] = createMarker(new GPoint(-83.28520203,41.13270187),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Hopewell-loudon Local High School",'Bascom=' + Bascom.length);
Tiffin[Tiffin.length] = createMarker(new GPoint(-83.17405701,41.10146332),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Krout Elementary School",'Tiffin=' + Tiffin.length);
Fostoria[Fostoria.length] = createMarker(new GPoint(-83.32778168,41.21608353),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Lakota Junior High School",'Fostoria=' + Fostoria.length);
Tiffin[Tiffin.length] = createMarker(new GPoint(-83.16515350,41.12315369),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Lincoln Elementary School",'Tiffin=' + Tiffin.length);
Fostoria[Fostoria.length] = createMarker(new GPoint(-83.40509033,41.16332626),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Longfellow Elementary School",'Fostoria=' + Fostoria.length);
Fostoria[Fostoria.length] = createMarker(new GPoint(-83.41496277,41.16395187),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Lowell Elementary School",'Fostoria=' + Fostoria.length);
Mc_Cutchenville[Mc_Cutchenville.length] = createMarker(new GPoint(-83.25646973,40.99486160),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Mccutchenville Elementary School",'Mc_Cutchenville=' + Mc_Cutchenville.length);
Melmore[Melmore.length] = createMarker(new GPoint(-83.14559937,41.03639984),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Melmore Elementary School",'Melmore=' + Melmore.length);
New_Riegel[New_Riegel.length] = createMarker(new GPoint(-83.31942749,41.05308151),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("New Riegel Elementary School",'New_Riegel=' + New_Riegel.length);
New_Riegel[New_Riegel.length] = createMarker(new GPoint(-83.31942749,41.05308151),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("New Riegel High School",'New_Riegel=' + New_Riegel.length);
Tiffin[Tiffin.length] = createMarker(new GPoint(-83.17663574,41.12394714),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Noble Elementary School",'Tiffin=' + Tiffin.length);
Old_Fort[Old_Fort.length] = createMarker(new GPoint(-83.14880371,41.23979950),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Old Fort Elementary School",'Old_Fort=' + Old_Fort.length);
Old_Fort[Old_Fort.length] = createMarker(new GPoint(-83.14880371,41.23979950),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Old Fort High School",'Old_Fort=' + Old_Fort.length);
Republic[Republic.length] = createMarker(new GPoint(-83.00289917,41.13510132),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Republic Elementary School",'Republic=' + Republic.length);
Fostoria[Fostoria.length] = createMarker(new GPoint(-83.41699982,41.17263412),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Riley Elementary School",'Fostoria=' + Fostoria.length);
Attica[Attica.length] = createMarker(new GPoint(-82.88610077,41.06090164),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Seneca East High School",'Attica=' + Attica.length);
Republic[Republic.length] = createMarker(new GPoint(-83.00289917,41.13510132),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Seneca East Junior High School",'Republic=' + Republic.length);
Bellevue[Bellevue.length] = createMarker(new GPoint(-82.83956909,41.16586304),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Seneca-huron Elementary School",'Bellevue=' + Bellevue.length);
Tiffin[Tiffin.length] = createMarker(new GPoint(-83.15311432,41.08806992),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Sentinel Career Center",'Tiffin=' + Tiffin.length);
Tiffin[Tiffin.length] = createMarker(new GPoint(-83.17694300,41.10705500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Tiffin City Digital Academy",'Tiffin=' + Tiffin.length);
Tiffin[Tiffin.length] = createMarker(new GPoint(-83.17438507,41.11469650),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Tiffin Junior High School",'Tiffin=' + Tiffin.length);
Tiffin[Tiffin.length] = createMarker(new GPoint(-83.17720032,41.11009979),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Tiffin Middle School",'Tiffin=' + Tiffin.length);
Tiffin[Tiffin.length] = createMarker(new GPoint(-83.19388580,41.11753464),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Washington Elementary School",'Tiffin=' + Tiffin.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(Attica);
map.removeOverlays(Bascom);
map.removeOverlays(Bellevue);
map.removeOverlays(Bettsville);
map.removeOverlays(Bloomville);
map.removeOverlays(Fostoria);
map.removeOverlays(Mc_Cutchenville);
map.removeOverlays(Melmore);
map.removeOverlays(New_Riegel);
map.removeOverlays(Old_Fort);
map.removeOverlays(Republic);
map.removeOverlays(Tiffin);
map.removeOverlays(Wayne);
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(Attica);map.removeOverlays(Attica);
map.removeOverlays(Bascom);
map.removeOverlays(Bellevue);
map.removeOverlays(Bettsville);
map.removeOverlays(Bloomville);
map.removeOverlays(Fostoria);
map.removeOverlays(Mc_Cutchenville);
map.removeOverlays(Melmore);
map.removeOverlays(New_Riegel);
map.removeOverlays(Old_Fort);
map.removeOverlays(Republic);
map.removeOverlays(Tiffin);
map.removeOverlays(Wayne);
map.addOverlays(Attica);
centerByArray(Attica, false, false);
cntMarker += Attica.length;
map.addOverlays(Bascom);
centerByArray(Bascom, false, false);
cntMarker += Bascom.length;
map.addOverlays(Bellevue);
centerByArray(Bellevue, false, false);
cntMarker += Bellevue.length;
map.addOverlays(Bettsville);
centerByArray(Bettsville, false, false);
cntMarker += Bettsville.length;
map.addOverlays(Bloomville);
centerByArray(Bloomville, false, false);
cntMarker += Bloomville.length;
map.addOverlays(Fostoria);
centerByArray(Fostoria, false, false);
cntMarker += Fostoria.length;
map.addOverlays(Mc_Cutchenville);
centerByArray(Mc_Cutchenville, false, false);
cntMarker += Mc_Cutchenville.length;
map.addOverlays(Melmore);
centerByArray(Melmore, false, false);
cntMarker += Melmore.length;
map.addOverlays(New_Riegel);
centerByArray(New_Riegel, false, false);
cntMarker += New_Riegel.length;
map.addOverlays(Old_Fort);
centerByArray(Old_Fort, false, false);
cntMarker += Old_Fort.length;
map.addOverlays(Republic);
centerByArray(Republic, false, false);
cntMarker += Republic.length;
map.addOverlays(Tiffin);
centerByArray(Tiffin, false, false);
cntMarker += Tiffin.length;
map.addOverlays(Wayne);
centerByArray(Wayne, false, false);
cntMarker += Wayne.length;
centerByArray(Attica,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');
}
}