function addMarkers()
{
mySelect = document.getElementById('selection');
Scottsdale = [];Scottsdale[Scottsdale.length] = createMarker(new GPoint(-111.81313324,33.59562683),"
",iconRd);
mySelect.options[mySelect.options.length] = new Option("Anasazi Elementary School",'Scottsdale=' + Scottsdale.length);
Scottsdale[Scottsdale.length] = createMarker(new GPoint(-111.94786072,33.49964905),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Arcadia Neighborhood Learning Center",'Scottsdale=' + Scottsdale.length);
Scottsdale[Scottsdale.length] = createMarker(new GPoint(-111.86637000,33.60963200),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Aztec Elementary School",'Scottsdale=' + Scottsdale.length);
Scottsdale[Scottsdale.length] = createMarker(new GPoint(-111.89469910,33.56549835),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Basis Scottsdale",'Scottsdale=' + Scottsdale.length);
Scottsdale[Scottsdale.length] = createMarker(new GPoint(-111.92539215,33.59313965),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Casy Country Day School #1",'Scottsdale=' + Scottsdale.length);
Scottsdale[Scottsdale.length] = createMarker(new GPoint(-111.92564392,33.59354019),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Casy Country Day School #1 (charter)",'Scottsdale=' + Scottsdale.length);
Scottsdale[Scottsdale.length] = createMarker(new GPoint(-111.88880157,33.60729980),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Casy Country Day School #2",'Scottsdale=' + Scottsdale.length);
Scottsdale[Scottsdale.length] = createMarker(new GPoint(-111.88113403,33.59753799),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Casy Country Day School #2 (charter)",'Scottsdale=' + Scottsdale.length);
Scottsdale[Scottsdale.length] = createMarker(new GPoint(-111.92563000,33.59354400),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Casy South Valley Academy",'Scottsdale=' + Scottsdale.length);
Scottsdale[Scottsdale.length] = createMarker(new GPoint(-111.93215942,33.57836151),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Chaparral High School",'Scottsdale=' + Scottsdale.length);
Scottsdale[Scottsdale.length] = createMarker(new GPoint(-111.84092712,33.58812714),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Cheyenne Traditional Elementary School",'Scottsdale=' + Scottsdale.length);
Scottsdale[Scottsdale.length] = createMarker(new GPoint(-111.92042542,33.46556473),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Classics And Four Arts Academy",'Scottsdale=' + Scottsdale.length);
Scottsdale[Scottsdale.length] = createMarker(new GPoint(-111.89991760,33.57117462),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Cochise Elementary School",'Scottsdale=' + Scottsdale.length);
Scottsdale[Scottsdale.length] = createMarker(new GPoint(-111.93862915,33.58936310),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Cocopah Middle School",'Scottsdale=' + Scottsdale.length);
Scottsdale[Scottsdale.length] = createMarker(new GPoint(-111.96456146,33.64673996),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Copper Canyon Elementary School",'Scottsdale=' + Scottsdale.length);
Scottsdale[Scottsdale.length] = createMarker(new GPoint(-111.86369324,33.66781616),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Copper Ridge Elementary School",'Scottsdale=' + Scottsdale.length);
Scottsdale[Scottsdale.length] = createMarker(new GPoint(-111.86369324,33.66781616),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Copper Ridge Middle School",'Scottsdale=' + Scottsdale.length);
Scottsdale[Scottsdale.length] = createMarker(new GPoint(-111.92173767,33.47574234),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Coronado High School",'Scottsdale=' + Scottsdale.length);
Scottsdale[Scottsdale.length] = createMarker(new GPoint(-111.89771271,33.50919724),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Desert Canyon Elementary School",'Scottsdale=' + Scottsdale.length);
Scottsdale[Scottsdale.length] = createMarker(new GPoint(-111.86080170,33.62781143),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Desert Canyon Middle School",'Scottsdale=' + Scottsdale.length);
Scottsdale[Scottsdale.length] = createMarker(new GPoint(-111.86512756,33.48756790),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Desert Eagle Secondary School",'Scottsdale=' + Scottsdale.length);
Scottsdale[Scottsdale.length] = createMarker(new GPoint(-111.86512756,33.48756790),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Desert Eagle Secondary School (charter)",'Scottsdale=' + Scottsdale.length);
Scottsdale[Scottsdale.length] = createMarker(new GPoint(-111.81015778,33.58946228),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Desert Mountain High School",'Scottsdale=' + Scottsdale.length);
Scottsdale[Scottsdale.length] = createMarker(new GPoint(-111.95349121,33.60433578),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Desert Shadows Elementary School",'Scottsdale=' + Scottsdale.length);
Scottsdale[Scottsdale.length] = createMarker(new GPoint(-111.95458984,33.60438156),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Desert Shadows Middle School",'Scottsdale=' + Scottsdale.length);
Scottsdale[Scottsdale.length] = createMarker(new GPoint(-111.95214081,33.61987305),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Desert Springs Elementary School",'Scottsdale=' + Scottsdale.length);
Scottsdale[Scottsdale.length] = createMarker(new GPoint(-111.91780090,33.46709824),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("East Valley Academy",'Scottsdale=' + Scottsdale.length);
Scottsdale[Scottsdale.length] = createMarker(new GPoint(-111.91809845,33.46689987),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("East Valley Academy (charter)",'Scottsdale=' + Scottsdale.length);
Scottsdale[Scottsdale.length] = createMarker(new GPoint(-111.91780090,33.46709824),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Edupreneurship Student Center (esc) Chandler",'Scottsdale=' + Scottsdale.length);
Scottsdale[Scottsdale.length] = createMarker(new GPoint(-111.89720154,33.46054459),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Edupreneurship Student Center (esc) Phoenix (chart",'Scottsdale=' + Scottsdale.length);
Scottsdale[Scottsdale.length] = createMarker(new GPoint(-111.89753723,33.46104813),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Edupreneurship Student Center (esc) Scottsdale",'Scottsdale=' + Scottsdale.length);
Scottsdale[Scottsdale.length] = createMarker(new GPoint(-111.89720154,33.46054459),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Edupreneurship Student Center (esc) Scottsdale (ch",'Scottsdale=' + Scottsdale.length);
Scottsdale[Scottsdale.length] = createMarker(new GPoint(-111.92173767,33.47578049),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Evit Scottsdale Voc Center",'Scottsdale=' + Scottsdale.length);
Scottsdale[Scottsdale.length] = createMarker(new GPoint(-111.92619324,33.77736282),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Foothills Academy",'Scottsdale=' + Scottsdale.length);
Scottsdale[Scottsdale.length] = createMarker(new GPoint(-111.91902924,33.67576599),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Grayhawk Elementary School",'Scottsdale=' + Scottsdale.length);
Scottsdale[Scottsdale.length] = createMarker(new GPoint(-111.89878845,33.47296143),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Hohokam Elementary School",'Scottsdale=' + Scottsdale.length);
Scottsdale[Scottsdale.length] = createMarker(new GPoint(-111.96013641,33.62576294),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Horizon High School",'Scottsdale=' + Scottsdale.length);
Scottsdale[Scottsdale.length] = createMarker(new GPoint(-111.91780090,33.46709824),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Horizons Back-to-basics Elementary School",'Scottsdale=' + Scottsdale.length);
Scottsdale[Scottsdale.length] = createMarker(new GPoint(-111.89469910,33.56549835),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Kachina Country Day School",'Scottsdale=' + Scottsdale.length);
Scottsdale[Scottsdale.length] = createMarker(new GPoint(-111.87558746,33.52336502),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Kachina Country Day School #2 (kachina School For",'Scottsdale=' + Scottsdale.length);
Scottsdale[Scottsdale.length] = createMarker(new GPoint(-111.85509491,33.57817078),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Laguna Elementary School",'Scottsdale=' + Scottsdale.length);
Scottsdale[Scottsdale.length] = createMarker(new GPoint(-111.95310211,33.61759949),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Liberty Elementary School",'Scottsdale=' + Scottsdale.length);
Scottsdale[Scottsdale.length] = createMarker(new GPoint(-111.80075073,33.58253860),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Mission Montessori Academy",'Scottsdale=' + Scottsdale.length);
Scottsdale[Scottsdale.length] = createMarker(new GPoint(-111.89606476,33.51691437),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Mohave Middle School",'Scottsdale=' + Scottsdale.length);
Scottsdale[Scottsdale.length] = createMarker(new GPoint(-111.91842900,33.46773000),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Montage Academy",'Scottsdale=' + Scottsdale.length);
Scottsdale[Scottsdale.length] = createMarker(new GPoint(-111.93586731,33.48076248),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Montessori Academy",'Scottsdale=' + Scottsdale.length);
Scottsdale[Scottsdale.length] = createMarker(new GPoint(-111.94525146,33.64041138),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Montessori Day Public Schools Chartered - Scottsda",'Scottsdale=' + Scottsdale.length);
Scottsdale[Scottsdale.length] = createMarker(new GPoint(-111.80496216,33.58720016),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Mountainside Middle School",'Scottsdale=' + Scottsdale.length);
Scottsdale[Scottsdale.length] = createMarker(new GPoint(-111.90013123,33.50308228),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Navajo Elementary School",'Scottsdale=' + Scottsdale.length);
Scottsdale[Scottsdale.length] = createMarker(new GPoint(-111.92038727,33.46564484),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("New School For Arts (charter)",'Scottsdale=' + Scottsdale.length);
Scottsdale[Scottsdale.length] = createMarker(new GPoint(-111.94950104,33.63542938),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("North Ranch Elementary School",'Scottsdale=' + Scottsdale.length);
Scottsdale[Scottsdale.length] = createMarker(new GPoint(-111.95310211,33.61759949),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Patriot Academy Soaring Eagles Campus",'Scottsdale=' + Scottsdale.length);
Scottsdale[Scottsdale.length] = createMarker(new GPoint(-111.92144012,33.46316147),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Peoria Horizons Charter School",'Scottsdale=' + Scottsdale.length);
Scottsdale[Scottsdale.length] = createMarker(new GPoint(-111.90145874,33.48773575),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Pima Elementary School",'Scottsdale=' + Scottsdale.length);
Scottsdale[Scottsdale.length] = createMarker(new GPoint(-111.91291046,33.69335556),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Pinnacle Peak Elementary School",'Scottsdale=' + Scottsdale.length);
Scottsdale[Scottsdale.length] = createMarker(new GPoint(-111.90456390,33.52960205),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Pueblo Elementary School",'Scottsdale=' + Scottsdale.length);
Scottsdale[Scottsdale.length] = createMarker(new GPoint(-111.92040253,33.49459839),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Reinvent Ed Inc High School",'Scottsdale=' + Scottsdale.length);
Scottsdale[Scottsdale.length] = createMarker(new GPoint(-111.90456390,33.52728653),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Saguaro High School",'Scottsdale=' + Scottsdale.length);
Scottsdale[Scottsdale.length] = createMarker(new GPoint(-111.86573029,33.46593857),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Salt River Day School",'Scottsdale=' + Scottsdale.length);
Scottsdale[Scottsdale.length] = createMarker(new GPoint(-111.93598175,33.61513519),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Sandpiper Elementary School",'Scottsdale=' + Scottsdale.length);
Scottsdale[Scottsdale.length] = createMarker(new GPoint(-111.92144012,33.46316147),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Scottsdale Horizons Charter School",'Scottsdale=' + Scottsdale.length);
Scottsdale[Scottsdale.length] = createMarker(new GPoint(-111.94346619,33.59320068),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Sequoya Elementary School",'Scottsdale=' + Scottsdale.length);
Scottsdale[Scottsdale.length] = createMarker(new GPoint(-111.89753723,33.46104813),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Sierra Vista Academy",'Scottsdale=' + Scottsdale.length);
Scottsdale[Scottsdale.length] = createMarker(new GPoint(-111.92006683,33.60371017),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Sonoran Sky Elementary School",'Scottsdale=' + Scottsdale.length);
Scottsdale[Scottsdale.length] = createMarker(new GPoint(-111.96540700,33.61215800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Stars Prep Academy - Scottsdale, Inc.",'Scottsdale=' + Scottsdale.length);
Scottsdale[Scottsdale.length] = createMarker(new GPoint(-111.97300720,33.61893845),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Sunrise Middle School",'Scottsdale=' + Scottsdale.length);
Scottsdale[Scottsdale.length] = createMarker(new GPoint(-111.93618774,33.45846176),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Supai Middle School",'Scottsdale=' + Scottsdale.length);
Scottsdale[Scottsdale.length] = createMarker(new GPoint(-111.93459320,33.47286224),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Tonalea Elementary School",'Scottsdale=' + Scottsdale.length);
Scottsdale[Scottsdale.length] = createMarker(new GPoint(-111.93527222,33.51734543),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Villa Montessori - Scottsdale Campus (charter)",'Scottsdale=' + Scottsdale.length);
Scottsdale[Scottsdale.length] = createMarker(new GPoint(-111.91763306,33.45574188),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Yavapai Elementary School",'Scottsdale=' + Scottsdale.length);
Scottsdale[Scottsdale.length] = createMarker(new GPoint(-111.88328552,33.61506653),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Zuni Elementary School",'Scottsdale=' + Scottsdale.length);
maxLng = -111.80075073;
maxLat = 33.77736282;
minLng = -111.97300720;
minLat = 33.45574188;
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(Scottsdale);
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(Scottsdale);map.removeOverlays(Scottsdale);
map.addOverlays(Scottsdale);
centerByArray(Scottsdale, false, false);
cntMarker += Scottsdale.length;
centerByArray(Scottsdale,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');
}
}