function addMarkers()
{
mySelect = document.getElementById('selection');
Kings_Mountain = [];Shelby = [];Lawndale = [];Casar = [];Fallston = [];Shebly = [];Grover = [];mySelect.options[mySelect.options.length] = new Option("Casar schools",'all=Casar');
mySelect.options[mySelect.options.length] = new Option("Fallston schools",'all=Fallston');
mySelect.options[mySelect.options.length] = new Option("Grover schools",'all=Grover');
mySelect.options[mySelect.options.length] = new Option("Kings Mountain schools",'all=Kings_Mountain');
mySelect.options[mySelect.options.length] = new Option("Lawndale schools",'all=Lawndale');
mySelect.options[mySelect.options.length] = new Option("Shebly schools",'all=Shebly');
mySelect.options[mySelect.options.length] = new Option("Shelby schools",'all=Shelby');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Kings_Mountain[Kings_Mountain.length] = createMarker(new GPoint(-81.41339111,35.24705505),"
",iconRd);
mySelect.options[mySelect.options.length] = new Option("Bethware Elementary School",'Kings_Mountain=' + Kings_Mountain.length);
Shelby[Shelby.length] = createMarker(new GPoint(-81.65317535,35.23895645),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Boiling Springs Elementary School",'Shelby=' + Shelby.length);
Lawndale[Lawndale.length] = createMarker(new GPoint(-81.53305054,35.41867447),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Burns High School",'Lawndale=' + Lawndale.length);
Lawndale[Lawndale.length] = createMarker(new GPoint(-81.53919983,35.42564774),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Burns Middle School",'Lawndale=' + Lawndale.length);
Casar[Casar.length] = createMarker(new GPoint(-81.61940002,35.51979828),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Casar Elementary School Of Arts",'Casar=' + Casar.length);
Shelby[Shelby.length] = createMarker(new GPoint(-81.62333679,35.27647018),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Crest Mid School Of Technology",'Shelby=' + Shelby.length);
Shelby[Shelby.length] = createMarker(new GPoint(-81.60832977,35.27224350),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Crest Senior High School",'Shelby=' + Shelby.length);
Kings_Mountain[Kings_Mountain.length] = createMarker(new GPoint(-81.35117400,35.24404800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Davidson School",'Kings_Mountain=' + Kings_Mountain.length);
Kings_Mountain[Kings_Mountain.length] = createMarker(new GPoint(-81.32930756,35.24915695),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("East Elementary School",'Kings_Mountain=' + Kings_Mountain.length);
Shelby[Shelby.length] = createMarker(new GPoint(-81.49311066,35.28105164),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Elizabeth Elementary School",'Shelby=' + Shelby.length);
Fallston[Fallston.length] = createMarker(new GPoint(-81.50160217,35.42879868),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Fallston Elementary School",'Fallston=' + Fallston.length);
Shelby[Shelby.length] = createMarker(new GPoint(-81.55830383,35.28787613),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Graham Elementary School",'Shelby=' + Shelby.length);
Shebly[Shebly.length] = createMarker(new GPoint(-81.55838500,35.28775100),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Graham Elementary School",'Shebly=' + Shebly.length);
Grover[Grover.length] = createMarker(new GPoint(-81.44749451,35.17375946),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Grover Elementary School",'Grover=' + Grover.length);
Shelby[Shelby.length] = createMarker(new GPoint(-81.56584930,35.26644897),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("James Love Elementary School",'Shelby=' + Shelby.length);
Shelby[Shelby.length] = createMarker(new GPoint(-81.51330566,35.30312347),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Jefferson Elementary School",'Shelby=' + Shelby.length);
Kings_Mountain[Kings_Mountain.length] = createMarker(new GPoint(-81.36660004,35.24089813),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Kings Mountain High School",'Kings_Mountain=' + Kings_Mountain.length);
Kings_Mountain[Kings_Mountain.length] = createMarker(new GPoint(-81.37998962,35.23506165),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Kings Mountain Intermediate",'Kings_Mountain=' + Kings_Mountain.length);
Kings_Mountain[Kings_Mountain.length] = createMarker(new GPoint(-81.37300873,35.22938919),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Kings Mountain Middle School",'Kings_Mountain=' + Kings_Mountain.length);
Shelby[Shelby.length] = createMarker(new GPoint(-81.52585602,35.28926468),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Marion Elementary School",'Shelby=' + Shelby.length);
Kings_Mountain[Kings_Mountain.length] = createMarker(new GPoint(-81.34117889,35.25387573),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("North Elementary School",'Kings_Mountain=' + Kings_Mountain.length);
Shelby[Shelby.length] = createMarker(new GPoint(-81.53178406,35.31062698),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("North Shelby",'Shelby=' + Shelby.length);
Shelby[Shelby.length] = createMarker(new GPoint(-81.53862000,35.27741623),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Shelby High School",'Shelby=' + Shelby.length);
Shelby[Shelby.length] = createMarker(new GPoint(-81.54455566,35.29224777),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Shelby Middle School",'Shelby=' + Shelby.length);
Shelby[Shelby.length] = createMarker(new GPoint(-81.66575623,35.27564621),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Springmore Elementary School",'Shelby=' + Shelby.length);
Shelby[Shelby.length] = createMarker(new GPoint(-81.53419495,35.21968460),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Township Three Elementary School",'Shelby=' + Shelby.length);
Shelby[Shelby.length] = createMarker(new GPoint(-81.61953735,35.38829422),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Union Elementary School",'Shelby=' + Shelby.length);
Shelby[Shelby.length] = createMarker(new GPoint(-81.42166901,35.33201981),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Washington Math And Science Elementary School",'Shelby=' + Shelby.length);
Kings_Mountain[Kings_Mountain.length] = createMarker(new GPoint(-81.35126495,35.23943710),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("West Elementary School",'Kings_Mountain=' + Kings_Mountain.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(Casar);
map.removeOverlays(Fallston);
map.removeOverlays(Grover);
map.removeOverlays(Kings_Mountain);
map.removeOverlays(Lawndale);
map.removeOverlays(Shebly);
map.removeOverlays(Shelby);
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(Kings_Mountain);map.removeOverlays(Casar);
map.removeOverlays(Fallston);
map.removeOverlays(Grover);
map.removeOverlays(Kings_Mountain);
map.removeOverlays(Lawndale);
map.removeOverlays(Shebly);
map.removeOverlays(Shelby);
map.addOverlays(Casar);
centerByArray(Casar, false, false);
cntMarker += Casar.length;
map.addOverlays(Fallston);
centerByArray(Fallston, false, false);
cntMarker += Fallston.length;
map.addOverlays(Grover);
centerByArray(Grover, false, false);
cntMarker += Grover.length;
map.addOverlays(Kings_Mountain);
centerByArray(Kings_Mountain, false, false);
cntMarker += Kings_Mountain.length;
map.addOverlays(Lawndale);
centerByArray(Lawndale, false, false);
cntMarker += Lawndale.length;
map.addOverlays(Shebly);
centerByArray(Shebly, false, false);
cntMarker += Shebly.length;
map.addOverlays(Shelby);
centerByArray(Shelby, false, false);
cntMarker += Shelby.length;
centerByArray(Kings_Mountain,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');
}
}