function addMarkers()
{
mySelect = document.getElementById('selection');
Littleton = [];Littleton[Littleton.length] = createMarker(new GPoint(-104.89669037,39.55795288),"
",iconRd);
mySelect.options[mySelect.options.length] = new Option("Acres Green Elementary School",'Littleton=' + Littleton.length);
Littleton[Littleton.length] = createMarker(new GPoint(-104.93613434,39.58478928),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Ames Elementary School",'Littleton=' + Littleton.length);
Littleton[Littleton.length] = createMarker(new GPoint(-104.96513367,39.58048630),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Arapahoe High School",'Littleton=' + Littleton.length);
Littleton[Littleton.length] = createMarker(new GPoint(-105.06060791,39.61659241),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Centennial Academy Of Fine Arts Education",'Littleton=' + Littleton.length);
Littleton[Littleton.length] = createMarker(new GPoint(-104.99046326,39.60879517),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("East Elementary School",'Littleton=' + Littleton.length);
Littleton[Littleton.length] = createMarker(new GPoint(-104.99724579,39.59708786),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Euclid Middle School",'Littleton=' + Littleton.length);
Littleton[Littleton.length] = createMarker(new GPoint(-104.98089600,39.61177063),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Field Elementary School",'Littleton=' + Littleton.length);
Littleton[Littleton.length] = createMarker(new GPoint(-104.96981049,39.59918976),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Franklin Elementary School",'Littleton=' + Littleton.length);
Littleton[Littleton.length] = createMarker(new GPoint(-105.06060791,39.61659241),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Goddard Middle School",'Littleton=' + Littleton.length);
Littleton[Littleton.length] = createMarker(new GPoint(-105.00572968,39.58438873),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Heritage High School",'Littleton=' + Littleton.length);
Littleton[Littleton.length] = createMarker(new GPoint(-104.97983551,39.59769058),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Highland Elementary School",'Littleton=' + Littleton.length);
Littleton[Littleton.length] = createMarker(new GPoint(-105.01170600,39.51931000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Hope Online Learning Academy Co-op",'Littleton=' + Littleton.length);
Littleton[Littleton.length] = createMarker(new GPoint(-104.98174286,39.58774948),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Hopkins Elementary School",'Littleton=' + Littleton.length);
Littleton[Littleton.length] = createMarker(new GPoint(-104.97803497,39.57298660),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("John Wesley Powell Middle School",'Littleton=' + Littleton.length);
Littleton[Littleton.length] = createMarker(new GPoint(-105.00278473,39.57368851),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Littleton Academy",'Littleton=' + Littleton.length);
Littleton[Littleton.length] = createMarker(new GPoint(-104.98539734,39.61328506),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Littleton High School",'Littleton=' + Littleton.length);
Littleton[Littleton.length] = createMarker(new GPoint(-105.02564240,39.62305832),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Littleton Prep Charter School",'Littleton=' + Littleton.length);
Littleton[Littleton.length] = createMarker(new GPoint(-104.93083191,39.60112381),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Lois Lenski Elementary School",'Littleton=' + Littleton.length);
Littleton[Littleton.length] = createMarker(new GPoint(-105.00713348,39.60073853),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Moody Elementary School",'Littleton=' + Littleton.length);
Littleton[Littleton.length] = createMarker(new GPoint(-104.94133759,39.59498978),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Newton Middle School",'Littleton=' + Littleton.length);
Littleton[Littleton.length] = createMarker(new GPoint(-104.95249176,39.60424423),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Peabody Elementary School",'Littleton=' + Littleton.length);
Littleton[Littleton.length] = createMarker(new GPoint(-105.04100037,39.55077744),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Plum Creek Academy Day Treatment",'Littleton=' + Littleton.length);
Littleton[Littleton.length] = createMarker(new GPoint(-104.89025879,39.52909851),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Rock Canyon High School",'Littleton=' + Littleton.length);
Littleton[Littleton.length] = createMarker(new GPoint(-104.89025879,39.52909851),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Rocky Heights Middle School",'Littleton=' + Littleton.length);
Littleton[Littleton.length] = createMarker(new GPoint(-105.08034515,39.47826385),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Roxborough Elementary School",'Littleton=' + Littleton.length);
Littleton[Littleton.length] = createMarker(new GPoint(-104.99790955,39.58493805),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Runyon Elementary School",'Littleton=' + Littleton.length);
Littleton[Littleton.length] = createMarker(new GPoint(-104.95533752,39.59118652),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Sandburg Elementary School",'Littleton=' + Littleton.length);
Littleton[Littleton.length] = createMarker(new GPoint(-104.96947479,39.59118652),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Twain Elementary School",'Littleton=' + Littleton.length);
Littleton[Littleton.length] = createMarker(new GPoint(-105.01024628,39.61518860),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Village At North Elementary School",'Littleton=' + Littleton.length);
Littleton[Littleton.length] = createMarker(new GPoint(-104.99057770,39.59824371),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Whitman Elementary School",'Littleton=' + Littleton.length);
Littleton[Littleton.length] = createMarker(new GPoint(-104.91043854,39.52305222),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Wildcat Mountain Elementary School",'Littleton=' + Littleton.length);
Littleton[Littleton.length] = createMarker(new GPoint(-105.04255676,39.60314178),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Wilder Elementary School",'Littleton=' + Littleton.length);
map.removeOverlays(Littleton);
setTimeout(function(){map.addOverlays(Littleton)},1000);
maxLng = -104.89025879;
maxLat = 39.62305832;
minLng = -105.08034515;
minLat = 39.47826385;
reCenterMap();
} // 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(Littleton);
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(Littleton);map.removeOverlays(Littleton);
map.addOverlays(Littleton);
centerByArray(Littleton, false, false);
cntMarker += Littleton.length;
centerByArray(Littleton,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');
}
}