function addMarkers() { mySelect = document.getElementById('selection'); Alpena = [];Bergman = [];Harrison = [];Lead_Hill = [];Omaha = [];Valley_Springs = [];mySelect.options[mySelect.options.length] = new Option("Alpena schools",'all=Alpena'); mySelect.options[mySelect.options.length] = new Option("Bergman schools",'all=Bergman'); mySelect.options[mySelect.options.length] = new Option("Harrison schools",'all=Harrison'); mySelect.options[mySelect.options.length] = new Option("Lead Hill schools",'all=Lead_Hill'); mySelect.options[mySelect.options.length] = new Option("Omaha schools",'all=Omaha'); mySelect.options[mySelect.options.length] = new Option("Valley Springs schools",'all=Valley_Springs'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Alpena[Alpena.length] = createMarker(new GPoint(-93.28690338,36.29550171),"
",iconRd); mySelect.options[mySelect.options.length] = new Option("Alpena Elementary School",'Alpena=' + Alpena.length); Alpena[Alpena.length] = createMarker(new GPoint(-93.28690338,36.29550171),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Alpena High School",'Alpena=' + Alpena.length); Bergman[Bergman.length] = createMarker(new GPoint(-93.00688934,36.31602859),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Bergman Elementary School",'Bergman=' + Bergman.length); Bergman[Bergman.length] = createMarker(new GPoint(-93.00688934,36.31602859),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Bergman High School",'Bergman=' + Bergman.length); Bergman[Bergman.length] = createMarker(new GPoint(-93.01505400,36.31273800),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Bergman Middle School",'Bergman=' + Bergman.length); Harrison[Harrison.length] = createMarker(new GPoint(-93.11247253,36.22957993),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Central Elementary School",'Harrison=' + Harrison.length); Harrison[Harrison.length] = createMarker(new GPoint(-93.10206604,36.23483658),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Eagle Heights Elementary School",'Harrison=' + Harrison.length); Harrison[Harrison.length] = createMarker(new GPoint(-93.12242889,36.21879959),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Forest Heights Elementary School",'Harrison=' + Harrison.length); Harrison[Harrison.length] = createMarker(new GPoint(-93.13402557,36.24645233),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Harrison High School",'Harrison=' + Harrison.length); Harrison[Harrison.length] = createMarker(new GPoint(-93.11103058,36.22520828),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Harrison Junior High School",'Harrison=' + Harrison.length); Lead_Hill[Lead_Hill.length] = createMarker(new GPoint(-92.92890167,36.44079971),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Lead Hill Elementary School",'Lead_Hill=' + Lead_Hill.length); Lead_Hill[Lead_Hill.length] = createMarker(new GPoint(-92.92890167,36.44079971),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Lead Hill High School",'Lead_Hill=' + Lead_Hill.length); Harrison[Harrison.length] = createMarker(new GPoint(-93.09089900,36.22148900),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Northark Technical Center",'Harrison=' + Harrison.length); Omaha[Omaha.length] = createMarker(new GPoint(-93.19625092,36.44889450),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Omaha Elementary School",'Omaha=' + Omaha.length); Omaha[Omaha.length] = createMarker(new GPoint(-93.19625092,36.44889450),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Omaha High School",'Omaha=' + Omaha.length); Omaha[Omaha.length] = createMarker(new GPoint(-93.19625092,36.44889450),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Omaha Middle School",'Omaha=' + Omaha.length); Harrison[Harrison.length] = createMarker(new GPoint(-93.12015533,36.23909760),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Skyline Heights Elementary School",'Harrison=' + Harrison.length); Valley_Springs[Valley_Springs.length] = createMarker(new GPoint(-92.98359680,36.14509964),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Valley Springs Elementary School",'Valley_Springs=' + Valley_Springs.length); Valley_Springs[Valley_Springs.length] = createMarker(new GPoint(-92.98359680,36.14509964),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Valley Springs High School",'Valley_Springs=' + Valley_Springs.length); Valley_Springs[Valley_Springs.length] = createMarker(new GPoint(-92.75499725,36.11940002),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Valley Springs Middle School",'Valley_Springs=' + Valley_Springs.length); Harrison[Harrison.length] = createMarker(new GPoint(-93.09947205,36.21886444),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Woodland Heights Elementary School",'Harrison=' + Harrison.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,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(Alpena); map.removeOverlays(Bergman); map.removeOverlays(Harrison); map.removeOverlays(Lead_Hill); map.removeOverlays(Omaha); map.removeOverlays(Valley_Springs); 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(Alpena);map.removeOverlays(Alpena); map.removeOverlays(Bergman); map.removeOverlays(Harrison); map.removeOverlays(Lead_Hill); map.removeOverlays(Omaha); map.removeOverlays(Valley_Springs); map.addOverlays(Alpena); centerByArray(Alpena, false, false); cntMarker += Alpena.length; map.addOverlays(Bergman); centerByArray(Bergman, false, false); cntMarker += Bergman.length; map.addOverlays(Harrison); centerByArray(Harrison, false, false); cntMarker += Harrison.length; map.addOverlays(Lead_Hill); centerByArray(Lead_Hill, false, false); cntMarker += Lead_Hill.length; map.addOverlays(Omaha); centerByArray(Omaha, false, false); cntMarker += Omaha.length; map.addOverlays(Valley_Springs); centerByArray(Valley_Springs, false, false); cntMarker += Valley_Springs.length; centerByArray(Alpena,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'); } }