function addMarkers()
{
mySelect = document.getElementById('selection');
Thomasville = [];Lexington = [];Denton = [];Winston_salem = [];mySelect.options[mySelect.options.length] = new Option("Denton schools",'all=Denton');
mySelect.options[mySelect.options.length] = new Option("Lexington schools",'all=Lexington');
mySelect.options[mySelect.options.length] = new Option("Thomasville schools",'all=Thomasville');
mySelect.options[mySelect.options.length] = new Option("Winston salem schools",'all=Winston_salem');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Thomasville[Thomasville.length] = createMarker(new GPoint(-80.08969879,35.86890030),"
",iconRd);
mySelect.options[mySelect.options.length] = new Option("Brier Creek Elementary School",'Thomasville=' + Thomasville.length);
Lexington[Lexington.length] = createMarker(new GPoint(-80.25072900,35.82624500),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Central Davidson Middle School",'Lexington=' + Lexington.length);
Lexington[Lexington.length] = createMarker(new GPoint(-80.22237396,35.73911667),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Central Davidson Senior High School",'Lexington=' + Lexington.length);
Lexington[Lexington.length] = createMarker(new GPoint(-80.25799561,35.80337906),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Charles England Intermediate",'Lexington=' + Lexington.length);
Lexington[Lexington.length] = createMarker(new GPoint(-80.41681671,35.78506088),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Churchland Elementary School",'Lexington=' + Lexington.length);
Lexington[Lexington.length] = createMarker(new GPoint(-80.17475128,35.81776810),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Davidson County Ext Day",'Lexington=' + Lexington.length);
Lexington[Lexington.length] = createMarker(new GPoint(-10.00000000,10.00000000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Davidson Early College",'Lexington=' + Lexington.length);
Lexington[Lexington.length] = createMarker(new GPoint(-80.16388702,35.80606842),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Davis-townsend Elementary School",'Lexington=' + Lexington.length);
Denton[Denton.length] = createMarker(new GPoint(-80.11830139,35.63357162),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Denton Elementary School",'Denton=' + Denton.length);
Thomasville[Thomasville.length] = createMarker(new GPoint(-80.09945679,35.84980011),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("E Lawson Brown Middle School",'Thomasville=' + Thomasville.length);
Thomasville[Thomasville.length] = createMarker(new GPoint(-80.10073090,35.85031891),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("East Davidson High School",'Thomasville=' + Thomasville.length);
Thomasville[Thomasville.length] = createMarker(new GPoint(-80.07936859,35.84957504),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Fair Grove Elementary School",'Thomasville=' + Thomasville.length);
Winston_salem[Winston_salem.length] = createMarker(new GPoint(-80.28221130,35.99361038),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Friedberg Elementary School",'Winston_salem=' + Winston_salem.length);
Winston_salem[Winston_salem.length] = createMarker(new GPoint(-80.13996800,35.95490000),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Friendship Elementary School",'Winston_salem=' + Winston_salem.length);
Thomasville[Thomasville.length] = createMarker(new GPoint(-80.07995605,35.92176056),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Hasty Elementary School",'Thomasville=' + Thomasville.length);
Thomasville[Thomasville.length] = createMarker(new GPoint(-80.12133789,35.94804764),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Ledford Middle School",'Thomasville=' + Thomasville.length);
Thomasville[Thomasville.length] = createMarker(new GPoint(-80.13381195,35.96436310),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Ledford Senior High School",'Thomasville=' + Thomasville.length);
Lexington[Lexington.length] = createMarker(new GPoint(-80.24647522,35.83099747),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Lexington Middle School",'Lexington=' + Lexington.length);
Lexington[Lexington.length] = createMarker(new GPoint(-80.25012207,35.83264923),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Lexington Senior High School",'Lexington=' + Lexington.length);
Thomasville[Thomasville.length] = createMarker(new GPoint(-80.06582642,35.87920380),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Liberty Drive Elementary School",'Thomasville=' + Thomasville.length);
Lexington[Lexington.length] = createMarker(new GPoint(-80.21576691,35.95313263),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Midway Elementary School",'Lexington=' + Lexington.length);
Lexington[Lexington.length] = createMarker(new GPoint(-80.24507904,35.92596436),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("North Davidson Middle School",'Lexington=' + Lexington.length);
Lexington[Lexington.length] = createMarker(new GPoint(-80.24716949,35.92259979),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("North Davidson Senior High School",'Lexington=' + Lexington.length);
Lexington[Lexington.length] = createMarker(new GPoint(-80.30201721,35.94252777),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Northwest Elementary School",'Lexington=' + Lexington.length);
Lexington[Lexington.length] = createMarker(new GPoint(-80.26406860,35.84523773),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Pickett Primary",'Lexington=' + Lexington.length);
Thomasville[Thomasville.length] = createMarker(new GPoint(-80.13504791,35.87786484),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Pilot Elementary School",'Thomasville=' + Thomasville.length);
Lexington[Lexington.length] = createMarker(new GPoint(-80.33338165,35.84329987),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Reeds Elementary School",'Lexington=' + Lexington.length);
Lexington[Lexington.length] = createMarker(new GPoint(-80.25359344,35.82376862),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Silver Valley Elementary School",'Lexington=' + Lexington.length);
Denton[Denton.length] = createMarker(new GPoint(-80.09994507,35.67672348),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("South Davidson High School",'Denton=' + Denton.length);
Denton[Denton.length] = createMarker(new GPoint(-80.09763900,35.57810900),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("South Davidson Middle School",'Denton=' + Denton.length);
Lexington[Lexington.length] = createMarker(new GPoint(-80.26240800,35.79703900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("South Lexington Dvlpmnt Center",'Lexington=' + Lexington.length);
Lexington[Lexington.length] = createMarker(new GPoint(-80.26266479,35.79766464),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("South Lexington/develop Wing Elementary School",'Lexington=' + Lexington.length);
Lexington[Lexington.length] = createMarker(new GPoint(-80.28152400,35.81844500),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Southwest Elementary School",'Lexington=' + Lexington.length);
Lexington[Lexington.length] = createMarker(new GPoint(-80.26652527,35.72159958),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Southwood Elementary School",'Lexington=' + Lexington.length);
Lexington[Lexington.length] = createMarker(new GPoint(-80.19938660,35.81786346),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Stoner-thomas School",'Lexington=' + Lexington.length);
Thomasville[Thomasville.length] = createMarker(new GPoint(-80.08029938,35.89865875),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Thomasville High School",'Thomasville=' + Thomasville.length);
Thomasville[Thomasville.length] = createMarker(new GPoint(-80.08059692,35.89870834),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Thomasville Middle School",'Thomasville=' + Thomasville.length);
Thomasville[Thomasville.length] = createMarker(new GPoint(-80.06108856,35.87804031),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Thomasville Primary",'Thomasville=' + Thomasville.length);
Lexington[Lexington.length] = createMarker(new GPoint(-80.37215424,35.80434418),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Tyro Middle School",'Lexington=' + Lexington.length);
Winston_salem[Winston_salem.length] = createMarker(new GPoint(-80.14207458,36.00862503),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Wallburg Elementary School",'Winston_salem=' + Winston_salem.length);
Lexington[Lexington.length] = createMarker(new GPoint(-80.25359344,35.82376862),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Welcome Elementary School",'Lexington=' + Lexington.length);
Lexington[Lexington.length] = createMarker(new GPoint(-80.37062836,35.80689621),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("West Davidson High School",'Lexington=' + Lexington.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(Denton);
map.removeOverlays(Lexington);
map.removeOverlays(Thomasville);
map.removeOverlays(Winston_salem);
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(Thomasville);map.removeOverlays(Denton);
map.removeOverlays(Lexington);
map.removeOverlays(Thomasville);
map.removeOverlays(Winston_salem);
map.addOverlays(Denton);
centerByArray(Denton, false, false);
cntMarker += Denton.length;
map.addOverlays(Lexington);
centerByArray(Lexington, false, false);
cntMarker += Lexington.length;
map.addOverlays(Thomasville);
centerByArray(Thomasville, false, false);
cntMarker += Thomasville.length;
map.addOverlays(Winston_salem);
centerByArray(Winston_salem, false, false);
cntMarker += Winston_salem.length;
centerByArray(Thomasville,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');
}
}