function addMarkers()
{
mySelect = document.getElementById('selection');
Florence = [];Timmonsville = [];Effingham = [];Pamplico = [];Coward = [];Lake_City = [];Johnsonville = [];Olanta = [];Scranton = [];mySelect.options[mySelect.options.length] = new Option("Coward schools",'all=Coward');
mySelect.options[mySelect.options.length] = new Option("Effingham schools",'all=Effingham');
mySelect.options[mySelect.options.length] = new Option("Florence schools",'all=Florence');
mySelect.options[mySelect.options.length] = new Option("Johnsonville schools",'all=Johnsonville');
mySelect.options[mySelect.options.length] = new Option("Lake City schools",'all=Lake_City');
mySelect.options[mySelect.options.length] = new Option("Olanta schools",'all=Olanta');
mySelect.options[mySelect.options.length] = new Option("Pamplico schools",'all=Pamplico');
mySelect.options[mySelect.options.length] = new Option("Scranton schools",'all=Scranton');
mySelect.options[mySelect.options.length] = new Option("Timmonsville schools",'all=Timmonsville');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Florence[Florence.length] = createMarker(new GPoint(-79.78125763,34.17663956),"
",iconRd);
mySelect.options[mySelect.options.length] = new Option("Briggs Elementary School",'Florence=' + Florence.length);
Timmonsville[Timmonsville.length] = createMarker(new GPoint(-79.94335175,34.13870239),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Brockington Elementary School",'Timmonsville=' + Timmonsville.length);
Florence[Florence.length] = createMarker(new GPoint(-79.80078888,34.20092010),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Carver Elementary School",'Florence=' + Florence.length);
Florence[Florence.length] = createMarker(new GPoint(-10.00000000,10.00000000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Choices School",'Florence=' + Florence.length);
Florence[Florence.length] = createMarker(new GPoint(-79.81869507,34.17102051),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Delmae Heights Elementary School",'Florence=' + Florence.length);
Effingham[Effingham.length] = createMarker(new GPoint(-79.77214050,34.09203339),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Dewey Carter Elementary School",'Effingham=' + Effingham.length);
Florence[Florence.length] = createMarker(new GPoint(-79.77250700,34.13390600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Florence Career Center",'Florence=' + Florence.length);
Florence[Florence.length] = createMarker(new GPoint(-79.73126984,34.14347076),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Greenwood Elementary School",'Florence=' + Florence.length);
Pamplico[Pamplico.length] = createMarker(new GPoint(-79.54974365,33.94549179),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Hannah-pamplico El/middle Elementary School",'Pamplico=' + Pamplico.length);
Pamplico[Pamplico.length] = createMarker(new GPoint(-79.55077362,33.94699478),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Hannah-pamplico High School",'Pamplico=' + Pamplico.length);
Florence[Florence.length] = createMarker(new GPoint(-79.85309601,34.16713715),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Henry L. Sneed Middle School",'Florence=' + Florence.length);
Florence[Florence.length] = createMarker(new GPoint(-79.70748901,34.22963715),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Henry Timrod Elementary School",'Florence=' + Florence.length);
Coward[Coward.length] = createMarker(new GPoint(-79.74849701,33.99520111),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("J C Lynch Elementary School",'Coward=' + Coward.length);
Lake_City[Lake_City.length] = createMarker(new GPoint(-79.75209808,33.86679840),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("J. Paul Truluck Middle School",'Lake_City=' + Lake_City.length);
Timmonsville[Timmonsville.length] = createMarker(new GPoint(-79.94543457,34.14151001),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Johnson Middle School",'Timmonsville=' + Timmonsville.length);
Johnsonville[Johnsonville.length] = createMarker(new GPoint(-79.44667053,33.81707764),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Johnsonville Elementary School",'Johnsonville=' + Johnsonville.length);
Johnsonville[Johnsonville.length] = createMarker(new GPoint(-79.44219971,33.81462097),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Johnsonville High School",'Johnsonville=' + Johnsonville.length);
Johnsonville[Johnsonville.length] = createMarker(new GPoint(-79.44925690,33.81758881),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Johnsonville Middle School",'Johnsonville=' + Johnsonville.length);
Lake_City[Lake_City.length] = createMarker(new GPoint(-79.75209808,33.86679840),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Lake City Elementary School",'Lake_City=' + Lake_City.length);
Lake_City[Lake_City.length] = createMarker(new GPoint(-79.75209808,33.86679840),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Lake City High School",'Lake_City=' + Lake_City.length);
Lake_City[Lake_City.length] = createMarker(new GPoint(-79.75209808,33.86679840),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Main Street Elementary School",'Lake_City=' + Lake_City.length);
Florence[Florence.length] = createMarker(new GPoint(-79.74492645,34.17777252),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Mclaurin Elementary School",'Florence=' + Florence.length);
Florence[Florence.length] = createMarker(new GPoint(-79.79097748,34.17885971),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Moore Intermediate School",'Florence=' + Florence.length);
Florence[Florence.length] = createMarker(new GPoint(-79.76667786,34.21147537),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("North Vista Elementary School",'Florence=' + Florence.length);
Olanta[Olanta.length] = createMarker(new GPoint(-79.93260193,33.94419861),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Olanta Elementary School",'Olanta=' + Olanta.length);
Florence[Florence.length] = createMarker(new GPoint(-79.77478000,34.22005300),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Palmetto Youth Academy",'Florence=' + Florence.length);
Lake_City[Lake_City.length] = createMarker(new GPoint(-79.75209808,33.86679840),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Ronald E. Mcnair Middle School",'Lake_City=' + Lake_City.length);
Florence[Florence.length] = createMarker(new GPoint(-79.79161600,34.18719800),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Royall Elementary School",'Florence=' + Florence.length);
Effingham[Effingham.length] = createMarker(new GPoint(-79.82875824,34.14925766),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Savannah Grove Elementary School",'Effingham=' + Effingham.length);
Scranton[Scranton.length] = createMarker(new GPoint(-79.75820160,33.92559814),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Scranton Elementary School",'Scranton=' + Scranton.length);
Florence[Florence.length] = createMarker(new GPoint(-79.77603149,34.12841415),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("South Florence High School",'Florence=' + Florence.length);
Florence[Florence.length] = createMarker(new GPoint(-79.76950073,34.13359833),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Southside Middle School",'Florence=' + Florence.length);
Florence[Florence.length] = createMarker(new GPoint(-79.69663239,34.19703674),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Theodore Lester Elementary School",'Florence=' + Florence.length);
Timmonsville[Timmonsville.length] = createMarker(new GPoint(-79.93973541,34.13393784),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Timmonsville High School",'Timmonsville=' + Timmonsville.length);
Florence[Florence.length] = createMarker(new GPoint(-79.65636444,34.19438171),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Wallace Gregg Elementary School",'Florence=' + Florence.length);
Florence[Florence.length] = createMarker(new GPoint(-79.82324219,34.19406891),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("West Florence High School",'Florence=' + Florence.length);
Florence[Florence.length] = createMarker(new GPoint(-79.76702881,34.21173477),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Williams Middle School",'Florence=' + Florence.length);
Florence[Florence.length] = createMarker(new GPoint(-79.72435760,34.22551346),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Wilson Senior High School",'Florence=' + Florence.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(Coward);
map.removeOverlays(Effingham);
map.removeOverlays(Florence);
map.removeOverlays(Johnsonville);
map.removeOverlays(Lake_City);
map.removeOverlays(Olanta);
map.removeOverlays(Pamplico);
map.removeOverlays(Scranton);
map.removeOverlays(Timmonsville);
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(Florence);map.removeOverlays(Coward);
map.removeOverlays(Effingham);
map.removeOverlays(Florence);
map.removeOverlays(Johnsonville);
map.removeOverlays(Lake_City);
map.removeOverlays(Olanta);
map.removeOverlays(Pamplico);
map.removeOverlays(Scranton);
map.removeOverlays(Timmonsville);
map.addOverlays(Coward);
centerByArray(Coward, false, false);
cntMarker += Coward.length;
map.addOverlays(Effingham);
centerByArray(Effingham, false, false);
cntMarker += Effingham.length;
map.addOverlays(Florence);
centerByArray(Florence, false, false);
cntMarker += Florence.length;
map.addOverlays(Johnsonville);
centerByArray(Johnsonville, false, false);
cntMarker += Johnsonville.length;
map.addOverlays(Lake_City);
centerByArray(Lake_City, false, false);
cntMarker += Lake_City.length;
map.addOverlays(Olanta);
centerByArray(Olanta, false, false);
cntMarker += Olanta.length;
map.addOverlays(Pamplico);
centerByArray(Pamplico, false, false);
cntMarker += Pamplico.length;
map.addOverlays(Scranton);
centerByArray(Scranton, false, false);
cntMarker += Scranton.length;
map.addOverlays(Timmonsville);
centerByArray(Timmonsville, false, false);
cntMarker += Timmonsville.length;
centerByArray(Florence,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');
}
}