function addMarkers()
{
mySelect = document.getElementById('selection');
Punta_Gorda = [];Port_Charlotte = [];Rotonda_West = [];Englewood = [];Charlotte_Harbor = [];mySelect.options[mySelect.options.length] = new Option("Charlotte Harbor schools",'all=Charlotte_Harbor');
mySelect.options[mySelect.options.length] = new Option("Englewood schools",'all=Englewood');
mySelect.options[mySelect.options.length] = new Option("Port Charlotte schools",'all=Port_Charlotte');
mySelect.options[mySelect.options.length] = new Option("Punta Gorda schools",'all=Punta_Gorda');
mySelect.options[mySelect.options.length] = new Option("Rotonda West schools",'all=Rotonda_West');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Punta_Gorda[Punta_Gorda.length] = createMarker(new GPoint(-82.04455566,26.93441391),"
",iconRd);
mySelect.options[mySelect.options.length] = new Option("Baker/head Start Elementary School",'Punta_Gorda=' + Punta_Gorda.length);
Port_Charlotte[Port_Charlotte.length] = createMarker(new GPoint(-82.14864900,26.98467500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Charlotte County Superintendent's Office",'Port_Charlotte=' + Port_Charlotte.length);
Port_Charlotte[Port_Charlotte.length] = createMarker(new GPoint(-82.07427216,26.96837997),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Charlotte Harbor School",'Port_Charlotte=' + Port_Charlotte.length);
Punta_Gorda[Punta_Gorda.length] = createMarker(new GPoint(-82.03954315,26.92898369),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Charlotte High School",'Punta_Gorda=' + Punta_Gorda.length);
Port_Charlotte[Port_Charlotte.length] = createMarker(new GPoint(-82.14686584,27.00354958),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Charlotte Technical Center",'Port_Charlotte=' + Port_Charlotte.length);
Punta_Gorda[Punta_Gorda.length] = createMarker(new GPoint(-81.69380951,26.94538879),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Crossenioroads Wilderness Institute",'Punta_Gorda=' + Punta_Gorda.length);
Punta_Gorda[Punta_Gorda.length] = createMarker(new GPoint(-82.01510620,26.98483658),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Deep Creek Elementary School",'Punta_Gorda=' + Punta_Gorda.length);
Punta_Gorda[Punta_Gorda.length] = createMarker(new GPoint(-82.02579498,26.90735626),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Eagle Vision",'Punta_Gorda=' + Punta_Gorda.length);
Punta_Gorda[Punta_Gorda.length] = createMarker(new GPoint(-82.00353241,26.94000435),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("East Elementary School",'Punta_Gorda=' + Punta_Gorda.length);
Punta_Gorda[Punta_Gorda.length] = createMarker(new GPoint(-82.02579498,26.90735626),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Kelly Hall High School",'Punta_Gorda=' + Punta_Gorda.length);
Port_Charlotte[Port_Charlotte.length] = createMarker(new GPoint(-82.06665802,27.01017761),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Kingsway Elementary School",'Port_Charlotte=' + Port_Charlotte.length);
Rotonda_West[Rotonda_West.length] = createMarker(new GPoint(-82.28977966,26.91279411),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("L. A. Ainger Middle School",'Rotonda_West=' + Rotonda_West.length);
Englewood[Englewood.length] = createMarker(new GPoint(-82.33572388,26.92815208),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Lemon Bay High School",'Englewood=' + Englewood.length);
Port_Charlotte[Port_Charlotte.length] = createMarker(new GPoint(-82.11318207,27.02175713),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Liberty Elementary School",'Port_Charlotte=' + Port_Charlotte.length);
Port_Charlotte[Port_Charlotte.length] = createMarker(new GPoint(-82.12335205,26.98516464),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Meadow Park Elementary School",'Port_Charlotte=' + Port_Charlotte.length);
Port_Charlotte[Port_Charlotte.length] = createMarker(new GPoint(-82.14461800,27.00642600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Migrant Non-enrolled Students",'Port_Charlotte=' + Port_Charlotte.length);
Port_Charlotte[Port_Charlotte.length] = createMarker(new GPoint(-82.16195679,27.00326347),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Murdock Middle School",'Port_Charlotte=' + Port_Charlotte.length);
Port_Charlotte[Port_Charlotte.length] = createMarker(new GPoint(-82.24237823,26.94325638),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Myakka River Elementary School",'Port_Charlotte=' + Port_Charlotte.length);
Port_Charlotte[Port_Charlotte.length] = createMarker(new GPoint(-82.08743286,27.00274467),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Neil Armstrong Elementary School",'Port_Charlotte=' + Port_Charlotte.length);
Port_Charlotte[Port_Charlotte.length] = createMarker(new GPoint(-82.17256800,26.99613700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("New Challenge School Of Charlotte County",'Port_Charlotte=' + Port_Charlotte.length);
Charlotte_Harbor[Charlotte_Harbor.length] = createMarker(new GPoint(-82.07672119,26.96832466),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Peace River Elementary School",'Charlotte_Harbor=' + Charlotte_Harbor.length);
Port_Charlotte[Port_Charlotte.length] = createMarker(new GPoint(-82.15188599,27.00334358),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Port Charlotte High School",'Port_Charlotte=' + Port_Charlotte.length);
Port_Charlotte[Port_Charlotte.length] = createMarker(new GPoint(-82.07741547,26.99946213),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Port Charlotte Middle School",'Port_Charlotte=' + Port_Charlotte.length);
Punta_Gorda[Punta_Gorda.length] = createMarker(new GPoint(-82.03799438,26.92984390),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Punta Gorda Middle School",'Punta_Gorda=' + Punta_Gorda.length);
Punta_Gorda[Punta_Gorda.length] = createMarker(new GPoint(-82.03954315,26.92927361),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Sallie Jones Elementary School",'Punta_Gorda=' + Punta_Gorda.length);
Rotonda_West[Rotonda_West.length] = createMarker(new GPoint(-82.28273010,26.91128731),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Vineland Elementary School",'Rotonda_West=' + Rotonda_West.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(Charlotte_Harbor);
map.removeOverlays(Englewood);
map.removeOverlays(Port_Charlotte);
map.removeOverlays(Punta_Gorda);
map.removeOverlays(Rotonda_West);
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(Punta_Gorda);map.removeOverlays(Charlotte_Harbor);
map.removeOverlays(Englewood);
map.removeOverlays(Port_Charlotte);
map.removeOverlays(Punta_Gorda);
map.removeOverlays(Rotonda_West);
map.addOverlays(Charlotte_Harbor);
centerByArray(Charlotte_Harbor, false, false);
cntMarker += Charlotte_Harbor.length;
map.addOverlays(Englewood);
centerByArray(Englewood, false, false);
cntMarker += Englewood.length;
map.addOverlays(Port_Charlotte);
centerByArray(Port_Charlotte, false, false);
cntMarker += Port_Charlotte.length;
map.addOverlays(Punta_Gorda);
centerByArray(Punta_Gorda, false, false);
cntMarker += Punta_Gorda.length;
map.addOverlays(Rotonda_West);
centerByArray(Rotonda_West, false, false);
cntMarker += Rotonda_West.length;
centerByArray(Punta_Gorda,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');
}
}