function addMarkers()
{
mySelect = document.getElementById('selection');
Parachute = [];Glenwood_Springs = [];Woody_Creek = [];Carbondale = [];New_Castle = [];Rifle = [];Silt = [];mySelect.options[mySelect.options.length] = new Option("Carbondale schools",'all=Carbondale');
mySelect.options[mySelect.options.length] = new Option("Glenwood Springs schools",'all=Glenwood_Springs');
mySelect.options[mySelect.options.length] = new Option("New Castle schools",'all=New_Castle');
mySelect.options[mySelect.options.length] = new Option("Parachute schools",'all=Parachute');
mySelect.options[mySelect.options.length] = new Option("Rifle schools",'all=Rifle');
mySelect.options[mySelect.options.length] = new Option("Silt schools",'all=Silt');
mySelect.options[mySelect.options.length] = new Option("Woody Creek schools",'all=Woody_Creek');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Parachute[Parachute.length] = createMarker(new GPoint(-108.08039856,39.50109863),"
",iconRd);
mySelect.options[mySelect.options.length] = new Option("Bea Underwood Elementary School",'Parachute=' + Parachute.length);
Glenwood_Springs[Glenwood_Springs.length] = createMarker(new GPoint(-107.32498169,39.53928757),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bridges High School",'Glenwood_Springs=' + Glenwood_Springs.length);
Woody_Creek[Woody_Creek.length] = createMarker(new GPoint(-106.89530182,39.28129959),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Carbondale Community Charter",'Woody_Creek=' + Woody_Creek.length);
Carbondale[Carbondale.length] = createMarker(new GPoint(-107.21292114,39.40258026),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Carbondale Community Charter School",'Carbondale=' + Carbondale.length);
Carbondale[Carbondale.length] = createMarker(new GPoint(-107.20993042,39.39568710),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Carbondale Elementary School",'Carbondale=' + Carbondale.length);
Carbondale[Carbondale.length] = createMarker(new GPoint(-107.20993805,39.39637756),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Carbondale Middle School",'Carbondale=' + Carbondale.length);
New_Castle[New_Castle.length] = createMarker(new GPoint(-107.65691400,39.54867200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Coal Ridge High School",'New_Castle=' + New_Castle.length);
Carbondale[Carbondale.length] = createMarker(new GPoint(-107.20655823,39.39856720),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Crystal River Elementary School",'Carbondale=' + Carbondale.length);
Glenwood_Springs[Glenwood_Springs.length] = createMarker(new GPoint(-107.32740784,39.54523468),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Glenwood Springs Elementary School",'Glenwood_Springs=' + Glenwood_Springs.length);
Glenwood_Springs[Glenwood_Springs.length] = createMarker(new GPoint(-107.32700348,39.54009628),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Glenwood Springs High School",'Glenwood_Springs=' + Glenwood_Springs.length);
Glenwood_Springs[Glenwood_Springs.length] = createMarker(new GPoint(-107.35923767,39.56309891),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Glenwood Springs Middle School",'Glenwood_Springs=' + Glenwood_Springs.length);
Parachute[Parachute.length] = createMarker(new GPoint(-108.05352783,39.45279312),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Grand Valley Early Childhood Literacy Center",'Parachute=' + Parachute.length);
Parachute[Parachute.length] = createMarker(new GPoint(-108.08039856,39.50109863),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Grand Valley High School",'Parachute=' + Parachute.length);
Rifle[Rifle.length] = createMarker(new GPoint(-107.78357697,39.53551483),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Highland Elementary School",'Rifle=' + Rifle.length);
New_Castle[New_Castle.length] = createMarker(new GPoint(-107.52469635,39.57640076),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Kathryn Senor Elementary School",'New_Castle=' + New_Castle.length);
Parachute[Parachute.length] = createMarker(new GPoint(-108.08039856,39.50109863),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("L W St John Middle School",'Parachute=' + Parachute.length);
Glenwood_Springs[Glenwood_Springs.length] = createMarker(new GPoint(-107.33397675,39.54782486),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Mountain Boces Day Treatment Center",'Glenwood_Springs=' + Glenwood_Springs.length);
Rifle[Rifle.length] = createMarker(new GPoint(-107.79479980,39.54194260),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Rifle High School",'Rifle=' + Rifle.length);
Rifle[Rifle.length] = createMarker(new GPoint(-107.78389740,39.53453827),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Rifle Middle School",'Rifle=' + Rifle.length);
New_Castle[New_Castle.length] = createMarker(new GPoint(-107.52469635,39.57640076),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Riverside School",'New_Castle=' + New_Castle.length);
Carbondale[Carbondale.length] = createMarker(new GPoint(-107.20648193,39.39820480),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Roaring Fork High School",'Carbondale=' + Carbondale.length);
Carbondale[Carbondale.length] = createMarker(new GPoint(-107.21668500,39.39747800),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Ross Montessori School",'Carbondale=' + Carbondale.length);
Silt[Silt.length] = createMarker(new GPoint(-107.65070343,39.51950073),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Roy Moore Elementary School",'Silt=' + Silt.length);
Glenwood_Springs[Glenwood_Springs.length] = createMarker(new GPoint(-107.31551361,39.51033783),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Sopris Elementary School",'Glenwood_Springs=' + Glenwood_Springs.length);
Rifle[Rifle.length] = createMarker(new GPoint(-107.77436829,39.55571365),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Wamsley Elementary School",'Rifle=' + Rifle.length);
Glenwood_Springs[Glenwood_Springs.length] = createMarker(new GPoint(-107.33397675,39.54782486),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Yampah Mountain School",'Glenwood_Springs=' + Glenwood_Springs.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(Carbondale);
map.removeOverlays(Glenwood_Springs);
map.removeOverlays(New_Castle);
map.removeOverlays(Parachute);
map.removeOverlays(Rifle);
map.removeOverlays(Silt);
map.removeOverlays(Woody_Creek);
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(Parachute);map.removeOverlays(Carbondale);
map.removeOverlays(Glenwood_Springs);
map.removeOverlays(New_Castle);
map.removeOverlays(Parachute);
map.removeOverlays(Rifle);
map.removeOverlays(Silt);
map.removeOverlays(Woody_Creek);
map.addOverlays(Carbondale);
centerByArray(Carbondale, false, false);
cntMarker += Carbondale.length;
map.addOverlays(Glenwood_Springs);
centerByArray(Glenwood_Springs, false, false);
cntMarker += Glenwood_Springs.length;
map.addOverlays(New_Castle);
centerByArray(New_Castle, false, false);
cntMarker += New_Castle.length;
map.addOverlays(Parachute);
centerByArray(Parachute, false, false);
cntMarker += Parachute.length;
map.addOverlays(Rifle);
centerByArray(Rifle, false, false);
cntMarker += Rifle.length;
map.addOverlays(Silt);
centerByArray(Silt, false, false);
cntMarker += Silt.length;
map.addOverlays(Woody_Creek);
centerByArray(Woody_Creek, false, false);
cntMarker += Woody_Creek.length;
centerByArray(Parachute,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');
}
}