function addMarkers()
{
mySelect = document.getElementById('selection');
Midland = [];Warrenton = [];New_Baltimore = [];Bealeton = [];Marshall = [];Catlett = [];Remington = [];mySelect.options[mySelect.options.length] = new Option("Bealeton schools",'all=Bealeton');
mySelect.options[mySelect.options.length] = new Option("Catlett schools",'all=Catlett');
mySelect.options[mySelect.options.length] = new Option("Marshall schools",'all=Marshall');
mySelect.options[mySelect.options.length] = new Option("Midland schools",'all=Midland');
mySelect.options[mySelect.options.length] = new Option("New Baltimore schools",'all=New_Baltimore');
mySelect.options[mySelect.options.length] = new Option("Remington schools",'all=Remington');
mySelect.options[mySelect.options.length] = new Option("Warrenton schools",'all=Warrenton');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Midland[Midland.length] = createMarker(new GPoint(-77.69085693,38.62261581),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Alternative Education Center",'Midland=' + Midland.length);
Warrenton[Warrenton.length] = createMarker(new GPoint(-77.71402000,38.73688900),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Auburn Middle School",'Warrenton=' + Warrenton.length);
New_Baltimore[New_Baltimore.length] = createMarker(new GPoint(-77.69376373,38.76020813),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("C. Hunter Ritchie Elementary School",'New_Baltimore=' + New_Baltimore.length);
Warrenton[Warrenton.length] = createMarker(new GPoint(-77.79764557,38.73370743),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("C. M. Bradley Elementary School",'Warrenton=' + Warrenton.length);
Bealeton[Bealeton.length] = createMarker(new GPoint(-77.76542664,38.57608032),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Cedar Lee Middle School",'Bealeton=' + Bealeton.length);
Marshall[Marshall.length] = createMarker(new GPoint(-77.84829600,38.91039500),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Claude Thompson Elementary School",'Marshall=' + Marshall.length);
Warrenton[Warrenton.length] = createMarker(new GPoint(-77.81451416,38.71870041),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Fauquier High School",'Warrenton=' + Warrenton.length);
Bealeton[Bealeton.length] = createMarker(new GPoint(-77.76326752,38.58483887),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Grace Miller Elementary School",'Bealeton=' + Bealeton.length);
Catlett[Catlett.length] = createMarker(new GPoint(-77.67806244,38.64869690),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("H. M. Pearson Elementary School",'Catlett=' + Catlett.length);
Warrenton[Warrenton.length] = createMarker(new GPoint(-77.78852844,38.69777679),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("James G. Brumfield Elementary School",'Warrenton=' + Warrenton.length);
Bealeton[Bealeton.length] = createMarker(new GPoint(-77.76979828,38.59008789),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Liberty High School",'Bealeton=' + Bealeton.length);
Remington[Remington.length] = createMarker(new GPoint(-77.80594635,38.53859711),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Margaret M. Pierce Elementary School",'Remington=' + Remington.length);
Marshall[Marshall.length] = createMarker(new GPoint(-77.85467900,38.86626600),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Marshall Middle School",'Marshall=' + Marshall.length);
Bealeton[Bealeton.length] = createMarker(new GPoint(-77.70126343,38.50260925),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Mary Walter Elementary School",'Bealeton=' + Bealeton.length);
Warrenton[Warrenton.length] = createMarker(new GPoint(-77.76103210,38.73588181),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("P. B. Smith Elementary School",'Warrenton=' + Warrenton.length);
Midland[Midland.length] = createMarker(new GPoint(-10.00000000,10.00000000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Regional Community Alternative Ed Continuum",'Midland=' + Midland.length);
Warrenton[Warrenton.length] = createMarker(new GPoint(-77.79097748,38.70190048),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("W. C. Taylor Middle School",'Warrenton=' + Warrenton.length);
Marshall[Marshall.length] = createMarker(new GPoint(-77.89469910,38.82559967),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("W. G. Coleman Elementary School",'Marshall=' + Marshall.length);
Warrenton[Warrenton.length] = createMarker(new GPoint(-77.80322266,38.71642303),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Warrenton Middle School",'Warrenton=' + Warrenton.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(Bealeton);
map.removeOverlays(Catlett);
map.removeOverlays(Marshall);
map.removeOverlays(Midland);
map.removeOverlays(New_Baltimore);
map.removeOverlays(Remington);
map.removeOverlays(Warrenton);
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(Midland);map.removeOverlays(Bealeton);
map.removeOverlays(Catlett);
map.removeOverlays(Marshall);
map.removeOverlays(Midland);
map.removeOverlays(New_Baltimore);
map.removeOverlays(Remington);
map.removeOverlays(Warrenton);
map.addOverlays(Bealeton);
centerByArray(Bealeton, false, false);
cntMarker += Bealeton.length;
map.addOverlays(Catlett);
centerByArray(Catlett, false, false);
cntMarker += Catlett.length;
map.addOverlays(Marshall);
centerByArray(Marshall, false, false);
cntMarker += Marshall.length;
map.addOverlays(Midland);
centerByArray(Midland, false, false);
cntMarker += Midland.length;
map.addOverlays(New_Baltimore);
centerByArray(New_Baltimore, false, false);
cntMarker += New_Baltimore.length;
map.addOverlays(Remington);
centerByArray(Remington, false, false);
cntMarker += Remington.length;
map.addOverlays(Warrenton);
centerByArray(Warrenton, false, false);
cntMarker += Warrenton.length;
centerByArray(Midland,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');
}
}