function addMarkers()
{
mySelect = document.getElementById('selection');
Reidsville = [];Eden = [];Mayodan = [];Madison = [];Ruffin = [];Wentworth = [];Stoneville = [];mySelect.options[mySelect.options.length] = new Option("Eden schools",'all=Eden');
mySelect.options[mySelect.options.length] = new Option("Madison schools",'all=Madison');
mySelect.options[mySelect.options.length] = new Option("Mayodan schools",'all=Mayodan');
mySelect.options[mySelect.options.length] = new Option("Reidsville schools",'all=Reidsville');
mySelect.options[mySelect.options.length] = new Option("Ruffin schools",'all=Ruffin');
mySelect.options[mySelect.options.length] = new Option("Stoneville schools",'all=Stoneville');
mySelect.options[mySelect.options.length] = new Option("Wentworth schools",'all=Wentworth');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Reidsville[Reidsville.length] = createMarker(new GPoint(-79.86029816,36.31014252),"
",iconBl);
mySelect.options[mySelect.options.length] = new Option("Bethany Community Middle School",'Reidsville=' + Reidsville.length);
Reidsville[Reidsville.length] = createMarker(new GPoint(-79.85649872,36.30834961),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Bethany Elementary School",'Reidsville=' + Reidsville.length);
Eden[Eden.length] = createMarker(new GPoint(-79.73257446,36.50339890),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Central Elementary School",'Eden=' + Eden.length);
Mayodan[Mayodan.length] = createMarker(new GPoint(-79.96708679,36.41136169),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Dalton Mcmichael High School",'Mayodan=' + Mayodan.length);
Eden[Eden.length] = createMarker(new GPoint(-79.77821350,36.49501801),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Douglass Elementary School",'Eden=' + Eden.length);
Eden[Eden.length] = createMarker(new GPoint(-79.68966675,36.51631165),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Draper Elementary School",'Eden=' + Eden.length);
Madison[Madison.length] = createMarker(new GPoint(-79.97650146,36.38000107),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Huntsville Elementary School",'Madison=' + Madison.length);
Eden[Eden.length] = createMarker(new GPoint(-79.73731995,36.50542831),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("J E Holmes Middle School",'Eden=' + Eden.length);
Eden[Eden.length] = createMarker(new GPoint(-79.73641968,36.50342560),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("John M Morehead High School",'Eden=' + Eden.length);
Madison[Madison.length] = createMarker(new GPoint(-79.97726440,36.39694214),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("John W Dillard Elementary School",'Madison=' + Madison.length);
Reidsville[Reidsville.length] = createMarker(new GPoint(-79.66045380,36.35799789),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Lawsonville Ave Elementary School",'Reidsville=' + Reidsville.length);
Eden[Eden.length] = createMarker(new GPoint(-79.75768280,36.49393845),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Leaksville-spray Elementary School",'Eden=' + Eden.length);
Ruffin[Ruffin.length] = createMarker(new GPoint(-79.63627625,36.44731903),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Lincoln Elementary School",'Ruffin=' + Ruffin.length);
Reidsville[Reidsville.length] = createMarker(new GPoint(-79.73810577,36.31019211),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Monroeton Elementary School",'Reidsville=' + Reidsville.length);
Reidsville[Reidsville.length] = createMarker(new GPoint(-79.68114471,36.36378479),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Moss Street Elementary School",'Reidsville=' + Reidsville.length);
Madison[Madison.length] = createMarker(new GPoint(-79.97296143,36.39964676),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("New Vision Sch.of Math/sci/tec Elementary School",'Madison=' + Madison.length);
Reidsville[Reidsville.length] = createMarker(new GPoint(-79.67591095,36.33116913),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Reidsville High School",'Reidsville=' + Reidsville.length);
Reidsville[Reidsville.length] = createMarker(new GPoint(-79.67990112,36.36303711),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Reidsville Intermediate",'Reidsville=' + Reidsville.length);
Reidsville[Reidsville.length] = createMarker(new GPoint(-79.67599487,36.33108521),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Reidsville Middle School",'Reidsville=' + Reidsville.length);
Wentworth[Wentworth.length] = createMarker(new GPoint(-79.77469635,36.40000153),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Rockingham County High School",'Wentworth=' + Wentworth.length);
Wentworth[Wentworth.length] = createMarker(new GPoint(-79.77469635,36.40000153),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Rockingham County Middle School",'Wentworth=' + Wentworth.length);
Eden[Eden.length] = createMarker(new GPoint(-79.73602295,36.47172546),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Score Center",'Eden=' + Eden.length);
Reidsville[Reidsville.length] = createMarker(new GPoint(-79.66800690,36.34422684),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("South End Elementary School",'Reidsville=' + Reidsville.length);
Stoneville[Stoneville.length] = createMarker(new GPoint(-79.90100098,36.46810150),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Stoneville Elementary School",'Stoneville=' + Stoneville.length);
Wentworth[Wentworth.length] = createMarker(new GPoint(-79.77469635,36.40000153),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Wentworth Elementary School",'Wentworth=' + Wentworth.length);
Madison[Madison.length] = createMarker(new GPoint(-79.98069000,36.40443420),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Western Rockingham Middle School",'Madison=' + Madison.length);
Reidsville[Reidsville.length] = createMarker(new GPoint(-79.62467957,36.28009033),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Williamsburg Elementary School",'Reidsville=' + Reidsville.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(Eden);
map.removeOverlays(Madison);
map.removeOverlays(Mayodan);
map.removeOverlays(Reidsville);
map.removeOverlays(Ruffin);
map.removeOverlays(Stoneville);
map.removeOverlays(Wentworth);
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(Reidsville);map.removeOverlays(Eden);
map.removeOverlays(Madison);
map.removeOverlays(Mayodan);
map.removeOverlays(Reidsville);
map.removeOverlays(Ruffin);
map.removeOverlays(Stoneville);
map.removeOverlays(Wentworth);
map.addOverlays(Eden);
centerByArray(Eden, false, false);
cntMarker += Eden.length;
map.addOverlays(Madison);
centerByArray(Madison, false, false);
cntMarker += Madison.length;
map.addOverlays(Mayodan);
centerByArray(Mayodan, false, false);
cntMarker += Mayodan.length;
map.addOverlays(Reidsville);
centerByArray(Reidsville, false, false);
cntMarker += Reidsville.length;
map.addOverlays(Ruffin);
centerByArray(Ruffin, false, false);
cntMarker += Ruffin.length;
map.addOverlays(Stoneville);
centerByArray(Stoneville, false, false);
cntMarker += Stoneville.length;
map.addOverlays(Wentworth);
centerByArray(Wentworth, false, false);
cntMarker += Wentworth.length;
centerByArray(Reidsville,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');
}
}