function addMarkers() { mySelect = document.getElementById('selection'); Montgomery = [];Mount_Vernon = [];Mountain_Brook = [];Demopolis = [];Mobile = [];Chickasaw = [];Decatur = [];Hoover = [];Birmingham = [];Huntsville = [];Cullman = [];Auburn = [];Lockhart = [];mySelect.options[mySelect.options.length] = new Option("Auburn schools",'all=Auburn'); mySelect.options[mySelect.options.length] = new Option("Birmingham schools",'all=Birmingham'); mySelect.options[mySelect.options.length] = new Option("Chickasaw schools",'all=Chickasaw'); mySelect.options[mySelect.options.length] = new Option("Cullman schools",'all=Cullman'); mySelect.options[mySelect.options.length] = new Option("Decatur schools",'all=Decatur'); mySelect.options[mySelect.options.length] = new Option("Demopolis schools",'all=Demopolis'); mySelect.options[mySelect.options.length] = new Option("Hoover schools",'all=Hoover'); mySelect.options[mySelect.options.length] = new Option("Huntsville schools",'all=Huntsville'); mySelect.options[mySelect.options.length] = new Option("Lockhart schools",'all=Lockhart'); mySelect.options[mySelect.options.length] = new Option("Mobile schools",'all=Mobile'); mySelect.options[mySelect.options.length] = new Option("Montgomery schools",'all=Montgomery'); mySelect.options[mySelect.options.length] = new Option("Mount Vernon schools",'all=Mount_Vernon'); mySelect.options[mySelect.options.length] = new Option("Mountain Brook schools",'all=Mountain_Brook'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Montgomery[Montgomery.length] = createMarker(new GPoint(-86.21886444,32.31903839),"
",iconGr); mySelect.options[mySelect.options.length] = new Option("Brewbaker Technology Magnet High School",'Montgomery=' + Montgomery.length); Mount_Vernon[Mount_Vernon.length] = createMarker(new GPoint(-88.11427307,31.11354637),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Calcedeaver Elementary School",'Mount_Vernon=' + Mount_Vernon.length); Mountain_Brook[Mountain_Brook.length] = createMarker(new GPoint(-86.71823120,33.51046753),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Cherokee Bend Elementary School",'Mountain_Brook=' + Mountain_Brook.length); Demopolis[Demopolis.length] = createMarker(new GPoint(-87.83670807,32.51723099),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Demopolis High School",'Demopolis=' + Demopolis.length); Montgomery[Montgomery.length] = createMarker(new GPoint(-86.28683472,32.36141205),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Forest Avenue Elementary School",'Montgomery=' + Montgomery.length); Mobile[Mobile.length] = createMarker(new GPoint(-88.07649994,30.66625786),"",iconRd); mySelect.options[mySelect.options.length] = new Option("George Hall Elementary School",'Mobile=' + Mobile.length); Chickasaw[Chickasaw.length] = createMarker(new GPoint(-88.08004761,30.75653839),"",iconBl); mySelect.options[mySelect.options.length] = new Option("K J Clark Middle School",'Chickasaw=' + Chickasaw.length); Decatur[Decatur.length] = createMarker(new GPoint(-86.99121857,34.62019730),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Leon Sheffield Elementary School",'Decatur=' + Decatur.length); Mobile[Mobile.length] = createMarker(new GPoint(-88.13539886,30.69968987),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Mary B Austin Elementary School",'Mobile=' + Mobile.length); Hoover[Hoover.length] = createMarker(new GPoint(-86.72810364,33.38628006),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Spain Park High School",'Hoover=' + Hoover.length); Birmingham[Birmingham.length] = createMarker(new GPoint(-86.78070831,33.42224884),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Vestavia Hills High School",'Birmingham=' + Birmingham.length); Huntsville[Huntsville.length] = createMarker(new GPoint(-86.53963470,34.65927124),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Virgil Grissom High School",'Huntsville=' + Huntsville.length); Cullman[Cullman.length] = createMarker(new GPoint(-86.85662842,34.17812347),"",iconRd); mySelect.options[mySelect.options.length] = new Option("West Elementary School",'Cullman=' + Cullman.length); Auburn[Auburn.length] = createMarker(new GPoint(-85.47283936,32.58867264),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Wrights Mill Road Elementary School",'Auburn=' + Auburn.length); Lockhart[Lockhart.length] = createMarker(new GPoint(-86.34970093,31.01020050),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Ws Harlan Elementary School",'Lockhart=' + Lockhart.length); map.removeOverlays(Auburn); map.removeOverlays(Birmingham); map.removeOverlays(Chickasaw); map.removeOverlays(Cullman); map.removeOverlays(Decatur); map.removeOverlays(Demopolis); map.removeOverlays(Hoover); map.removeOverlays(Huntsville); map.removeOverlays(Lockhart); map.removeOverlays(Mobile); map.removeOverlays(Montgomery); map.removeOverlays(Mount_Vernon); map.removeOverlays(Mountain_Brook); setTimeout(function(){map.addOverlays(Auburn)},1000); setTimeout(function(){map.addOverlays(Birmingham)},1000); setTimeout(function(){map.addOverlays(Chickasaw)},1000); setTimeout(function(){map.addOverlays(Cullman)},1000); setTimeout(function(){map.addOverlays(Decatur)},1000); setTimeout(function(){map.addOverlays(Demopolis)},1000); setTimeout(function(){map.addOverlays(Hoover)},1000); setTimeout(function(){map.addOverlays(Huntsville)},1000); setTimeout(function(){map.addOverlays(Lockhart)},1000); setTimeout(function(){map.addOverlays(Mobile)},1000); setTimeout(function(){map.addOverlays(Montgomery)},1000); setTimeout(function(){map.addOverlays(Mount_Vernon)},1000); setTimeout(function(){map.addOverlays(Mountain_Brook)},1000); maxLng = -85.47283936; maxLat = 34.65927124; minLng = -88.13539886; minLat = 30.66625786; 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(Auburn); map.removeOverlays(Birmingham); map.removeOverlays(Chickasaw); map.removeOverlays(Cullman); map.removeOverlays(Decatur); map.removeOverlays(Demopolis); map.removeOverlays(Hoover); map.removeOverlays(Huntsville); map.removeOverlays(Lockhart); map.removeOverlays(Mobile); map.removeOverlays(Montgomery); map.removeOverlays(Mount_Vernon); map.removeOverlays(Mountain_Brook); 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(Montgomery);map.removeOverlays(Auburn); map.removeOverlays(Birmingham); map.removeOverlays(Chickasaw); map.removeOverlays(Cullman); map.removeOverlays(Decatur); map.removeOverlays(Demopolis); map.removeOverlays(Hoover); map.removeOverlays(Huntsville); map.removeOverlays(Lockhart); map.removeOverlays(Mobile); map.removeOverlays(Montgomery); map.removeOverlays(Mount_Vernon); map.removeOverlays(Mountain_Brook); map.addOverlays(Auburn); centerByArray(Auburn, false, false); cntMarker += Auburn.length; map.addOverlays(Birmingham); centerByArray(Birmingham, false, false); cntMarker += Birmingham.length; map.addOverlays(Chickasaw); centerByArray(Chickasaw, false, false); cntMarker += Chickasaw.length; map.addOverlays(Cullman); centerByArray(Cullman, false, false); cntMarker += Cullman.length; map.addOverlays(Decatur); centerByArray(Decatur, false, false); cntMarker += Decatur.length; map.addOverlays(Demopolis); centerByArray(Demopolis, false, false); cntMarker += Demopolis.length; map.addOverlays(Hoover); centerByArray(Hoover, false, false); cntMarker += Hoover.length; map.addOverlays(Huntsville); centerByArray(Huntsville, false, false); cntMarker += Huntsville.length; map.addOverlays(Lockhart); centerByArray(Lockhart, false, false); cntMarker += Lockhart.length; map.addOverlays(Mobile); centerByArray(Mobile, false, false); cntMarker += Mobile.length; map.addOverlays(Montgomery); centerByArray(Montgomery, false, false); cntMarker += Montgomery.length; map.addOverlays(Mount_Vernon); centerByArray(Mount_Vernon, false, false); cntMarker += Mount_Vernon.length; map.addOverlays(Mountain_Brook); centerByArray(Mountain_Brook, false, false); cntMarker += Mountain_Brook.length; centerByArray(Montgomery,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///1333,458,28,648,1038,918,80,380,448,372,965,886,1008,894,1066,/all'); } }