function addMarkers() { mySelect = document.getElementById('selection'); Gallipolis = [];Bidwell = [];Rio_Grande = [];Crown_City = [];Cheshire = [];Patriot = [];Vinton = [];mySelect.options[mySelect.options.length] = new Option("Bidwell schools",'all=Bidwell'); mySelect.options[mySelect.options.length] = new Option("Cheshire schools",'all=Cheshire'); mySelect.options[mySelect.options.length] = new Option("Crown City schools",'all=Crown_City'); mySelect.options[mySelect.options.length] = new Option("Gallipolis schools",'all=Gallipolis'); mySelect.options[mySelect.options.length] = new Option("Patriot schools",'all=Patriot'); mySelect.options[mySelect.options.length] = new Option("Rio Grande schools",'all=Rio_Grande'); mySelect.options[mySelect.options.length] = new Option("Vinton schools",'all=Vinton'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Gallipolis[Gallipolis.length] = createMarker(new GPoint(-82.18117523,38.90779495),"
",iconRd); mySelect.options[mySelect.options.length] = new Option("Addaville Elementary School",'Gallipolis=' + Gallipolis.length); Bidwell[Bidwell.length] = createMarker(new GPoint(-82.27949524,38.91647720),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Bidwell-porter Elementary School",'Bidwell=' + Bidwell.length); Rio_Grande[Rio_Grande.length] = createMarker(new GPoint(-82.38050079,38.88290024),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Buckeye Hills Career Center",'Rio_Grande=' + Rio_Grande.length); Gallipolis[Gallipolis.length] = createMarker(new GPoint(-82.19261169,38.70870972),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Clay Alternative",'Gallipolis=' + Gallipolis.length); Gallipolis[Gallipolis.length] = createMarker(new GPoint(-82.20822906,38.80893326),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Gallia Academy High School",'Gallipolis=' + Gallipolis.length); Gallipolis[Gallipolis.length] = createMarker(new GPoint(-82.26740265,38.80195999),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Green Elementary School",'Gallipolis=' + Gallipolis.length); Crown_City[Crown_City.length] = createMarker(new GPoint(-82.27146149,38.65989304),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Hannan Trace Elementary School",'Crown_City=' + Crown_City.length); Cheshire[Cheshire.length] = createMarker(new GPoint(-82.11966705,38.94895935),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Kyger Creek Middle School",'Cheshire=' + Cheshire.length); Rio_Grande[Rio_Grande.length] = createMarker(new GPoint(-82.38050079,38.88290024),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Rio Grande Elementary School",'Rio_Grande=' + Rio_Grande.length); Cheshire[Cheshire.length] = createMarker(new GPoint(-82.15638733,38.92938232),"",iconGr); mySelect.options[mySelect.options.length] = new Option("River Valley High School",'Cheshire=' + Cheshire.length); Crown_City[Crown_City.length] = createMarker(new GPoint(-82.27600098,38.66126251),"",iconGr); mySelect.options[mySelect.options.length] = new Option("South Gallia High School",'Crown_City=' + Crown_City.length); Patriot[Patriot.length] = createMarker(new GPoint(-82.40149689,38.82194519),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Southwestern Elementary School",'Patriot=' + Patriot.length); Vinton[Vinton.length] = createMarker(new GPoint(-82.34918213,38.97634125),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Vinton Elementary School",'Vinton=' + Vinton.length); Gallipolis[Gallipolis.length] = createMarker(new GPoint(-82.20547485,38.81072617),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Washington Elementary School",'Gallipolis=' + Gallipolis.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(Bidwell); map.removeOverlays(Cheshire); map.removeOverlays(Crown_City); map.removeOverlays(Gallipolis); map.removeOverlays(Patriot); map.removeOverlays(Rio_Grande); map.removeOverlays(Vinton); 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(Gallipolis);map.removeOverlays(Bidwell); map.removeOverlays(Cheshire); map.removeOverlays(Crown_City); map.removeOverlays(Gallipolis); map.removeOverlays(Patriot); map.removeOverlays(Rio_Grande); map.removeOverlays(Vinton); map.addOverlays(Bidwell); centerByArray(Bidwell, false, false); cntMarker += Bidwell.length; map.addOverlays(Cheshire); centerByArray(Cheshire, false, false); cntMarker += Cheshire.length; map.addOverlays(Crown_City); centerByArray(Crown_City, false, false); cntMarker += Crown_City.length; map.addOverlays(Gallipolis); centerByArray(Gallipolis, false, false); cntMarker += Gallipolis.length; map.addOverlays(Patriot); centerByArray(Patriot, false, false); cntMarker += Patriot.length; map.addOverlays(Rio_Grande); centerByArray(Rio_Grande, false, false); cntMarker += Rio_Grande.length; map.addOverlays(Vinton); centerByArray(Vinton, false, false); cntMarker += Vinton.length; centerByArray(Gallipolis,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'); } }