function addMarkers()
{
mySelect = document.getElementById('selection');
Port_Deposit = [];North_East = [];Chesapeake_City = [];Rising_Sun = [];Elkton = [];Cecilton = [];Charlestown = [];Conowingo = [];Perryville = [];mySelect.options[mySelect.options.length] = new Option("Cecilton schools",'all=Cecilton');
mySelect.options[mySelect.options.length] = new Option("Charlestown schools",'all=Charlestown');
mySelect.options[mySelect.options.length] = new Option("Chesapeake City schools",'all=Chesapeake_City');
mySelect.options[mySelect.options.length] = new Option("Conowingo schools",'all=Conowingo');
mySelect.options[mySelect.options.length] = new Option("Elkton schools",'all=Elkton');
mySelect.options[mySelect.options.length] = new Option("North East schools",'all=North_East');
mySelect.options[mySelect.options.length] = new Option("Perryville schools",'all=Perryville');
mySelect.options[mySelect.options.length] = new Option("Port Deposit schools",'all=Port_Deposit');
mySelect.options[mySelect.options.length] = new Option("Rising Sun schools",'all=Rising_Sun');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Port_Deposit[Port_Deposit.length] = createMarker(new GPoint(-76.07875061,39.60654449),"
",iconRd);
mySelect.options[mySelect.options.length] = new Option("Bainbridge Elementary School",'Port_Deposit=' + Port_Deposit.length);
North_East[North_East.length] = createMarker(new GPoint(-75.95836639,39.63935471),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Bay View Elementary School",'North_East=' + North_East.length);
Chesapeake_City[Chesapeake_City.length] = createMarker(new GPoint(-75.82560730,39.51340103),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bohemia Manor High School",'Chesapeake_City=' + Chesapeake_City.length);
Chesapeake_City[Chesapeake_City.length] = createMarker(new GPoint(-75.82565308,39.51335907),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Bohemia Manor Middle School",'Chesapeake_City=' + Chesapeake_City.length);
Rising_Sun[Rising_Sun.length] = createMarker(new GPoint(-75.98322296,39.70069885),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Calvert Elementary School",'Rising_Sun=' + Rising_Sun.length);
North_East[North_East.length] = createMarker(new GPoint(-75.95751953,39.63893890),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Cecil County School Of Technology",'North_East=' + North_East.length);
Elkton[Elkton.length] = createMarker(new GPoint(-75.81706238,39.65623856),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Cecil Manor Elementary School",'Elkton=' + Elkton.length);
Cecilton[Cecilton.length] = createMarker(new GPoint(-75.87436676,39.40514374),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Cecilton Elementary School",'Cecilton=' + Cecilton.length);
Charlestown[Charlestown.length] = createMarker(new GPoint(-75.98278046,39.57355499),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Charlestown Elementary School",'Charlestown=' + Charlestown.length);
Elkton[Elkton.length] = createMarker(new GPoint(-75.85851288,39.67407990),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Cherry Hill Middle School",'Elkton=' + Elkton.length);
Chesapeake_City[Chesapeake_City.length] = createMarker(new GPoint(-75.81582642,39.52771759),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Chesapeake City Elementary School",'Chesapeake_City=' + Chesapeake_City.length);
Conowingo[Conowingo.length] = createMarker(new GPoint(-76.14839935,39.66411591),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Conowingo Elementary School",'Conowingo=' + Conowingo.length);
Elkton[Elkton.length] = createMarker(new GPoint(-75.89878082,39.53382111),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Elk Neck Elementary School",'Elkton=' + Elkton.length);
Elkton[Elkton.length] = createMarker(new GPoint(-75.83332825,39.62127304),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Elkton High School",'Elkton=' + Elkton.length);
Elkton[Elkton.length] = createMarker(new GPoint(-75.82923889,39.62003708),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Elkton Middle School",'Elkton=' + Elkton.length);
Elkton[Elkton.length] = createMarker(new GPoint(-75.83297729,39.62028503),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Gilpin Manor Elementary School",'Elkton=' + Elkton.length);
Elkton[Elkton.length] = createMarker(new GPoint(-75.82213593,39.59396744),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Holly Hall Elementary School",'Elkton=' + Elkton.length);
Elkton[Elkton.length] = createMarker(new GPoint(-75.85736847,39.67201996),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Kenmore Elementary School",'Elkton=' + Elkton.length);
Elkton[Elkton.length] = createMarker(new GPoint(-75.89130402,39.64442825),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Leeds Elementary School",'Elkton=' + Elkton.length);
North_East[North_East.length] = createMarker(new GPoint(-75.93721771,39.59561157),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("North East Elementary School",'North_East=' + North_East.length);
North_East[North_East.length] = createMarker(new GPoint(-75.93325043,39.58725357),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("North East Evening High School",'North_East=' + North_East.length);
North_East[North_East.length] = createMarker(new GPoint(-75.93325043,39.58725357),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("North East High School",'North_East=' + North_East.length);
North_East[North_East.length] = createMarker(new GPoint(-75.93957520,39.60132217),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("North East Middle School",'North_East=' + North_East.length);
Perryville[Perryville.length] = createMarker(new GPoint(-76.06827545,39.56430817),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Perryville Elementary School",'Perryville=' + Perryville.length);
Perryville[Perryville.length] = createMarker(new GPoint(-76.06655884,39.58310318),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Perryville High School",'Perryville=' + Perryville.length);
Perryville[Perryville.length] = createMarker(new GPoint(-76.07015228,39.57197189),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Perryville Middle School",'Perryville=' + Perryville.length);
Elkton[Elkton.length] = createMarker(new GPoint(-75.86636353,39.69094467),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Providence School",'Elkton=' + Elkton.length);
Rising_Sun[Rising_Sun.length] = createMarker(new GPoint(-76.06478882,39.68115997),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Rising Sun Elementary School",'Rising_Sun=' + Rising_Sun.length);
North_East[North_East.length] = createMarker(new GPoint(-75.97552490,39.69239426),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Rising Sun High School",'North_East=' + North_East.length);
Rising_Sun[Rising_Sun.length] = createMarker(new GPoint(-76.07055664,39.70191193),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Rising Sun Middle School",'Rising_Sun=' + Rising_Sun.length);
Elkton[Elkton.length] = createMarker(new GPoint(-75.80119324,39.60399246),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Thomson Estates Elementary School",'Elkton=' + Elkton.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(Cecilton);
map.removeOverlays(Charlestown);
map.removeOverlays(Chesapeake_City);
map.removeOverlays(Conowingo);
map.removeOverlays(Elkton);
map.removeOverlays(North_East);
map.removeOverlays(Perryville);
map.removeOverlays(Port_Deposit);
map.removeOverlays(Rising_Sun);
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(Port_Deposit);map.removeOverlays(Cecilton);
map.removeOverlays(Charlestown);
map.removeOverlays(Chesapeake_City);
map.removeOverlays(Conowingo);
map.removeOverlays(Elkton);
map.removeOverlays(North_East);
map.removeOverlays(Perryville);
map.removeOverlays(Port_Deposit);
map.removeOverlays(Rising_Sun);
map.addOverlays(Cecilton);
centerByArray(Cecilton, false, false);
cntMarker += Cecilton.length;
map.addOverlays(Charlestown);
centerByArray(Charlestown, false, false);
cntMarker += Charlestown.length;
map.addOverlays(Chesapeake_City);
centerByArray(Chesapeake_City, false, false);
cntMarker += Chesapeake_City.length;
map.addOverlays(Conowingo);
centerByArray(Conowingo, false, false);
cntMarker += Conowingo.length;
map.addOverlays(Elkton);
centerByArray(Elkton, false, false);
cntMarker += Elkton.length;
map.addOverlays(North_East);
centerByArray(North_East, false, false);
cntMarker += North_East.length;
map.addOverlays(Perryville);
centerByArray(Perryville, false, false);
cntMarker += Perryville.length;
map.addOverlays(Port_Deposit);
centerByArray(Port_Deposit, false, false);
cntMarker += Port_Deposit.length;
map.addOverlays(Rising_Sun);
centerByArray(Rising_Sun, false, false);
cntMarker += Rising_Sun.length;
centerByArray(Port_Deposit,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');
}
}