function addMarkers()
{
mySelect = document.getElementById('selection');
Turbeville = [];Manning = [];_West_Manning = [];Alcolu = [];Summerton = [];New_Zion = [];mySelect.options[mySelect.options.length] = new Option("Alcolu schools",'all=Alcolu');
mySelect.options[mySelect.options.length] = new Option("Manning schools",'all=Manning');
mySelect.options[mySelect.options.length] = new Option("New Zion schools",'all=New_Zion');
mySelect.options[mySelect.options.length] = new Option("Summerton schools",'all=Summerton');
mySelect.options[mySelect.options.length] = new Option("Turbeville schools",'all=Turbeville');
mySelect.options[mySelect.options.length] = new Option(" West Manning schools",'all=_West_Manning');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Turbeville[Turbeville.length] = createMarker(new GPoint(-79.99770355,33.88370132),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("East Clarendon High School",'Turbeville=' + Turbeville.length);
Turbeville[Turbeville.length] = createMarker(new GPoint(-79.99770355,33.88370132),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("East Clarendon Middle School",'Turbeville=' + Turbeville.length);
Manning[Manning.length] = createMarker(new GPoint(-10.00000000,10.00000000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("F E Dubose Voc Center",'Manning=' + Manning.length);
Manning[Manning.length] = createMarker(new GPoint(-80.24109650,33.70235825),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Manning Early Childhood Center",'Manning=' + Manning.length);
_West_Manning[_West_Manning.length] = createMarker(new GPoint(-80.30660248,33.72299957),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Manning Elementary School",'_West_Manning=' + _West_Manning.length);
Manning[Manning.length] = createMarker(new GPoint(-80.21070862,33.69517136),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Manning High School",'Manning=' + Manning.length);
Manning[Manning.length] = createMarker(new GPoint(-80.21914673,33.69615555),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Manning Junior High School",'Manning=' + Manning.length);
Manning[Manning.length] = createMarker(new GPoint(-80.21366119,33.69796753),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Manning Primary School",'Manning=' + Manning.length);
Alcolu[Alcolu.length] = createMarker(new GPoint(-80.21408844,33.75162125),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Phoenix Center",'Alcolu=' + Alcolu.length);
Summerton[Summerton.length] = createMarker(new GPoint(-80.38289642,33.48270035),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Saint Paul Primary",'Summerton=' + Summerton.length);
Summerton[Summerton.length] = createMarker(new GPoint(-101.88980700,35.10200300),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Scott's Branch Middle School",'Summerton=' + Summerton.length);
Summerton[Summerton.length] = createMarker(new GPoint(-80.37300110,33.48189926),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Scotts Branch High School",'Summerton=' + Summerton.length);
Turbeville[Turbeville.length] = createMarker(new GPoint(-79.99770355,33.88370132),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Turbeville Correctional Institution High School",'Turbeville=' + Turbeville.length);
New_Zion[New_Zion.length] = createMarker(new GPoint(-80.01779938,33.80849838),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Walker Gamble Elementary School",'New_Zion=' + New_Zion.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(Alcolu);
map.removeOverlays(Manning);
map.removeOverlays(New_Zion);
map.removeOverlays(Summerton);
map.removeOverlays(Turbeville);
map.removeOverlays(_West_Manning);
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(Turbeville);map.removeOverlays(Alcolu);
map.removeOverlays(Manning);
map.removeOverlays(New_Zion);
map.removeOverlays(Summerton);
map.removeOverlays(Turbeville);
map.removeOverlays(_West_Manning);
map.addOverlays(Alcolu);
centerByArray(Alcolu, false, false);
cntMarker += Alcolu.length;
map.addOverlays(Manning);
centerByArray(Manning, false, false);
cntMarker += Manning.length;
map.addOverlays(New_Zion);
centerByArray(New_Zion, false, false);
cntMarker += New_Zion.length;
map.addOverlays(Summerton);
centerByArray(Summerton, false, false);
cntMarker += Summerton.length;
map.addOverlays(Turbeville);
centerByArray(Turbeville, false, false);
cntMarker += Turbeville.length;
map.addOverlays(_West_Manning);
centerByArray(_West_Manning, false, false);
cntMarker += _West_Manning.length;
centerByArray(Turbeville,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');
}
}