function addMarkers()
{
mySelect = document.getElementById('selection');
Wilmington = [];Carolina_Beach = [];Maumee = [];Wrightsville_Beach = [];mySelect.options[mySelect.options.length] = new Option("Carolina Beach schools",'all=Carolina_Beach');
mySelect.options[mySelect.options.length] = new Option("Maumee schools",'all=Maumee');
mySelect.options[mySelect.options.length] = new Option("Wilmington schools",'all=Wilmington');
mySelect.options[mySelect.options.length] = new Option("Wrightsville Beach schools",'all=Wrightsville_Beach');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Wilmington[Wilmington.length] = createMarker(new GPoint(-77.94049835,34.23229980),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Alternative Pathways For Suc",'Wilmington=' + Wilmington.length);
Wilmington[Wilmington.length] = createMarker(new GPoint(-77.92131042,34.23983383),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Annie H Snipes Elementary School",'Wilmington=' + Wilmington.length);
Wilmington[Wilmington.length] = createMarker(new GPoint(-77.84114075,34.19828796),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Bradley Creek Elementary School",'Wilmington=' + Wilmington.length);
Wilmington[Wilmington.length] = createMarker(new GPoint(-77.90381622,34.23089600),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Cape Fear Center For Inquiry",'Wilmington=' + Wilmington.length);
Carolina_Beach[Carolina_Beach.length] = createMarker(new GPoint(-77.89930725,34.03120804),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Carolina Beach Elementary School",'Carolina_Beach=' + Carolina_Beach.length);
Wilmington[Wilmington.length] = createMarker(new GPoint(-77.90408325,34.10403824),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Charles P Murray Middle School",'Wilmington=' + Wilmington.length);
Wilmington[Wilmington.length] = createMarker(new GPoint(-77.86466217,34.23605728),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("College Park Elementary School",'Wilmington=' + Wilmington.length);
Wilmington[Wilmington.length] = createMarker(new GPoint(-77.94068909,34.24965286),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("D C Virgo Middle School",'Wilmington=' + Wilmington.length);
Wilmington[Wilmington.length] = createMarker(new GPoint(-77.93934631,34.24874878),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Dorothy B Johnson Elementary School",'Wilmington=' + Wilmington.length);
Wilmington[Wilmington.length] = createMarker(new GPoint(-77.83444214,34.26513290),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Dr Hubert Eaton Senior Elementary School",'Wilmington=' + Wilmington.length);
Wilmington[Wilmington.length] = createMarker(new GPoint(-77.91487122,34.16241837),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Dr John Codington Elementary School",'Wilmington=' + Wilmington.length);
Wilmington[Wilmington.length] = createMarker(new GPoint(-77.90844727,34.20680618),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Edwin A Alderman Elementary School",'Wilmington=' + Wilmington.length);
Wilmington[Wilmington.length] = createMarker(new GPoint(-77.87774658,34.30676651),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Emma B Trask Middle School",'Wilmington=' + Wilmington.length);
Wilmington[Wilmington.length] = createMarker(new GPoint(-77.87559509,34.30057526),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Emsley A Laney High School",'Wilmington=' + Wilmington.length);
Wilmington[Wilmington.length] = createMarker(new GPoint(-77.90515137,34.10403824),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Eugene Ashley High School",'Wilmington=' + Wilmington.length);
Wilmington[Wilmington.length] = createMarker(new GPoint(-77.91296387,34.22998047),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Forest Hills Elementary School",'Wilmington=' + Wilmington.length);
Wilmington[Wilmington.length] = createMarker(new GPoint(-77.93608856,34.23225403),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Gregory Elementary School",'Wilmington=' + Wilmington.length);
Wilmington[Wilmington.length] = createMarker(new GPoint(-77.91139221,34.12428665),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Heyward C Bellamy Elementary School",'Wilmington=' + Wilmington.length);
Wilmington[Wilmington.length] = createMarker(new GPoint(-77.88316345,34.19382095),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Holly Tree Elementary School",'Wilmington=' + Wilmington.length);
Wilmington[Wilmington.length] = createMarker(new GPoint(-77.84148407,34.25627518),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("John J Blair Elementary School",'Wilmington=' + Wilmington.length);
Wilmington[Wilmington.length] = createMarker(new GPoint(-77.89158630,34.19919968),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("John T Hoggard High School",'Wilmington=' + Wilmington.length);
Wilmington[Wilmington.length] = createMarker(new GPoint(-77.93117523,34.21360397),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Lakeside",'Wilmington=' + Wilmington.length);
Wilmington[Wilmington.length] = createMarker(new GPoint(-77.84139252,34.25631332),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("M C S Noble Middle School",'Wilmington=' + Wilmington.length);
Wilmington[Wilmington.length] = createMarker(new GPoint(-77.91497803,34.13995361),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Mary C Williams Elementary School",'Wilmington=' + Wilmington.length);
Wilmington[Wilmington.length] = createMarker(new GPoint(-10.00000000,10.00000000),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Murrayville Elementary School",'Wilmington=' + Wilmington.length);
Wilmington[Wilmington.length] = createMarker(new GPoint(-77.88459778,34.13613129),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Myrtle Grove Middle School",'Wilmington=' + Wilmington.length);
Wilmington[Wilmington.length] = createMarker(new GPoint(-77.93259430,34.23685837),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("New Hanover High School",'Wilmington=' + Wilmington.length);
Wilmington[Wilmington.length] = createMarker(new GPoint(-77.80784607,34.26597977),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Ogden Elementary School",'Wilmington=' + Wilmington.length);
Wilmington[Wilmington.length] = createMarker(new GPoint(-77.90085602,34.17974472),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Pine Valley Elementary School",'Wilmington=' + Wilmington.length);
Wilmington[Wilmington.length] = createMarker(new GPoint(-77.91402435,34.24384689),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Rachel Freeman Elementary School",'Wilmington=' + Wilmington.length);
Wilmington[Wilmington.length] = createMarker(new GPoint(-77.89178467,34.20701981),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Roland-grise Middle School",'Wilmington=' + Wilmington.length);
Wilmington[Wilmington.length] = createMarker(new GPoint(-77.94158936,34.20731735),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Sunset Park Elementary School",'Wilmington=' + Wilmington.length);
Wilmington[Wilmington.length] = createMarker(new GPoint(-77.86186981,34.17784500),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Walter L Parsley Elementary School",'Wilmington=' + Wilmington.length);
Wilmington[Wilmington.length] = createMarker(new GPoint(-77.86199951,34.25770187),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("William H Blount Elementary School",'Wilmington=' + Wilmington.length);
Maumee[Maumee.length] = createMarker(new GPoint(-83.68671417,41.58881760),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("William H Blount Elementary School",'Maumee=' + Maumee.length);
Wilmington[Wilmington.length] = createMarker(new GPoint(-77.93595886,34.23128510),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Williston Middle School",'Wilmington=' + Wilmington.length);
Wilmington[Wilmington.length] = createMarker(new GPoint(-77.88192749,34.21234131),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Winter Park Model Elementary School",'Wilmington=' + Wilmington.length);
Wilmington[Wilmington.length] = createMarker(new GPoint(-77.92102814,34.29278183),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Wrightsboro Elementary School",'Wilmington=' + Wilmington.length);
Wrightsville_Beach[Wrightsville_Beach.length] = createMarker(new GPoint(-77.79851532,34.21234894),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Wrightsville Beach Elementary School",'Wrightsville_Beach=' + Wrightsville_Beach.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(Carolina_Beach);
map.removeOverlays(Maumee);
map.removeOverlays(Wilmington);
map.removeOverlays(Wrightsville_Beach);
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(Wilmington);map.removeOverlays(Carolina_Beach);
map.removeOverlays(Maumee);
map.removeOverlays(Wilmington);
map.removeOverlays(Wrightsville_Beach);
map.addOverlays(Carolina_Beach);
centerByArray(Carolina_Beach, false, false);
cntMarker += Carolina_Beach.length;
map.addOverlays(Maumee);
centerByArray(Maumee, false, false);
cntMarker += Maumee.length;
map.addOverlays(Wilmington);
centerByArray(Wilmington, false, false);
cntMarker += Wilmington.length;
map.addOverlays(Wrightsville_Beach);
centerByArray(Wrightsville_Beach, false, false);
cntMarker += Wrightsville_Beach.length;
centerByArray(Wilmington,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');
}
}