function addMarkers(){
mySelect = document.getElementById('selection');
Aiken = [];Charleston = [];Beaufort = [];Columbia = [];Greenwood = [];Camden = [];Greenville = [];Mount_Pleasant = [];Hilton_Head_Island = [];Easley = [];Pawleys_Island = [];Graniteville = [];Estill = [];Gilbert = [];Summerville = [];Bishopville = [];Sumter = [];Dalzell = [];Darlington = [];Union = [];mySelect.options[mySelect.options.length] = new Option("Aiken schools",'all=Aiken');
mySelect.options[mySelect.options.length] = new Option("Beaufort schools",'all=Beaufort');
mySelect.options[mySelect.options.length] = new Option("Bishopville schools",'all=Bishopville');
mySelect.options[mySelect.options.length] = new Option("Camden schools",'all=Camden');
mySelect.options[mySelect.options.length] = new Option("Charleston schools",'all=Charleston');
mySelect.options[mySelect.options.length] = new Option("Columbia schools",'all=Columbia');
mySelect.options[mySelect.options.length] = new Option("Dalzell schools",'all=Dalzell');
mySelect.options[mySelect.options.length] = new Option("Darlington schools",'all=Darlington');
mySelect.options[mySelect.options.length] = new Option("Easley schools",'all=Easley');
mySelect.options[mySelect.options.length] = new Option("Estill schools",'all=Estill');
mySelect.options[mySelect.options.length] = new Option("Gilbert schools",'all=Gilbert');
mySelect.options[mySelect.options.length] = new Option("Graniteville schools",'all=Graniteville');
mySelect.options[mySelect.options.length] = new Option("Greenville schools",'all=Greenville');
mySelect.options[mySelect.options.length] = new Option("Greenwood schools",'all=Greenwood');
mySelect.options[mySelect.options.length] = new Option("Hilton Head Island schools",'all=Hilton_Head_Island');
mySelect.options[mySelect.options.length] = new Option("Mount Pleasant schools",'all=Mount_Pleasant');
mySelect.options[mySelect.options.length] = new Option("Pawleys Island schools",'all=Pawleys_Island');
mySelect.options[mySelect.options.length] = new Option("Summerville schools",'all=Summerville');
mySelect.options[mySelect.options.length] = new Option("Sumter schools",'all=Sumter');
mySelect.options[mySelect.options.length] = new Option("Union schools",'all=Union');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Aiken[Aiken.length] = createMarker(new GPoint(-81.72637700,33.56487300),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Aiken Preparatory School",'Aiken=' + Aiken.length);
Charleston[Charleston.length] = createMarker(new GPoint(-79.94563500,32.78688200),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Ashley Hall",'Charleston=' + Charleston.length);
Beaufort[Beaufort.length] = createMarker(new GPoint(-80.64030500,32.43442900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Beaufort Academy Inc.",'Beaufort=' + Beaufort.length);
Columbia[Columbia.length] = createMarker(new GPoint(-81.06959100,34.08122800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Ben Lippen School",'Columbia=' + Columbia.length);
Greenwood[Greenwood.length] = createMarker(new GPoint(-82.19823000,34.21349400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Cambridge Academy",'Greenwood=' + Greenwood.length);
Camden[Camden.length] = createMarker(new GPoint(-80.55939600,34.28057800),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Camden Military Academy",'Camden=' + Camden.length);
Charleston[Charleston.length] = createMarker(new GPoint(-79.93480600,32.77855500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Charleston Day School",'Charleston=' + Charleston.length);
Greenville[Greenville.length] = createMarker(new GPoint(-82.34853300,34.79860300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Christ Church Episcopal School",'Greenville=' + Greenville.length);
Mount_Pleasant[Mount_Pleasant.length] = createMarker(new GPoint(-79.86394500,32.78735100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Coastal Christian Preparatory School",'Mount_Pleasant=' + Mount_Pleasant.length);
Greenville[Greenville.length] = createMarker(new GPoint(-82.40079300,34.85141200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("First Presbyterian Academy",'Greenville=' + Greenville.length);
Columbia[Columbia.length] = createMarker(new GPoint(-81.01358400,33.95079100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Heathwood Hall Episcopal School",'Columbia=' + Columbia.length);
Hilton_Head_Island[Hilton_Head_Island.length] = createMarker(new GPoint(-80.77623300,32.13608300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Hilton Head Preparatory School",'Hilton_Head_Island=' + Hilton_Head_Island.length);
Easley[Easley.length] = createMarker(new GPoint(-82.66241300,34.84366000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Landmark Christian Academy",'Easley=' + Easley.length);
Pawleys_Island[Pawleys_Island.length] = createMarker(new GPoint(-79.13892700,33.43572300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Lowcountry Preparatory School",'Pawleys_Island=' + Pawleys_Island.length);
Graniteville[Graniteville.length] = createMarker(new GPoint(-81.80339200,33.55664400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Minnie Palmore House Learning Center",'Graniteville=' + Graniteville.length);
Mount_Pleasant[Mount_Pleasant.length] = createMarker(new GPoint(-79.85486700,32.84761000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Palmetto Christian Academy",'Mount_Pleasant=' + Mount_Pleasant.length);
Estill[Estill.length] = createMarker(new GPoint(-81.18245100,32.75643200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Patrick Henry Academy",'Estill=' + Estill.length);
Gilbert[Gilbert.length] = createMarker(new GPoint(-81.40116200,34.02278900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Pineview Christian Academy",'Gilbert=' + Gilbert.length);
Summerville[Summerville.length] = createMarker(new GPoint(-80.24245700,33.02452800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Pinewood Preparatory School",'Summerville=' + Summerville.length);
Charleston[Charleston.length] = createMarker(new GPoint(-79.96685400,32.77559700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Porter-gaud School",'Charleston=' + Charleston.length);
Bishopville[Bishopville.length] = createMarker(new GPoint(-80.26770000,34.21320000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Robert E Lee Academy",'Bishopville=' + Bishopville.length);
Sumter[Sumter.length] = createMarker(new GPoint(-80.35820500,33.91869300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Francis Xavier High School",'Sumter=' + Sumter.length);
Columbia[Columbia.length] = createMarker(new GPoint(-80.91937200,33.96535600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Sandhills School",'Columbia=' + Columbia.length);
Dalzell[Dalzell.length] = createMarker(new GPoint(-80.46030000,34.01900000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Thomas Sumter Academy",'Dalzell=' + Dalzell.length);
Mount_Pleasant[Mount_Pleasant.length] = createMarker(new GPoint(-79.85493300,32.82962800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Trident Academy",'Mount_Pleasant=' + Mount_Pleasant.length);
Darlington[Darlington.length] = createMarker(new GPoint(-79.93326100,34.23672500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Trinity Collegiate School",'Darlington=' + Darlington.length);
Union[Union.length] = createMarker(new GPoint(-81.64944000,34.73299200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Union Christian Day School",'Union=' + Union.length);
Sumter[Sumter.length] = createMarker(new GPoint(-80.40408800,33.93525900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Wilson Hall",'Sumter=' + Sumter.length);
map.removeOverlays(Aiken);
map.removeOverlays(Beaufort);
map.removeOverlays(Bishopville);
map.removeOverlays(Camden);
map.removeOverlays(Charleston);
map.removeOverlays(Columbia);
map.removeOverlays(Dalzell);
map.removeOverlays(Darlington);
map.removeOverlays(Easley);
map.removeOverlays(Estill);
map.removeOverlays(Gilbert);
map.removeOverlays(Graniteville);
map.removeOverlays(Greenville);
map.removeOverlays(Greenwood);
map.removeOverlays(Hilton_Head_Island);
map.removeOverlays(Mount_Pleasant);
map.removeOverlays(Pawleys_Island);
map.removeOverlays(Summerville);
map.removeOverlays(Sumter);
map.removeOverlays(Union);
setTimeout(function(){map.addOverlays(Aiken)},1000);
setTimeout(function(){map.addOverlays(Beaufort)},1000);
setTimeout(function(){map.addOverlays(Bishopville)},1000);
setTimeout(function(){map.addOverlays(Camden)},1000);
setTimeout(function(){map.addOverlays(Charleston)},1000);
setTimeout(function(){map.addOverlays(Columbia)},1000);
setTimeout(function(){map.addOverlays(Dalzell)},1000);
setTimeout(function(){map.addOverlays(Darlington)},1000);
setTimeout(function(){map.addOverlays(Easley)},1000);
setTimeout(function(){map.addOverlays(Estill)},1000);
setTimeout(function(){map.addOverlays(Gilbert)},1000);
setTimeout(function(){map.addOverlays(Graniteville)},1000);
setTimeout(function(){map.addOverlays(Greenville)},1000);
setTimeout(function(){map.addOverlays(Greenwood)},1000);
setTimeout(function(){map.addOverlays(Hilton_Head_Island)},1000);
setTimeout(function(){map.addOverlays(Mount_Pleasant)},1000);
setTimeout(function(){map.addOverlays(Pawleys_Island)},1000);
setTimeout(function(){map.addOverlays(Summerville)},1000);
setTimeout(function(){map.addOverlays(Sumter)},1000);
setTimeout(function(){map.addOverlays(Union)},1000);
maxLng = -79.13892700;
maxLat = 34.85141200;
minLng = -82.66241300;
minLat = 32.13608300;
reCenterMap();
} // 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,11);
/*
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(Aiken);
map.removeOverlays(Beaufort);
map.removeOverlays(Bishopville);
map.removeOverlays(Camden);
map.removeOverlays(Charleston);
map.removeOverlays(Columbia);
map.removeOverlays(Dalzell);
map.removeOverlays(Darlington);
map.removeOverlays(Easley);
map.removeOverlays(Estill);
map.removeOverlays(Gilbert);
map.removeOverlays(Graniteville);
map.removeOverlays(Greenville);
map.removeOverlays(Greenwood);
map.removeOverlays(Hilton_Head_Island);
map.removeOverlays(Mount_Pleasant);
map.removeOverlays(Pawleys_Island);
map.removeOverlays(Summerville);
map.removeOverlays(Sumter);
map.removeOverlays(Union);
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(Aiken);map.removeOverlays(Aiken);
map.removeOverlays(Beaufort);
map.removeOverlays(Bishopville);
map.removeOverlays(Camden);
map.removeOverlays(Charleston);
map.removeOverlays(Columbia);
map.removeOverlays(Dalzell);
map.removeOverlays(Darlington);
map.removeOverlays(Easley);
map.removeOverlays(Estill);
map.removeOverlays(Gilbert);
map.removeOverlays(Graniteville);
map.removeOverlays(Greenville);
map.removeOverlays(Greenwood);
map.removeOverlays(Hilton_Head_Island);
map.removeOverlays(Mount_Pleasant);
map.removeOverlays(Pawleys_Island);
map.removeOverlays(Summerville);
map.removeOverlays(Sumter);
map.removeOverlays(Union);
map.addOverlays(Aiken);
centerByArray(Aiken, false, false);
cntMarker += Aiken.length;
map.addOverlays(Beaufort);
centerByArray(Beaufort, false, false);
cntMarker += Beaufort.length;
map.addOverlays(Bishopville);
centerByArray(Bishopville, false, false);
cntMarker += Bishopville.length;
map.addOverlays(Camden);
centerByArray(Camden, false, false);
cntMarker += Camden.length;
map.addOverlays(Charleston);
centerByArray(Charleston, false, false);
cntMarker += Charleston.length;
map.addOverlays(Columbia);
centerByArray(Columbia, false, false);
cntMarker += Columbia.length;
map.addOverlays(Dalzell);
centerByArray(Dalzell, false, false);
cntMarker += Dalzell.length;
map.addOverlays(Darlington);
centerByArray(Darlington, false, false);
cntMarker += Darlington.length;
map.addOverlays(Easley);
centerByArray(Easley, false, false);
cntMarker += Easley.length;
map.addOverlays(Estill);
centerByArray(Estill, false, false);
cntMarker += Estill.length;
map.addOverlays(Gilbert);
centerByArray(Gilbert, false, false);
cntMarker += Gilbert.length;
map.addOverlays(Graniteville);
centerByArray(Graniteville, false, false);
cntMarker += Graniteville.length;
map.addOverlays(Greenville);
centerByArray(Greenville, false, false);
cntMarker += Greenville.length;
map.addOverlays(Greenwood);
centerByArray(Greenwood, false, false);
cntMarker += Greenwood.length;
map.addOverlays(Hilton_Head_Island);
centerByArray(Hilton_Head_Island, false, false);
cntMarker += Hilton_Head_Island.length;
map.addOverlays(Mount_Pleasant);
centerByArray(Mount_Pleasant, false, false);
cntMarker += Mount_Pleasant.length;
map.addOverlays(Pawleys_Island);
centerByArray(Pawleys_Island, false, false);
cntMarker += Pawleys_Island.length;
map.addOverlays(Summerville);
centerByArray(Summerville, false, false);
cntMarker += Summerville.length;
map.addOverlays(Sumter);
centerByArray(Sumter, false, false);
cntMarker += Sumter.length;
map.addOverlays(Union);
centerByArray(Union, false, false);
cntMarker += Union.length;
centerByArray(Aiken,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///25447,25461,25705,25494,25455,25697,25466,25599,25779,25788,25621,25686,25692,25512,25605,25566,25684,25781,25630,25693,25741,25814,25790,25447,25461,25705,25455,25507,25697,25466,25599,25710,25779,25621,25686,25692,25637,25512,25569,25492,25605,25566,25684,25781,25630,25693,25814,25790,/all');
//window.open('/map.php?type=2&schools=25447,25461,25705,25494,25455,25697,25466,25599,25779,25788,25621,25686,25692,25512,25605,25566,25684,25781,25630,25693,25741,25814,25790,25447,25461,25705,25455,25507,25697,25466,25599,25710,25779,25621,25686,25692,25637,25512,25569,25492,25605,25566,25684,25781,25630,25693,25814,25790,&school_level=&radius=&zipcode=&school_type_search=&school_type_code=');
}
}
function createMarker(point, label, icon)
{
var marker = new GMarker(point, icon);
var html = label;
GEvent.addListener(marker, "click", function() {
marker.openInfoWindowHtml(html);
});
return marker;
}