function addMarkers()
{
mySelect = document.getElementById('selection');
Gastonia = [];Belmont = [];Bessemer_City = [];Dallas = [];Cherryville = [];Cramerton = [];Mount_Holly = [];Lowell = [];Stanley = [];Mcadenville = [];mySelect.options[mySelect.options.length] = new Option("Belmont schools",'all=Belmont');
mySelect.options[mySelect.options.length] = new Option("Bessemer City schools",'all=Bessemer_City');
mySelect.options[mySelect.options.length] = new Option("Cherryville schools",'all=Cherryville');
mySelect.options[mySelect.options.length] = new Option("Cramerton schools",'all=Cramerton');
mySelect.options[mySelect.options.length] = new Option("Dallas schools",'all=Dallas');
mySelect.options[mySelect.options.length] = new Option("Gastonia schools",'all=Gastonia');
mySelect.options[mySelect.options.length] = new Option("Lowell schools",'all=Lowell');
mySelect.options[mySelect.options.length] = new Option("Mcadenville schools",'all=Mcadenville');
mySelect.options[mySelect.options.length] = new Option("Mount Holly schools",'all=Mount_Holly');
mySelect.options[mySelect.options.length] = new Option("Stanley schools",'all=Stanley');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Gastonia[Gastonia.length] = createMarker(new GPoint(-81.21225739,35.26499939),"
",iconRd);
mySelect.options[mySelect.options.length] = new Option("Arlington Elementary School",'Gastonia=' + Gastonia.length);
Gastonia[Gastonia.length] = createMarker(new GPoint(-81.12811279,35.24248123),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Ashbrook High School",'Gastonia=' + Gastonia.length);
Belmont[Belmont.length] = createMarker(new GPoint(-81.04885864,35.23939514),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Belmont Central Elementary School",'Belmont=' + Belmont.length);
Belmont[Belmont.length] = createMarker(new GPoint(-81.04200745,35.24150848),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Belmont Middle School",'Belmont=' + Belmont.length);
Bessemer_City[Bessemer_City.length] = createMarker(new GPoint(-81.28500900,35.28496000),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Bessemer City Central Elementary School",'Bessemer_City=' + Bessemer_City.length);
Bessemer_City[Bessemer_City.length] = createMarker(new GPoint(-81.28033447,35.29838943),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bessemer City High School",'Bessemer_City=' + Bessemer_City.length);
Bessemer_City[Bessemer_City.length] = createMarker(new GPoint(-81.28140259,35.30360031),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Bessemer City Middle School",'Bessemer_City=' + Bessemer_City.length);
Bessemer_City[Bessemer_City.length] = createMarker(new GPoint(-81.27871704,35.29866028),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Bessemer City Primary",'Bessemer_City=' + Bessemer_City.length);
Gastonia[Gastonia.length] = createMarker(new GPoint(-81.15364838,35.29298782),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Brookside Elementary School",'Gastonia=' + Gastonia.length);
Dallas[Dallas.length] = createMarker(new GPoint(-81.18215179,35.31336212),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Carr Elementary School",'Dallas=' + Dallas.length);
Belmont[Belmont.length] = createMarker(new GPoint(-81.03579712,35.27349472),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Catawba Heights Elementary School",'Belmont=' + Belmont.length);
Gastonia[Gastonia.length] = createMarker(new GPoint(-81.24978638,35.20695114),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Chapel Grove Elementary School",'Gastonia=' + Gastonia.length);
Cherryville[Cherryville.length] = createMarker(new GPoint(-81.37158203,35.37912369),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Cherryville Elementary School",'Cherryville=' + Cherryville.length);
Cherryville[Cherryville.length] = createMarker(new GPoint(-81.37956238,35.37895966),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Cherryville Senior High School",'Cherryville=' + Cherryville.length);
Dallas[Dallas.length] = createMarker(new GPoint(-81.18150330,35.33589935),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Costner Elementary School",'Dallas=' + Dallas.length);
Cramerton[Cramerton.length] = createMarker(new GPoint(-73.83959198,40.67771530),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Cramerton Middle School",'Cramerton=' + Cramerton.length);
Mount_Holly[Mount_Holly.length] = createMarker(new GPoint(-81.01600647,35.29853821),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("East Gaston High School",'Mount_Holly=' + Mount_Holly.length);
Gastonia[Gastonia.length] = createMarker(new GPoint(-81.25972100,35.25668400),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Edward D Sadler, Jr Elementary School",'Gastonia=' + Gastonia.length);
Gastonia[Gastonia.length] = createMarker(new GPoint(-81.18782043,35.26213074),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Forest Heights Elementary School",'Gastonia=' + Gastonia.length);
Gastonia[Gastonia.length] = createMarker(new GPoint(-81.13629150,35.18282700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Forestview High School",'Gastonia=' + Gastonia.length);
Gastonia[Gastonia.length] = createMarker(new GPoint(-81.13461304,35.25460815),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Gardner Park Elementary School",'Gastonia=' + Gastonia.length);
Gastonia[Gastonia.length] = createMarker(new GPoint(-81.20217896,35.22243500),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Hershal H Beam Elementary School",'Gastonia=' + Gastonia.length);
Gastonia[Gastonia.length] = createMarker(new GPoint(-81.18609619,35.26330185),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Highland Charter",'Gastonia=' + Gastonia.length);
Gastonia[Gastonia.length] = createMarker(new GPoint(-81.18986511,35.27964020),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Highland School Of Technology",'Gastonia=' + Gastonia.length);
Lowell[Lowell.length] = createMarker(new GPoint(-81.10157400,35.26698500),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Holbrook Middle School",'Lowell=' + Lowell.length);
Gastonia[Gastonia.length] = createMarker(new GPoint(-81.20658112,35.24126816),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Hunter Huss High School",'Gastonia=' + Gastonia.length);
Mount_Holly[Mount_Holly.length] = createMarker(new GPoint(-81.02970123,35.31430054),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Ida Rankin Elementary School",'Mount_Holly=' + Mount_Holly.length);
Belmont[Belmont.length] = createMarker(new GPoint(-81.03295898,35.23545074),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("J B Page Elementary School",'Belmont=' + Belmont.length);
Cherryville[Cherryville.length] = createMarker(new GPoint(-81.39559937,35.37990189),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("John Chavis Middle School",'Cherryville=' + Cherryville.length);
Stanley[Stanley.length] = createMarker(new GPoint(-81.09220123,35.36143875),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Kiser Elementary School",'Stanley=' + Stanley.length);
Gastonia[Gastonia.length] = createMarker(new GPoint(-81.19133759,35.24092865),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Lingerfeldt Elementary School",'Gastonia=' + Gastonia.length);
Lowell[Lowell.length] = createMarker(new GPoint(-81.09227753,35.27808762),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Lowell Elementary School",'Lowell=' + Lowell.length);
Mcadenville[Mcadenville.length] = createMarker(new GPoint(-81.07289886,35.25360107),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Mcadenville Elementary School",'Mcadenville=' + Mcadenville.length);
Mount_Holly[Mount_Holly.length] = createMarker(new GPoint(-81.02261353,35.29823303),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Mount Holly Middle School",'Mount_Holly=' + Mount_Holly.length);
Gastonia[Gastonia.length] = createMarker(new GPoint(-81.08328247,35.21129990),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("New Hope Elementary School",'Gastonia=' + Gastonia.length);
Belmont[Belmont.length] = createMarker(new GPoint(-81.04921722,35.27291489),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("North Belmont Elementary School",'Belmont=' + Belmont.length);
Dallas[Dallas.length] = createMarker(new GPoint(-81.17749786,35.33549118),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("North Gaston High School",'Dallas=' + Dallas.length);
Gastonia[Gastonia.length] = createMarker(new GPoint(-81.15299988,35.26020050),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Piedmont Community Charter",'Gastonia=' + Gastonia.length);
Mount_Holly[Mount_Holly.length] = createMarker(new GPoint(-80.99851990,35.32839584),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Pinewood Elementary School",'Mount_Holly=' + Mount_Holly.length);
Gastonia[Gastonia.length] = createMarker(new GPoint(-81.20403290,35.24923325),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Pleasant Ridge Elementary School",'Gastonia=' + Gastonia.length);
Gastonia[Gastonia.length] = createMarker(new GPoint(-81.20730591,35.27878189),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Rhyne Elementary School",'Gastonia=' + Gastonia.length);
Gastonia[Gastonia.length] = createMarker(new GPoint(-81.16570282,35.21337128),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Robinson Elementary School",'Gastonia=' + Gastonia.length);
Gastonia[Gastonia.length] = createMarker(new GPoint(-81.15388489,35.24919510),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Sherwood Elementary School",'Gastonia=' + Gastonia.length);
Belmont[Belmont.length] = createMarker(new GPoint(-81.03792572,35.22425461),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("South Point High School",'Belmont=' + Belmont.length);
Gastonia[Gastonia.length] = createMarker(new GPoint(-81.20614624,35.23055267),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Southwest Middle School",'Gastonia=' + Gastonia.length);
Stanley[Stanley.length] = createMarker(new GPoint(-81.09530640,35.34792328),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Springfield Primary",'Stanley=' + Stanley.length);
Stanley[Stanley.length] = createMarker(new GPoint(-81.10368347,35.36727905),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Stanley Middle School",'Stanley=' + Stanley.length);
Bessemer_City[Bessemer_City.length] = createMarker(new GPoint(-81.32293701,35.34050751),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Tryon Elementary School",'Bessemer_City=' + Bessemer_City.length);
Gastonia[Gastonia.length] = createMarker(new GPoint(-81.13380432,35.18978119),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("W A Bess Elementary School",'Gastonia=' + Gastonia.length);
Gastonia[Gastonia.length] = createMarker(new GPoint(-81.15547943,35.25296021),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("W P Grier Middle School",'Gastonia=' + Gastonia.length);
Gastonia[Gastonia.length] = createMarker(new GPoint(-81.13360596,35.28110123),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Warlick School",'Gastonia=' + Gastonia.length);
Gastonia[Gastonia.length] = createMarker(new GPoint(-81.21226501,35.26499939),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Webb St Special Education",'Gastonia=' + Gastonia.length);
Cherryville[Cherryville.length] = createMarker(new GPoint(-81.37648300,35.38111000),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("William B Beam Intermediate",'Cherryville=' + Cherryville.length);
Dallas[Dallas.length] = createMarker(new GPoint(-81.18326569,35.33535767),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("William C Friday Middle School",'Dallas=' + Dallas.length);
Gastonia[Gastonia.length] = createMarker(new GPoint(-81.17908478,35.27816772),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Woodhill Elementary School",'Gastonia=' + Gastonia.length);
Gastonia[Gastonia.length] = createMarker(new GPoint(-81.18638400,35.26217000),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("York Chester Middle School",'Gastonia=' + Gastonia.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(Belmont);
map.removeOverlays(Bessemer_City);
map.removeOverlays(Cherryville);
map.removeOverlays(Cramerton);
map.removeOverlays(Dallas);
map.removeOverlays(Gastonia);
map.removeOverlays(Lowell);
map.removeOverlays(Mcadenville);
map.removeOverlays(Mount_Holly);
map.removeOverlays(Stanley);
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(Gastonia);map.removeOverlays(Belmont);
map.removeOverlays(Bessemer_City);
map.removeOverlays(Cherryville);
map.removeOverlays(Cramerton);
map.removeOverlays(Dallas);
map.removeOverlays(Gastonia);
map.removeOverlays(Lowell);
map.removeOverlays(Mcadenville);
map.removeOverlays(Mount_Holly);
map.removeOverlays(Stanley);
map.addOverlays(Belmont);
centerByArray(Belmont, false, false);
cntMarker += Belmont.length;
map.addOverlays(Bessemer_City);
centerByArray(Bessemer_City, false, false);
cntMarker += Bessemer_City.length;
map.addOverlays(Cherryville);
centerByArray(Cherryville, false, false);
cntMarker += Cherryville.length;
map.addOverlays(Cramerton);
centerByArray(Cramerton, false, false);
cntMarker += Cramerton.length;
map.addOverlays(Dallas);
centerByArray(Dallas, false, false);
cntMarker += Dallas.length;
map.addOverlays(Gastonia);
centerByArray(Gastonia, false, false);
cntMarker += Gastonia.length;
map.addOverlays(Lowell);
centerByArray(Lowell, false, false);
cntMarker += Lowell.length;
map.addOverlays(Mcadenville);
centerByArray(Mcadenville, false, false);
cntMarker += Mcadenville.length;
map.addOverlays(Mount_Holly);
centerByArray(Mount_Holly, false, false);
cntMarker += Mount_Holly.length;
map.addOverlays(Stanley);
centerByArray(Stanley, false, false);
cntMarker += Stanley.length;
centerByArray(Gastonia,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');
}
}