function addMarkers()
{
mySelect = document.getElementById('selection');
Summerville = [];Ridgeville = [];Dorchester = [];Charleston = [];N_Charleston = [];Ladson = [];St_George = [];No_Charleston = [];mySelect.options[mySelect.options.length] = new Option("Charleston schools",'all=Charleston');
mySelect.options[mySelect.options.length] = new Option("Dorchester schools",'all=Dorchester');
mySelect.options[mySelect.options.length] = new Option("Ladson schools",'all=Ladson');
mySelect.options[mySelect.options.length] = new Option("N Charleston schools",'all=N_Charleston');
mySelect.options[mySelect.options.length] = new Option("No Charleston schools",'all=No_Charleston');
mySelect.options[mySelect.options.length] = new Option("Ridgeville schools",'all=Ridgeville');
mySelect.options[mySelect.options.length] = new Option("St George schools",'all=St_George');
mySelect.options[mySelect.options.length] = new Option("Summerville schools",'all=Summerville');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Summerville[Summerville.length] = createMarker(new GPoint(-80.18182373,33.03086472),"
",iconBl);
mySelect.options[mySelect.options.length] = new Option("Alston Middle School",'Summerville=' + Summerville.length);
Summerville[Summerville.length] = createMarker(new GPoint(-80.21118927,32.94966125),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Beech Hill Elementary School",'Summerville=' + Summerville.length);
Summerville[Summerville.length] = createMarker(new GPoint(-80.24609375,33.03390503),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Charles B Dubose Middle School",'Summerville=' + Summerville.length);
Ridgeville[Ridgeville.length] = createMarker(new GPoint(-80.31456100,33.09535100),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Clay Hill Middle School",'Ridgeville=' + Ridgeville.length);
Dorchester[Dorchester.length] = createMarker(new GPoint(-80.57862900,33.30856600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Dorchester Co Career School",'Dorchester=' + Dorchester.length);
Charleston[Charleston.length] = createMarker(new GPoint(-80.07140700,32.85483200),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Drayton Hall Elementary School",'Charleston=' + Charleston.length);
Summerville[Summerville.length] = createMarker(new GPoint(-80.20113373,32.99150848),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Flowertown Elementary School",'Summerville=' + Summerville.length);
N_Charleston[N_Charleston.length] = createMarker(new GPoint(-80.90660095,34.03099823),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Fort Dorchester Elementary School",'N_Charleston=' + N_Charleston.length);
N_Charleston[N_Charleston.length] = createMarker(new GPoint(-80.10205841,32.91831589),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Fort Dorchester High School",'N_Charleston=' + N_Charleston.length);
Summerville[Summerville.length] = createMarker(new GPoint(-80.21848297,32.98837662),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Gregg Middle School",'Summerville=' + Summerville.length);
Dorchester[Dorchester.length] = createMarker(new GPoint(-80.38061523,33.15709305),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Harleyville-ridgeville Elementary School",'Dorchester=' + Dorchester.length);
Summerville[Summerville.length] = createMarker(new GPoint(-80.23647308,33.00799561),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Knightsville Elementary School",'Summerville=' + Summerville.length);
Summerville[Summerville.length] = createMarker(new GPoint(-80.20150757,32.99138260),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Newington Elementary School",'Summerville=' + Summerville.length);
Ladson[Ladson.length] = createMarker(new GPoint(-80.14753723,32.95666122),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Oakbrook Elementary School",'Ladson=' + Ladson.length);
Ladson[Ladson.length] = createMarker(new GPoint(-80.14753723,32.95666122),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Oakbrook Middle School",'Ladson=' + Ladson.length);
Summerville[Summerville.length] = createMarker(new GPoint(-80.18305969,33.01037216),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Rollings Middle School Of Arts",'Summerville=' + Summerville.length);
St_George[St_George.length] = createMarker(new GPoint(-80.57715607,33.19379044),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Saint George Middle School",'St_George=' + St_George.length);
Summerville[Summerville.length] = createMarker(new GPoint(-80.18344116,33.00424576),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Spann Elementary School",'Summerville=' + Summerville.length);
Summerville[Summerville.length] = createMarker(new GPoint(-80.18341827,33.01005936),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Summerville Elementary School",'Summerville=' + Summerville.length);
Summerville[Summerville.length] = createMarker(new GPoint(-80.21910095,32.99527740),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Summerville High School",'Summerville=' + Summerville.length);
St_George[St_George.length] = createMarker(new GPoint(-80.58823395,33.18254852),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Williams Memorial Elementary School",'St_George=' + St_George.length);
No_Charleston[No_Charleston.length] = createMarker(new GPoint(-80.09968567,32.93370438),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Windsor Hill Elementary School",'No_Charleston=' + No_Charleston.length);
Dorchester[Dorchester.length] = createMarker(new GPoint(-80.49151611,33.16537476),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Woodland High School",'Dorchester=' + Dorchester.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(Charleston);
map.removeOverlays(Dorchester);
map.removeOverlays(Ladson);
map.removeOverlays(N_Charleston);
map.removeOverlays(No_Charleston);
map.removeOverlays(Ridgeville);
map.removeOverlays(St_George);
map.removeOverlays(Summerville);
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(Summerville);map.removeOverlays(Charleston);
map.removeOverlays(Dorchester);
map.removeOverlays(Ladson);
map.removeOverlays(N_Charleston);
map.removeOverlays(No_Charleston);
map.removeOverlays(Ridgeville);
map.removeOverlays(St_George);
map.removeOverlays(Summerville);
map.addOverlays(Charleston);
centerByArray(Charleston, false, false);
cntMarker += Charleston.length;
map.addOverlays(Dorchester);
centerByArray(Dorchester, false, false);
cntMarker += Dorchester.length;
map.addOverlays(Ladson);
centerByArray(Ladson, false, false);
cntMarker += Ladson.length;
map.addOverlays(N_Charleston);
centerByArray(N_Charleston, false, false);
cntMarker += N_Charleston.length;
map.addOverlays(No_Charleston);
centerByArray(No_Charleston, false, false);
cntMarker += No_Charleston.length;
map.addOverlays(Ridgeville);
centerByArray(Ridgeville, false, false);
cntMarker += Ridgeville.length;
map.addOverlays(St_George);
centerByArray(St_George, false, false);
cntMarker += St_George.length;
map.addOverlays(Summerville);
centerByArray(Summerville, false, false);
cntMarker += Summerville.length;
centerByArray(Summerville,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');
}
}