function addMarkers(){
mySelect = document.getElementById('selection');
Scottsdale = [];Scottsdale[Scottsdale.length] = createMarker(new GPoint(-111.92623800,33.59927600),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Arizona International Academy",'Scottsdale=' + Scottsdale.length);
Scottsdale[Scottsdale.length] = createMarker(new GPoint(-111.94346500,33.58869400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Blessed Sacrament Preschool And Kindergarten",'Scottsdale=' + Scottsdale.length);
Scottsdale[Scottsdale.length] = createMarker(new GPoint(-111.87333100,33.59083100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Camelback Desert School",'Scottsdale=' + Scottsdale.length);
Scottsdale[Scottsdale.length] = createMarker(new GPoint(-111.94173800,33.58190000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Chaparral Christian School",'Scottsdale=' + Scottsdale.length);
Scottsdale[Scottsdale.length] = createMarker(new GPoint(-111.95307200,33.61169700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Children's Meeting House",'Scottsdale=' + Scottsdale.length);
Scottsdale[Scottsdale.length] = createMarker(new GPoint(-111.92616400,33.60265000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Desert Sky Montessori",'Scottsdale=' + Scottsdale.length);
Scottsdale[Scottsdale.length] = createMarker(new GPoint(-111.94245400,33.60423700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Devereux",'Scottsdale=' + Scottsdale.length);
Scottsdale[Scottsdale.length] = createMarker(new GPoint(-111.87476200,33.60056300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("El Dorado Private School",'Scottsdale=' + Scottsdale.length);
Scottsdale[Scottsdale.length] = createMarker(new GPoint(-111.90906300,33.48359300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("First Impressions Preschool",'Scottsdale=' + Scottsdale.length);
Scottsdale[Scottsdale.length] = createMarker(new GPoint(-111.90170600,33.54318800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Great Beginnings Montessori",'Scottsdale=' + Scottsdale.length);
Scottsdale[Scottsdale.length] = createMarker(new GPoint(-111.92470700,33.56786300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Great Beginnings Montessori Inc",'Scottsdale=' + Scottsdale.length);
Scottsdale[Scottsdale.length] = createMarker(new GPoint(-111.88616500,33.58468100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Hand In Hand Of Scottsdale",'Scottsdale=' + Scottsdale.length);
Scottsdale[Scottsdale.length] = createMarker(new GPoint(-111.91817100,33.48384800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Howard S Gray Education Program",'Scottsdale=' + Scottsdale.length);
Scottsdale[Scottsdale.length] = createMarker(new GPoint(-111.88277400,33.56953000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("International School of Arizona",'Scottsdale=' + Scottsdale.length);
Scottsdale[Scottsdale.length] = createMarker(new GPoint(-111.97632000,33.62633700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Kinder Care Learning Center #1324",'Scottsdale=' + Scottsdale.length);
Scottsdale[Scottsdale.length] = createMarker(new GPoint(-111.92565000,33.60173600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The King David School",'Scottsdale=' + Scottsdale.length);
Scottsdale[Scottsdale.length] = createMarker(new GPoint(-111.89937400,33.61825100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("La Petite Academy",'Scottsdale=' + Scottsdale.length);
Scottsdale[Scottsdale.length] = createMarker(new GPoint(-111.92113900,33.49398000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Marion Burton School",'Scottsdale=' + Scottsdale.length);
Scottsdale[Scottsdale.length] = createMarker(new GPoint(-111.80094000,33.58263700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Mission Montessori On The Desert",'Scottsdale=' + Scottsdale.length);
Scottsdale[Scottsdale.length] = createMarker(new GPoint(-111.91398600,33.46316300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("New Way Learning Academy",'Scottsdale=' + Scottsdale.length);
Scottsdale[Scottsdale.length] = createMarker(new GPoint(-111.87626600,33.63994400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Notre Dame Preparatory School",'Scottsdale=' + Scottsdale.length);
Scottsdale[Scottsdale.length] = createMarker(new GPoint(-111.91733900,33.49201200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Our Lady Of Perpetual Help School",'Scottsdale=' + Scottsdale.length);
Scottsdale[Scottsdale.length] = createMarker(new GPoint(-111.95143400,33.63436200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Pope John Xxiii Catholic School Community",'Scottsdale=' + Scottsdale.length);
Scottsdale[Scottsdale.length] = createMarker(new GPoint(-111.94299600,33.61003700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Rainbow Montessori School",'Scottsdale=' + Scottsdale.length);
Scottsdale[Scottsdale.length] = createMarker(new GPoint(-111.95881500,33.62619900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Rancho Solano Private Schools-greenway Campus",'Scottsdale=' + Scottsdale.length);
Scottsdale[Scottsdale.length] = createMarker(new GPoint(-111.89993400,33.52851700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Maria Goretti Preschool",'Scottsdale=' + Scottsdale.length);
Scottsdale[Scottsdale.length] = createMarker(new GPoint(-111.87814400,33.61201300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Scottsdale Child Care & Learning Center",'Scottsdale=' + Scottsdale.length);
Scottsdale[Scottsdale.length] = createMarker(new GPoint(-111.94201300,33.62614600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Scottsdale Child Care & Learning Center-kierland",'Scottsdale=' + Scottsdale.length);
Scottsdale[Scottsdale.length] = createMarker(new GPoint(-111.87434300,33.62019400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Scottsdale School Inc",'Scottsdale=' + Scottsdale.length);
Scottsdale[Scottsdale.length] = createMarker(new GPoint(-111.91769800,33.49586100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Scottsdale United Methodist Co Operative Preschool and Kindergarten",'Scottsdale=' + Scottsdale.length);
Scottsdale[Scottsdale.length] = createMarker(new GPoint(-111.87428800,33.58273700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Shep. Of The Desert Luth School",'Scottsdale=' + Scottsdale.length);
Scottsdale[Scottsdale.length] = createMarker(new GPoint(-111.89320600,33.58596300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Spatula Soup/the Right Track",'Scottsdale=' + Scottsdale.length);
Scottsdale[Scottsdale.length] = createMarker(new GPoint(-111.91009200,33.46056300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Daniel The Prophet School",'Scottsdale=' + Scottsdale.length);
Scottsdale[Scottsdale.length] = createMarker(new GPoint(-111.92087300,33.60770000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Thunderbird Adventist Academy",'Scottsdale=' + Scottsdale.length);
Scottsdale[Scottsdale.length] = createMarker(new GPoint(-111.92053200,33.60771600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Thunderbird Christian Elementary School",'Scottsdale=' + Scottsdale.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,11);
/*
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');
//window.open('/map.php?type=1&schools=&school_level=&radius=&zipcode=&school_type_search=&school_type_code=');
}
}
function createMarker(point, label, icon)
{
var marker = new GMarker(point, icon);
var html = label;
GEvent.addListener(marker, "click", function() {
marker.openInfoWindowHtml(html);
});
return marker;
}