function addMarkers(){
mySelect = document.getElementById('selection');
Charleston = [];Clemson = [];Columbia = [];Beaufort = [];Simpsonville = [];Easley = [];Bluffton = [];Spartanburg = [];Greenville = [];Mount_Pleasant = [];Anderson = [];Camden = [];Florence = [];Mauldin = [];Ridgeway = [];Pawleys_Island = [];Hilton_Head_Island = [];N_Augusta = [];Greenwood = [];mySelect.options[mySelect.options.length] = new Option("Anderson schools",'all=Anderson');
mySelect.options[mySelect.options.length] = new Option("Beaufort schools",'all=Beaufort');
mySelect.options[mySelect.options.length] = new Option("Bluffton schools",'all=Bluffton');
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("Clemson schools",'all=Clemson');
mySelect.options[mySelect.options.length] = new Option("Columbia schools",'all=Columbia');
mySelect.options[mySelect.options.length] = new Option("Easley schools",'all=Easley');
mySelect.options[mySelect.options.length] = new Option("Florence schools",'all=Florence');
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("Mauldin schools",'all=Mauldin');
mySelect.options[mySelect.options.length] = new Option("Mount Pleasant schools",'all=Mount_Pleasant');
mySelect.options[mySelect.options.length] = new Option("N Augusta schools",'all=N_Augusta');
mySelect.options[mySelect.options.length] = new Option("Pawleys Island schools",'all=Pawleys_Island');
mySelect.options[mySelect.options.length] = new Option("Ridgeway schools",'all=Ridgeway');
mySelect.options[mySelect.options.length] = new Option("Simpsonville schools",'all=Simpsonville');
mySelect.options[mySelect.options.length] = new Option("Spartanburg schools",'all=Spartanburg');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Charleston[Charleston.length] = createMarker(new GPoint(-80.00475600,32.78408500),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Charles Towne Montessori School",'Charleston=' + Charleston.length);
Clemson[Clemson.length] = createMarker(new GPoint(-82.81203500,34.67360100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Clemson Montessori School",'Clemson=' + Clemson.length);
Columbia[Columbia.length] = createMarker(new GPoint(-81.00460400,34.00631800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Columbia Montessori Children's House",'Columbia=' + Columbia.length);
Beaufort[Beaufort.length] = createMarker(new GPoint(-80.67280000,32.43350000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Ec Montessori And Grade School",'Beaufort=' + Beaufort.length);
Simpsonville[Simpsonville.length] = createMarker(new GPoint(-82.23629400,34.76125500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Five Oaks Academy",'Simpsonville=' + Simpsonville.length);
Easley[Easley.length] = createMarker(new GPoint(-82.51557600,34.81189200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Foothills Montessori School",'Easley=' + Easley.length);
Bluffton[Bluffton.length] = createMarker(new GPoint(-80.86269400,32.23413300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("May River Montessori School",'Bluffton=' + Bluffton.length);
Spartanburg[Spartanburg.length] = createMarker(new GPoint(-81.93032600,34.94160600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Montessori Academy",'Spartanburg=' + Spartanburg.length);
Columbia[Columbia.length] = createMarker(new GPoint(-80.89124600,34.08919400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Montessori College of Early Learning",'Columbia=' + Columbia.length);
Columbia[Columbia.length] = createMarker(new GPoint(-81.08004200,34.02776400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Montessori Early Learning Center",'Columbia=' + Columbia.length);
Greenville[Greenville.length] = createMarker(new GPoint(-82.40189500,34.85844100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Montessori Education Center",'Greenville=' + Greenville.length);
Columbia[Columbia.length] = createMarker(new GPoint(-81.07894800,34.02809400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Montessori Elementary School Of St Andr",'Columbia=' + Columbia.length);
Mount_Pleasant[Mount_Pleasant.length] = createMarker(new GPoint(-79.87692100,32.78923700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Montessori Of Mt Pleasant",'Mount_Pleasant=' + Mount_Pleasant.length);
Anderson[Anderson.length] = createMarker(new GPoint(-82.63981500,34.56260600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Montessori School Of Anderson",'Anderson=' + Anderson.length);
Camden[Camden.length] = createMarker(new GPoint(-80.63128400,34.25162100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Montessori School Of Camden",'Camden=' + Camden.length);
Columbia[Columbia.length] = createMarker(new GPoint(-81.00520600,33.98577800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Montessori School Of Columbia",'Columbia=' + Columbia.length);
Florence[Florence.length] = createMarker(new GPoint(-79.77493500,34.19323200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Montessori School Of Florence",'Florence=' + Florence.length);
Greenville[Greenville.length] = createMarker(new GPoint(-82.34084100,34.86250600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Montessori School Of Greenville",'Greenville=' + Greenville.length);
Mauldin[Mauldin.length] = createMarker(new GPoint(-82.30326900,34.77779400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Montessori School Of Mauld",'Mauldin=' + Mauldin.length);
Mauldin[Mauldin.length] = createMarker(new GPoint(-82.30350000,34.77690000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Montessori School of Mauldin,Inc.",'Mauldin=' + Mauldin.length);
Spartanburg[Spartanburg.length] = createMarker(new GPoint(-82.01504600,34.93655600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Montessori West Christian School",'Spartanburg=' + Spartanburg.length);
Ridgeway[Ridgeway.length] = createMarker(new GPoint(-81.00497600,34.29092500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Palmetto Montessori",'Ridgeway=' + Ridgeway.length);
Pawleys_Island[Pawleys_Island.length] = createMarker(new GPoint(-79.12183400,33.44868000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Pawleys Island Montessori Day School",'Pawleys_Island=' + Pawleys_Island.length);
Hilton_Head_Island[Hilton_Head_Island.length] = createMarker(new GPoint(-80.77585700,32.13587800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Sea Pines Montessori Academy",'Hilton_Head_Island=' + Hilton_Head_Island.length);
N_Augusta[N_Augusta.length] = createMarker(new GPoint(-81.97615200,33.53441400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Walden Hall/solomon's Christia",'N_Augusta=' + N_Augusta.length);
Greenwood[Greenwood.length] = createMarker(new GPoint(-82.15383600,34.18127800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Zion Temple Sda School",'Greenwood=' + Greenwood.length);
map.removeOverlays(Anderson);
map.removeOverlays(Beaufort);
map.removeOverlays(Bluffton);
map.removeOverlays(Camden);
map.removeOverlays(Charleston);
map.removeOverlays(Clemson);
map.removeOverlays(Columbia);
map.removeOverlays(Easley);
map.removeOverlays(Florence);
map.removeOverlays(Greenville);
map.removeOverlays(Greenwood);
map.removeOverlays(Hilton_Head_Island);
map.removeOverlays(Mauldin);
map.removeOverlays(Mount_Pleasant);
map.removeOverlays(N_Augusta);
map.removeOverlays(Pawleys_Island);
map.removeOverlays(Ridgeway);
map.removeOverlays(Simpsonville);
map.removeOverlays(Spartanburg);
setTimeout(function(){map.addOverlays(Anderson)},1000);
setTimeout(function(){map.addOverlays(Beaufort)},1000);
setTimeout(function(){map.addOverlays(Bluffton)},1000);
setTimeout(function(){map.addOverlays(Camden)},1000);
setTimeout(function(){map.addOverlays(Charleston)},1000);
setTimeout(function(){map.addOverlays(Clemson)},1000);
setTimeout(function(){map.addOverlays(Columbia)},1000);
setTimeout(function(){map.addOverlays(Easley)},1000);
setTimeout(function(){map.addOverlays(Florence)},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(Mauldin)},1000);
setTimeout(function(){map.addOverlays(Mount_Pleasant)},1000);
setTimeout(function(){map.addOverlays(N_Augusta)},1000);
setTimeout(function(){map.addOverlays(Pawleys_Island)},1000);
setTimeout(function(){map.addOverlays(Ridgeway)},1000);
setTimeout(function(){map.addOverlays(Simpsonville)},1000);
setTimeout(function(){map.addOverlays(Spartanburg)},1000);
maxLng = -79.12183400;
maxLat = 34.94160600;
minLng = -82.81203500;
minLat = 32.13587800;
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(Anderson);
map.removeOverlays(Beaufort);
map.removeOverlays(Bluffton);
map.removeOverlays(Camden);
map.removeOverlays(Charleston);
map.removeOverlays(Clemson);
map.removeOverlays(Columbia);
map.removeOverlays(Easley);
map.removeOverlays(Florence);
map.removeOverlays(Greenville);
map.removeOverlays(Greenwood);
map.removeOverlays(Hilton_Head_Island);
map.removeOverlays(Mauldin);
map.removeOverlays(Mount_Pleasant);
map.removeOverlays(N_Augusta);
map.removeOverlays(Pawleys_Island);
map.removeOverlays(Ridgeway);
map.removeOverlays(Simpsonville);
map.removeOverlays(Spartanburg);
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(Charleston);map.removeOverlays(Anderson);
map.removeOverlays(Beaufort);
map.removeOverlays(Bluffton);
map.removeOverlays(Camden);
map.removeOverlays(Charleston);
map.removeOverlays(Clemson);
map.removeOverlays(Columbia);
map.removeOverlays(Easley);
map.removeOverlays(Florence);
map.removeOverlays(Greenville);
map.removeOverlays(Greenwood);
map.removeOverlays(Hilton_Head_Island);
map.removeOverlays(Mauldin);
map.removeOverlays(Mount_Pleasant);
map.removeOverlays(N_Augusta);
map.removeOverlays(Pawleys_Island);
map.removeOverlays(Ridgeway);
map.removeOverlays(Simpsonville);
map.removeOverlays(Spartanburg);
map.addOverlays(Anderson);
centerByArray(Anderson, false, false);
cntMarker += Anderson.length;
map.addOverlays(Beaufort);
centerByArray(Beaufort, false, false);
cntMarker += Beaufort.length;
map.addOverlays(Bluffton);
centerByArray(Bluffton, false, false);
cntMarker += Bluffton.length;
map.addOverlays(Camden);
centerByArray(Camden, false, false);
cntMarker += Camden.length;
map.addOverlays(Charleston);
centerByArray(Charleston, false, false);
cntMarker += Charleston.length;
map.addOverlays(Clemson);
centerByArray(Clemson, false, false);
cntMarker += Clemson.length;
map.addOverlays(Columbia);
centerByArray(Columbia, false, false);
cntMarker += Columbia.length;
map.addOverlays(Easley);
centerByArray(Easley, false, false);
cntMarker += Easley.length;
map.addOverlays(Florence);
centerByArray(Florence, false, false);
cntMarker += Florence.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(Mauldin);
centerByArray(Mauldin, false, false);
cntMarker += Mauldin.length;
map.addOverlays(Mount_Pleasant);
centerByArray(Mount_Pleasant, false, false);
cntMarker += Mount_Pleasant.length;
map.addOverlays(N_Augusta);
centerByArray(N_Augusta, false, false);
cntMarker += N_Augusta.length;
map.addOverlays(Pawleys_Island);
centerByArray(Pawleys_Island, false, false);
cntMarker += Pawleys_Island.length;
map.addOverlays(Ridgeway);
centerByArray(Ridgeway, false, false);
cntMarker += Ridgeway.length;
map.addOverlays(Simpsonville);
centerByArray(Simpsonville, false, false);
cntMarker += Simpsonville.length;
map.addOverlays(Spartanburg);
centerByArray(Spartanburg, false, false);
cntMarker += Spartanburg.length;
centerByArray(Charleston,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///25647,25538,34686,25645,25505,25518,25524,25642,25643,25644,25525,34803,25574,32945,25648,25817,25712,31792,25641,25646,25798,25687,25685,36223,25640,25649,/all');
//window.open('/map.php?type=2&schools=25647,25538,34686,25645,25505,25518,25524,25642,25643,25644,25525,34803,25574,32945,25648,25817,25712,31792,25641,25646,25798,25687,25685,36223,25640,25649,&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;
}