function addMarkers()
{
mySelect = document.getElementById('selection');
Gastonia = [];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);
Gastonia[Gastonia.length] = createMarker(new GPoint(-81.15364838,35.29298782),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Brookside Elementary School",'Gastonia=' + Gastonia.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);
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);
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);
Gastonia[Gastonia.length] = createMarker(new GPoint(-81.19133759,35.24092865),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Lingerfeldt Elementary School",'Gastonia=' + Gastonia.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);
Gastonia[Gastonia.length] = createMarker(new GPoint(-81.15299988,35.26020050),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Piedmont Community Charter",'Gastonia=' + Gastonia.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);
Gastonia[Gastonia.length] = createMarker(new GPoint(-81.20614624,35.23055267),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Southwest Middle School",'Gastonia=' + Gastonia.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);
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(Gastonia);
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(Gastonia);
map.addOverlays(Gastonia);
centerByArray(Gastonia, false, false);
cntMarker += Gastonia.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');
}
}