function addMarkers(){ mySelect = document.getElementById('selection'); Phoenix = [];Tucson = [];Scottsdale = [];Mayer = [];Paradise_Valley = [];Wickenburg = [];mySelect.options[mySelect.options.length] = new Option("Mayer schools",'all=Mayer'); mySelect.options[mySelect.options.length] = new Option("Paradise Valley schools",'all=Paradise_Valley'); mySelect.options[mySelect.options.length] = new Option("Phoenix schools",'all=Phoenix'); mySelect.options[mySelect.options.length] = new Option("Scottsdale schools",'all=Scottsdale'); mySelect.options[mySelect.options.length] = new Option("Tucson schools",'all=Tucson'); mySelect.options[mySelect.options.length] = new Option("Wickenburg schools",'all=Wickenburg'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Phoenix[Phoenix.length] = createMarker(new GPoint(-112.07384000,33.52955100),"
All Saints Episcopal Day School
6300 N Central Avenue
Phoenix, AZ 85012
Co-ed school, PK-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("All Saints Episcopal Day School",'Phoenix=' + Phoenix.length); Tucson[Tucson.length] = createMarker(new GPoint(-110.87526100,32.26496900),"
Castlehill Country Day School
3225 N Craycroft Road
Tucson, AZ 85712
Co-ed school, PK-5
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Castlehill Country Day School",'Tucson=' + Tucson.length); Tucson[Tucson.length] = createMarker(new GPoint(-110.81388400,32.30155100),"
Fenster School
8500 E Ocotillo Drive
Tucson, AZ 85750
Co-ed school, 9-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Fenster School",'Tucson=' + Tucson.length); Tucson[Tucson.length] = createMarker(new GPoint(-111.03723700,32.31586400),"
Green Fields Country Day School
6000 N Camino De La Tierra
Tucson, AZ 85741
Co-ed school, K-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Green Fields Country Day School",'Tucson=' + Tucson.length); Phoenix[Phoenix.length] = createMarker(new GPoint(-111.98074600,33.62054600),"
Jess Schwartz College Prep: The Jewish Community's High School
4645 East Marilyn Road
Phoenix, AZ 85032
Co-ed school, 9-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Jess Schwartz College Prep: The Jewish Community's High School",'Phoenix=' + Phoenix.length); Scottsdale[Scottsdale.length] = createMarker(new GPoint(-111.92565000,33.60173600),"
The King David School
12753 N Scottsdale Road
Scottsdale, AZ 85254
Co-ed school, K-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("The King David School",'Scottsdale=' + Scottsdale.length); Scottsdale[Scottsdale.length] = createMarker(new GPoint(-111.91398600,33.46316300),"
New Way Learning Academy
1300 N 77th Street
Scottsdale, AZ 85257
Co-ed school, K-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("New Way Learning Academy",'Scottsdale=' + Scottsdale.length); Mayer[Mayer.length] = createMarker(new GPoint(-112.15059200,34.34842300),"
The Orme School Of Arizona
Hc 63 Box 3040 1000 Orme School Road
Mayer, AZ 86333
Co-ed school, 6-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("The Orme School Of Arizona",'Mayer=' + Mayer.length); Paradise_Valley[Paradise_Valley.length] = createMarker(new GPoint(-111.99745200,33.51710000),"
Phoenix Country Day School
3901 E. Stanford Dr.
Paradise Valley, AZ 85253
Co-ed school, PK-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Phoenix Country Day School",'Paradise_Valley=' + Paradise_Valley.length); Phoenix[Phoenix.length] = createMarker(new GPoint(-112.02443400,33.48752200),"
St. Paul's Academy
2645 E Osborn Rd
Phoenix, AZ 85016
All-boys school, 8-12
[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("St. Paul's Academy",'Phoenix=' + Phoenix.length); Paradise_Valley[Paradise_Valley.length] = createMarker(new GPoint(-111.97769300,33.56827600),"
Tesseract School
4800 E Doubletree Ranch Rd
Paradise Valley, AZ 85253
Co-ed school, PK-10
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Tesseract School",'Paradise_Valley=' + Paradise_Valley.length); Tucson[Tucson.length] = createMarker(new GPoint(-110.90995700,32.27567100),"
Tucson Hebrew Academy
3888 E River Rd
Tucson, AZ 85718
Co-ed school, K-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Tucson Hebrew Academy",'Tucson=' + Tucson.length); Wickenburg[Wickenburg.length] = createMarker(new GPoint(-112.73565000,33.96764500),"
Wickenburg Christian Academy
260 W Yavapai Street
Wickenburg, AZ 85390
Co-ed school, PK-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Wickenburg Christian Academy",'Wickenburg=' + Wickenburg.length); map.removeOverlays(Mayer); map.removeOverlays(Paradise_Valley); map.removeOverlays(Phoenix); map.removeOverlays(Scottsdale); map.removeOverlays(Tucson); map.removeOverlays(Wickenburg); setTimeout(function(){map.addOverlays(Mayer)},1000); setTimeout(function(){map.addOverlays(Paradise_Valley)},1000); setTimeout(function(){map.addOverlays(Phoenix)},1000); setTimeout(function(){map.addOverlays(Scottsdale)},1000); setTimeout(function(){map.addOverlays(Tucson)},1000); setTimeout(function(){map.addOverlays(Wickenburg)},1000); maxLng = -110.81388400; maxLat = 34.34842300; minLng = -112.73565000; minLat = 32.26496900; 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,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(Mayer); map.removeOverlays(Paradise_Valley); map.removeOverlays(Phoenix); map.removeOverlays(Scottsdale); map.removeOverlays(Tucson); map.removeOverlays(Wickenburg); 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(Phoenix);map.removeOverlays(Mayer); map.removeOverlays(Paradise_Valley); map.removeOverlays(Phoenix); map.removeOverlays(Scottsdale); map.removeOverlays(Tucson); map.removeOverlays(Wickenburg); map.addOverlays(Mayer); centerByArray(Mayer, false, false); cntMarker += Mayer.length; map.addOverlays(Paradise_Valley); centerByArray(Paradise_Valley, false, false); cntMarker += Paradise_Valley.length; map.addOverlays(Phoenix); centerByArray(Phoenix, false, false); cntMarker += Phoenix.length; map.addOverlays(Scottsdale); centerByArray(Scottsdale, false, false); cntMarker += Scottsdale.length; map.addOverlays(Tucson); centerByArray(Tucson, false, false); cntMarker += Tucson.length; map.addOverlays(Wickenburg); centerByArray(Wickenburg, false, false); cntMarker += Wickenburg.length; centerByArray(Phoenix,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///737,653,30402,35799,717,632,35798,584,737,653,30402,503,686,632,528,584,746,764,/all'); //window.open('/map.php?type=2&schools=737,653,30402,35799,717,632,35798,584,737,653,30402,503,686,632,528,584,746,764,&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; }