function addMarkers()
{
mySelect = document.getElementById('selection');
Highlands_Ranch = [];Highlands_Ranch[Highlands_Ranch.length] = createMarker(new GPoint(-104.93331146,39.52802658),"
",iconRd);
mySelect.options[mySelect.options.length] = new Option("Arrowwood Elementary School",'Highlands_Ranch=' + Highlands_Ranch.length);
Highlands_Ranch[Highlands_Ranch.length] = createMarker(new GPoint(-104.98714447,39.54070282),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Bear Canyon Elementary School",'Highlands_Ranch=' + Highlands_Ranch.length);
Highlands_Ranch[Highlands_Ranch.length] = createMarker(new GPoint(-104.94692700,39.51824400),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Copper Mesa Elementary School",'Highlands_Ranch=' + Highlands_Ranch.length);
Highlands_Ranch[Highlands_Ranch.length] = createMarker(new GPoint(-104.95103455,39.55529785),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Cougar Run Elementary School",'Highlands_Ranch=' + Highlands_Ranch.length);
Highlands_Ranch[Highlands_Ranch.length] = createMarker(new GPoint(-105.02275085,39.52761459),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Coyote Creek Elementary School",'Highlands_Ranch=' + Highlands_Ranch.length);
Highlands_Ranch[Highlands_Ranch.length] = createMarker(new GPoint(-104.92893219,39.55271912),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Cresthill Middle School",'Highlands_Ranch=' + Highlands_Ranch.length);
Highlands_Ranch[Highlands_Ranch.length] = createMarker(new GPoint(-104.92887878,39.54772949),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Eagle Academy",'Highlands_Ranch=' + Highlands_Ranch.length);
Highlands_Ranch[Highlands_Ranch.length] = createMarker(new GPoint(-104.99402618,39.54199219),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Eldorado Elementary School",'Highlands_Ranch=' + Highlands_Ranch.length);
Highlands_Ranch[Highlands_Ranch.length] = createMarker(new GPoint(-104.91028595,39.54666519),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Fox Creek Elementary School",'Highlands_Ranch=' + Highlands_Ranch.length);
Highlands_Ranch[Highlands_Ranch.length] = createMarker(new GPoint(-104.95049286,39.53150177),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Heritage Elementary School",'Highlands_Ranch=' + Highlands_Ranch.length);
Highlands_Ranch[Highlands_Ranch.length] = createMarker(new GPoint(-104.92887878,39.54772949),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Highlands Ranch High School",'Highlands_Ranch=' + Highlands_Ranch.length);
Highlands_Ranch[Highlands_Ranch.length] = createMarker(new GPoint(-104.96378326,39.52312469),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Mountain Ridge Middle School",'Highlands_Ranch=' + Highlands_Ranch.length);
Highlands_Ranch[Highlands_Ranch.length] = createMarker(new GPoint(-104.96414948,39.52317429),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Mountain Vista High School",'Highlands_Ranch=' + Highlands_Ranch.length);
Highlands_Ranch[Highlands_Ranch.length] = createMarker(new GPoint(-104.98352051,39.55095291),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Northridge Elementary School",'Highlands_Ranch=' + Highlands_Ranch.length);
Highlands_Ranch[Highlands_Ranch.length] = createMarker(new GPoint(-104.94056702,39.55002213),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Platte River Charter Academy",'Highlands_Ranch=' + Highlands_Ranch.length);
Highlands_Ranch[Highlands_Ranch.length] = createMarker(new GPoint(-105.00922394,39.53150177),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Ranch View Middle School",'Highlands_Ranch=' + Highlands_Ranch.length);
Highlands_Ranch[Highlands_Ranch.length] = createMarker(new GPoint(-104.91980200,39.53499900),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Redstone Elementary School",'Highlands_Ranch=' + Highlands_Ranch.length);
Highlands_Ranch[Highlands_Ranch.length] = createMarker(new GPoint(-104.99564362,39.53122330),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Saddle Ranch Elementary School",'Highlands_Ranch=' + Highlands_Ranch.length);
Highlands_Ranch[Highlands_Ranch.length] = createMarker(new GPoint(-104.96462250,39.56111908),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Sand Creek Elementary School",'Highlands_Ranch=' + Highlands_Ranch.length);
Highlands_Ranch[Highlands_Ranch.length] = createMarker(new GPoint(-104.96273804,39.53251266),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Summit View Elementary School",'Highlands_Ranch=' + Highlands_Ranch.length);
Highlands_Ranch[Highlands_Ranch.length] = createMarker(new GPoint(-105.01390839,39.53445816),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Thunderridge High School",'Highlands_Ranch=' + Highlands_Ranch.length);
Highlands_Ranch[Highlands_Ranch.length] = createMarker(new GPoint(-105.01950836,39.53876877),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Trailblazer Elementary School",'Highlands_Ranch=' + Highlands_Ranch.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(Highlands_Ranch);
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(Highlands_Ranch);map.removeOverlays(Highlands_Ranch);
map.addOverlays(Highlands_Ranch);
centerByArray(Highlands_Ranch, false, false);
cntMarker += Highlands_Ranch.length;
centerByArray(Highlands_Ranch,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');
}
}