function addMarkers()
{
mySelect = document.getElementById('selection');
Castle_Rock = [];Littleton = [];Lone_Tree = [];Highlands_Ranch = [];Parker = [];Franktown = [];Larkspur = [];Sedalia = [];mySelect.options[mySelect.options.length] = new Option("Castle Rock schools",'all=Castle_Rock');
mySelect.options[mySelect.options.length] = new Option("Franktown schools",'all=Franktown');
mySelect.options[mySelect.options.length] = new Option("Highlands Ranch schools",'all=Highlands_Ranch');
mySelect.options[mySelect.options.length] = new Option("Larkspur schools",'all=Larkspur');
mySelect.options[mySelect.options.length] = new Option("Littleton schools",'all=Littleton');
mySelect.options[mySelect.options.length] = new Option("Lone Tree schools",'all=Lone_Tree');
mySelect.options[mySelect.options.length] = new Option("Parker schools",'all=Parker');
mySelect.options[mySelect.options.length] = new Option("Sedalia schools",'all=Sedalia');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Castle_Rock[Castle_Rock.length] = createMarker(new GPoint(-104.86959076,39.38027191),"
",iconRd);
mySelect.options[mySelect.options.length] = new Option("Academy Charter School",'Castle_Rock=' + Castle_Rock.length);
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);
Lone_Tree[Lone_Tree.length] = createMarker(new GPoint(-104.88129400,39.55426900),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("American Academy At Castle Pines Charter",'Lone_Tree=' + Lone_Tree.length);
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);
Castle_Rock[Castle_Rock.length] = createMarker(new GPoint(-104.89387512,39.46543884),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Buffalo Ridge Elementary School",'Castle_Rock=' + Castle_Rock.length);
Castle_Rock[Castle_Rock.length] = createMarker(new GPoint(-104.85633087,39.37255096),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Cantril School",'Castle_Rock=' + Castle_Rock.length);
Castle_Rock[Castle_Rock.length] = createMarker(new GPoint(-104.84996796,39.38117218),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Castle Rock Elementary School",'Castle_Rock=' + Castle_Rock.length);
Castle_Rock[Castle_Rock.length] = createMarker(new GPoint(-104.87498474,39.40871811),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Castle Rock Middle School",'Castle_Rock=' + Castle_Rock.length);
Parker[Parker.length] = createMarker(new GPoint(-104.79256439,39.54591370),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Challenge To Excellence Charter School",'Parker=' + Parker.length);
Parker[Parker.length] = createMarker(new GPoint(-104.80750275,39.53899384),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Chaparral High School",'Parker=' + Parker.length);
Parker[Parker.length] = createMarker(new GPoint(-104.78664700,39.52513300),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Cherokee Trail Elementary School",'Parker=' + Parker.length);
Franktown[Franktown.length] = createMarker(new GPoint(-104.76021576,39.43438339),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Cherry Valley Elementary School",'Franktown=' + Franktown.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);
Parker[Parker.length] = createMarker(new GPoint(-104.75586700,39.53542328),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Core Knowledge Charter School",'Parker=' + Parker.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);
Castle_Rock[Castle_Rock.length] = createMarker(new GPoint(-104.87856293,39.47209167),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("D C S Montessori Charter School",'Castle_Rock=' + Castle_Rock.length);
Parker[Parker.length] = createMarker(new GPoint(-104.77082062,39.52215195),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Daniel C Oakes High School",'Parker=' + Parker.length);
Castle_Rock[Castle_Rock.length] = createMarker(new GPoint(-104.85353088,39.36944199),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Daniel C Oakes High School--castle Rock",'Castle_Rock=' + Castle_Rock.length);
Castle_Rock[Castle_Rock.length] = createMarker(new GPoint(-104.85947418,39.39690781),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Douglas County High School",'Castle_Rock=' + Castle_Rock.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);
Lone_Tree[Lone_Tree.length] = createMarker(new GPoint(-104.90102386,39.54600143),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Eagle Ridge Elementary School",'Lone_Tree=' + Lone_Tree.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);
Castle_Rock[Castle_Rock.length] = createMarker(new GPoint(-104.87544250,39.38386154),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Flagstone Elementary School",'Castle_Rock=' + Castle_Rock.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);
Franktown[Franktown.length] = createMarker(new GPoint(-104.70880127,39.35630035),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Franktown Elementary School",'Franktown=' + Franktown.length);
Parker[Parker.length] = createMarker(new GPoint(-104.71534729,39.50170135),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Frontier Valley Elementary School",'Parker=' + Parker.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);
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);
Parker[Parker.length] = createMarker(new GPoint(-104.75708771,39.50431061),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Iron Horse Elementary School",'Parker=' + Parker.length);
Larkspur[Larkspur.length] = createMarker(new GPoint(-104.90564728,39.23212051),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Larkspur Elementary School",'Larkspur=' + Larkspur.length);
Parker[Parker.length] = createMarker(new GPoint(-104.78459930,39.56019974),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Legacy Point Elementary School",'Parker=' + Parker.length);
Castle_Rock[Castle_Rock.length] = createMarker(new GPoint(-104.84279633,39.35900497),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Meadow View Elementary School",'Castle_Rock=' + Castle_Rock.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);
Parker[Parker.length] = createMarker(new GPoint(-104.72796631,39.45489883),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Mountain View Elementary School",'Parker=' + Parker.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);
Parker[Parker.length] = createMarker(new GPoint(-104.75883484,39.46315002),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Northeast Elementary School",'Parker=' + Parker.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);
Parker[Parker.length] = createMarker(new GPoint(-104.80696869,39.52658463),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Pine Grove Elementary School",'Parker=' + Parker.length);
Parker[Parker.length] = createMarker(new GPoint(-104.76572418,39.54408264),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Pine Lane Intermediate School",'Parker=' + Parker.length);
Parker[Parker.length] = createMarker(new GPoint(-104.76828766,39.54105377),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Pine Lane Primary School",'Parker=' + Parker.length);
Parker[Parker.length] = createMarker(new GPoint(-104.73761749,39.51268768),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Pioneer Elementary School",'Parker=' + Parker.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);
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);
Parker[Parker.length] = createMarker(new GPoint(-104.75813293,39.43453979),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Ponderosa High School",'Parker=' + Parker.length);
Parker[Parker.length] = createMarker(new GPoint(-104.79777527,39.51038742),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Prairie Crossing Elementary School",'Parker=' + Parker.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);
Parker[Parker.length] = createMarker(new GPoint(-104.80348969,39.52904129),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Renaissance Charter School",'Parker=' + Parker.length);
Parker[Parker.length] = createMarker(new GPoint(-104.79684448,39.53719711),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Renaissance Expedition Learn Outward Bound School",'Parker=' + Parker.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);
Castle_Rock[Castle_Rock.length] = createMarker(new GPoint(-104.81445312,39.37213898),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Rock Ridge Elementary School",'Castle_Rock=' + Castle_Rock.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);
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);
Parker[Parker.length] = createMarker(new GPoint(-104.73977200,39.43159200),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Sagewood Middle School",'Parker=' + Parker.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);
Sedalia[Sedalia.length] = createMarker(new GPoint(-104.96939087,39.43692017),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Sedalia Elementary School",'Sedalia=' + Sedalia.length);
Parker[Parker.length] = createMarker(new GPoint(-104.76324463,39.54409027),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Sierra Middle School",'Parker=' + Parker.length);
Castle_Rock[Castle_Rock.length] = createMarker(new GPoint(-104.91322600,39.39294400),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Soaring Hawk Elementary School",'Castle_Rock=' + Castle_Rock.length);
Castle_Rock[Castle_Rock.length] = createMarker(new GPoint(-104.84489441,39.37003326),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("South Street Elementary School",'Castle_Rock=' + Castle_Rock.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);
Castle_Rock[Castle_Rock.length] = createMarker(new GPoint(-104.87544250,39.38386154),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Timber Trail Elementary School",'Castle_Rock=' + Castle_Rock.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);
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);
} // 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(Castle_Rock);
map.removeOverlays(Franktown);
map.removeOverlays(Highlands_Ranch);
map.removeOverlays(Larkspur);
map.removeOverlays(Littleton);
map.removeOverlays(Lone_Tree);
map.removeOverlays(Parker);
map.removeOverlays(Sedalia);
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(Castle_Rock);map.removeOverlays(Castle_Rock);
map.removeOverlays(Franktown);
map.removeOverlays(Highlands_Ranch);
map.removeOverlays(Larkspur);
map.removeOverlays(Littleton);
map.removeOverlays(Lone_Tree);
map.removeOverlays(Parker);
map.removeOverlays(Sedalia);
map.addOverlays(Castle_Rock);
centerByArray(Castle_Rock, false, false);
cntMarker += Castle_Rock.length;
map.addOverlays(Franktown);
centerByArray(Franktown, false, false);
cntMarker += Franktown.length;
map.addOverlays(Highlands_Ranch);
centerByArray(Highlands_Ranch, false, false);
cntMarker += Highlands_Ranch.length;
map.addOverlays(Larkspur);
centerByArray(Larkspur, false, false);
cntMarker += Larkspur.length;
map.addOverlays(Littleton);
centerByArray(Littleton, false, false);
cntMarker += Littleton.length;
map.addOverlays(Lone_Tree);
centerByArray(Lone_Tree, false, false);
cntMarker += Lone_Tree.length;
map.addOverlays(Parker);
centerByArray(Parker, false, false);
cntMarker += Parker.length;
map.addOverlays(Sedalia);
centerByArray(Sedalia, false, false);
cntMarker += Sedalia.length;
centerByArray(Castle_Rock,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');
}
}