function addMarkers(){ mySelect = document.getElementById('selection'); Phoenix = [];Peoria = [];Whiteriver = [];Tempe = [];Glendale = [];Flagstaff = [];Peridot = [];Mesa = [];Tucson = [];Goodyear = [];mySelect.options[mySelect.options.length] = new Option("Flagstaff schools",'all=Flagstaff'); mySelect.options[mySelect.options.length] = new Option("Glendale schools",'all=Glendale'); mySelect.options[mySelect.options.length] = new Option("Goodyear schools",'all=Goodyear'); mySelect.options[mySelect.options.length] = new Option("Mesa schools",'all=Mesa'); mySelect.options[mySelect.options.length] = new Option("Peoria schools",'all=Peoria'); mySelect.options[mySelect.options.length] = new Option("Peridot schools",'all=Peridot'); mySelect.options[mySelect.options.length] = new Option("Phoenix schools",'all=Phoenix'); mySelect.options[mySelect.options.length] = new Option("Tempe schools",'all=Tempe'); mySelect.options[mySelect.options.length] = new Option("Tucson schools",'all=Tucson'); mySelect.options[mySelect.options.length] = new Option("Whiteriver schools",'all=Whiteriver'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Phoenix[Phoenix.length] = createMarker(new GPoint(-112.11652800,33.39366700),"
Arizona Lutheran Academy
6036 S 27th Avenue
Phoenix, AZ 85041
Co-ed school, 9-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Arizona Lutheran Academy",'Phoenix=' + Phoenix.length); Peoria[Peoria.length] = createMarker(new GPoint(-112.28148900,33.72468000),"
Cross of Glory Lutheran School
10111 W. Jomax. Rd.
Peoria, AZ 85383
Co-ed school, PK-4
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Cross of Glory Lutheran School",'Peoria=' + Peoria.length); Whiteriver[Whiteriver.length] = createMarker(new GPoint(-109.96870900,33.83890100),"
East Fork Lutheran School
PO Box 489
Whiteriver, AZ 85941
Co-ed school, K-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("East Fork Lutheran School",'Whiteriver=' + Whiteriver.length); Tempe[Tempe.length] = createMarker(new GPoint(-111.94908300,33.39269600),"
Emmanuel Lutheran School
715 W Southern Avenue
Tempe, AZ 85282
Co-ed school, PK-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Emmanuel Lutheran School",'Tempe=' + Tempe.length); Phoenix[Phoenix.length] = createMarker(new GPoint(-112.14167400,33.60346300),"
Emmaus Lutheran School
3841 W Sweetwater Avenue
Phoenix, AZ 85029
Co-ed school, PK-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Emmaus Lutheran School",'Phoenix=' + Phoenix.length); Phoenix[Phoenix.length] = createMarker(new GPoint(-112.08326400,33.48319700),"
Good Shepherd Lutheran School
3040 N 7th Avenue
Phoenix, AZ 85013
Co-ed school, 1-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Good Shepherd Lutheran School",'Phoenix=' + Phoenix.length); Glendale[Glendale.length] = createMarker(new GPoint(-112.18008300,33.54110100),"
Grace Lutheran School
5600 W Palmaire Avenue
Glendale, AZ 85301
Co-ed school, PK-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Grace Lutheran School",'Glendale=' + Glendale.length); Flagstaff[Flagstaff.length] = createMarker(new GPoint(-111.65776700,35.22515200),"
Mt Calvary Lutheran School
2605 N Fort Valley Road
Flagstaff, AZ 86001
Co-ed school, PK-7
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Mt Calvary Lutheran School",'Flagstaff=' + Flagstaff.length); Peridot[Peridot.length] = createMarker(new GPoint(-110.35090000,33.63090000),"
Peridot Lutheran Elementary School
Po Box 118
Peridot, AZ 85542
Co-ed school, K-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Peridot Lutheran Elementary School",'Peridot=' + Peridot.length); Mesa[Mesa.length] = createMarker(new GPoint(-111.75972700,33.42258300),"
Pilgrim Lutheran School
3257 E University Drive
Mesa, AZ 85213
Co-ed school, PK-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Pilgrim Lutheran School",'Mesa=' + Mesa.length); Tucson[Tucson.length] = createMarker(new GPoint(-111.12885200,32.36582600),"
Redeemer Lutheran School
8845 N Silverbell Rd
Tucson, AZ 85743
Co-ed school, PK-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Redeemer Lutheran School",'Tucson=' + Tucson.length); Goodyear[Goodyear.length] = createMarker(new GPoint(-112.40863200,33.45021200),"
St Thomas Lutheran School
16260 W Van Buren Street
Goodyear, AZ 85338
Co-ed school, PK-PK
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("St Thomas Lutheran School",'Goodyear=' + Goodyear.length); map.removeOverlays(Flagstaff); map.removeOverlays(Glendale); map.removeOverlays(Goodyear); map.removeOverlays(Mesa); map.removeOverlays(Peoria); map.removeOverlays(Peridot); map.removeOverlays(Phoenix); map.removeOverlays(Tempe); map.removeOverlays(Tucson); map.removeOverlays(Whiteriver); setTimeout(function(){map.addOverlays(Flagstaff)},1000); setTimeout(function(){map.addOverlays(Glendale)},1000); setTimeout(function(){map.addOverlays(Goodyear)},1000); setTimeout(function(){map.addOverlays(Mesa)},1000); setTimeout(function(){map.addOverlays(Peoria)},1000); setTimeout(function(){map.addOverlays(Peridot)},1000); setTimeout(function(){map.addOverlays(Phoenix)},1000); setTimeout(function(){map.addOverlays(Tempe)},1000); setTimeout(function(){map.addOverlays(Tucson)},1000); setTimeout(function(){map.addOverlays(Whiteriver)},1000); maxLng = -109.96870900; maxLat = 35.22515200; minLng = -112.40863200; minLat = 32.36582600; 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(Flagstaff); map.removeOverlays(Glendale); map.removeOverlays(Goodyear); map.removeOverlays(Mesa); map.removeOverlays(Peoria); map.removeOverlays(Peridot); map.removeOverlays(Phoenix); map.removeOverlays(Tempe); map.removeOverlays(Tucson); map.removeOverlays(Whiteriver); 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(Flagstaff); map.removeOverlays(Glendale); map.removeOverlays(Goodyear); map.removeOverlays(Mesa); map.removeOverlays(Peoria); map.removeOverlays(Peridot); map.removeOverlays(Phoenix); map.removeOverlays(Tempe); map.removeOverlays(Tucson); map.removeOverlays(Whiteriver); map.addOverlays(Flagstaff); centerByArray(Flagstaff, false, false); cntMarker += Flagstaff.length; map.addOverlays(Glendale); centerByArray(Glendale, false, false); cntMarker += Glendale.length; map.addOverlays(Goodyear); centerByArray(Goodyear, false, false); cntMarker += Goodyear.length; map.addOverlays(Mesa); centerByArray(Mesa, false, false); cntMarker += Mesa.length; map.addOverlays(Peoria); centerByArray(Peoria, false, false); cntMarker += Peoria.length; map.addOverlays(Peridot); centerByArray(Peridot, false, false); cntMarker += Peridot.length; map.addOverlays(Phoenix); centerByArray(Phoenix, false, false); cntMarker += Phoenix.length; map.addOverlays(Tempe); centerByArray(Tempe, false, false); cntMarker += Tempe.length; map.addOverlays(Tucson); centerByArray(Tucson, false, false); cntMarker += Tucson.length; map.addOverlays(Whiteriver); centerByArray(Whiteriver, false, false); cntMarker += Whiteriver.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///510,627,582,32027,657,30511,648,560,575,559,669,557,/all'); //window.open('/map.php?type=2&schools=510,627,582,32027,657,30511,648,560,575,559,669,557,&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; }