function addMarkers() { mySelect = document.getElementById('selection'); Phoenix = [];Pima = [];Tucson = [];Nogales = [];Prescott = [];Holbrook = [];Mesa = [];mySelect.options[mySelect.options.length] = new Option("Holbrook special education schools",'all=Holbrook'); mySelect.options[mySelect.options.length] = new Option("Mesa special education schools",'all=Mesa'); mySelect.options[mySelect.options.length] = new Option("Nogales special education schools",'all=Nogales'); mySelect.options[mySelect.options.length] = new Option("Phoenix special education schools",'all=Phoenix'); mySelect.options[mySelect.options.length] = new Option("Pima special education schools",'all=Pima'); mySelect.options[mySelect.options.length] = new Option("Prescott special education schools",'all=Prescott'); mySelect.options[mySelect.options.length] = new Option("Tucson special education schools",'all=Tucson'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Phoenix[Phoenix.length] = createMarker(new GPoint(-112.05813599,33.38144302),"
Amy L. Houston Academy
7139 S 10th St
Phoenix, AZ 85042

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Amy L. Houston Academy",'Phoenix=' + Phoenix.length); Pima[Pima.length] = createMarker(new GPoint(-109.92459869,32.92610168),"
Brighter Day Preschool
P O Box 488
Pima, AZ 85543

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Brighter Day Preschool",'Pima=' + Pima.length); Pima[Pima.length] = createMarker(new GPoint(-109.90879822,32.94850159),"
Dan Hinton Accommodation School
Po Box 488
Pima, AZ 85543

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Dan Hinton Accommodation School",'Pima=' + Pima.length); Tucson[Tucson.length] = createMarker(new GPoint(-110.95633698,32.21724319),"
Direct Link I Elementary School
445 S. Park
Tucson, AZ 85719

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Direct Link I Elementary School",'Tucson=' + Tucson.length); Phoenix[Phoenix.length] = createMarker(new GPoint(-112.20336151,33.49232101),"
Flor Del Sol Elementary School
3818 N. 67th Ave
Phoenix, AZ 85033

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Flor Del Sol Elementary School",'Phoenix=' + Phoenix.length); Phoenix[Phoenix.length] = createMarker(new GPoint(-112.14885712,33.82289886),"
Homebound High School
3535 N 27th Ave
Phoenix, AZ 85017

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Homebound High School",'Phoenix=' + Phoenix.length); Nogales[Nogales.length] = createMarker(new GPoint(-110.94116974,31.34002495),"
Nogales Special Programs
310 W Plum St
Nogales, AZ 85621

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Nogales Special Programs",'Nogales=' + Nogales.length); Phoenix[Phoenix.length] = createMarker(new GPoint(-112.19607544,33.47166443),"
Palm Lane North Elementary School
6339 W Monte Vista Rd
Phoenix, AZ 85035

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Palm Lane North Elementary School",'Phoenix=' + Phoenix.length); Prescott[Prescott.length] = createMarker(new GPoint(-112.47166443,34.54100800),"
Prelude Preschool Handicapped
551 First Street
Prescott, AZ 86301

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Prelude Preschool Handicapped",'Prescott=' + Prescott.length); Holbrook[Holbrook.length] = createMarker(new GPoint(-110.11679840,34.91400146),"
Rainbow Accommodation School
Po Box 668
Holbrook, AZ 86025

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Rainbow Accommodation School",'Holbrook=' + Holbrook.length); Tucson[Tucson.length] = createMarker(new GPoint(-110.96839905,32.27186203),"
Rillito Center
266 E Pastime Road
Tucson, AZ 85705

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Rillito Center",'Tucson=' + Tucson.length); Phoenix[Phoenix.length] = createMarker(new GPoint(-112.06486511,33.39206314),"
Roosevelt Elementary School
6000 South 7th Street
Phoenix, AZ 85040

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Roosevelt Elementary School",'Phoenix=' + Phoenix.length); Mesa[Mesa.length] = createMarker(new GPoint(-111.67053986,33.42983627),"
S H A R P
950 North Sun Valley Blvd.
Mesa, AZ 85207

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("S H A R P",'Mesa=' + Mesa.length); maxLng = -109.90879822; maxLat = 34.91400146; minLng = -112.47166443; minLat = 31.34002495; reCenterMap(); map.removeOverlays(Holbrook); map.removeOverlays(Mesa); map.removeOverlays(Nogales); map.removeOverlays(Phoenix); map.removeOverlays(Pima); map.removeOverlays(Prescott); map.removeOverlays(Tucson); setTimeout(function(){map.addOverlays(Holbrook)},1000); setTimeout(function(){map.addOverlays(Mesa)},1000); setTimeout(function(){map.addOverlays(Nogales)},1000); setTimeout(function(){map.addOverlays(Phoenix)},1000); setTimeout(function(){map.addOverlays(Pima)},1000); setTimeout(function(){map.addOverlays(Prescott)},1000); setTimeout(function(){map.addOverlays(Tucson)},1000); } // 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(Holbrook); map.removeOverlays(Mesa); map.removeOverlays(Nogales); map.removeOverlays(Phoenix); map.removeOverlays(Pima); map.removeOverlays(Prescott); map.removeOverlays(Tucson); 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(Holbrook); map.removeOverlays(Mesa); map.removeOverlays(Nogales); map.removeOverlays(Phoenix); map.removeOverlays(Pima); map.removeOverlays(Prescott); map.removeOverlays(Tucson); map.addOverlays(Holbrook); centerByArray(Holbrook, false, false); cntMarker += Holbrook.length; map.addOverlays(Mesa); centerByArray(Mesa, false, false); cntMarker += Mesa.length; map.addOverlays(Nogales); centerByArray(Nogales, false, false); cntMarker += Nogales.length; map.addOverlays(Phoenix); centerByArray(Phoenix, false, false); cntMarker += Phoenix.length; map.addOverlays(Pima); centerByArray(Pima, false, false); cntMarker += Pima.length; map.addOverlays(Prescott); centerByArray(Prescott, false, false); cntMarker += Prescott.length; map.addOverlays(Tucson); centerByArray(Tucson, false, false); cntMarker += Tucson.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////all'); } }