function addMarkers() { mySelect = document.getElementById('selection'); Bowerston = [];Cadiz = [];Hopedale = [];Jewett = [];Scio = [];Freeport = [];mySelect.options[mySelect.options.length] = new Option("Bowerston schools",'all=Bowerston'); mySelect.options[mySelect.options.length] = new Option("Cadiz schools",'all=Cadiz'); mySelect.options[mySelect.options.length] = new Option("Freeport schools",'all=Freeport'); mySelect.options[mySelect.options.length] = new Option("Hopedale schools",'all=Hopedale'); mySelect.options[mySelect.options.length] = new Option("Jewett schools",'all=Jewett'); mySelect.options[mySelect.options.length] = new Option("Scio schools",'all=Scio'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Bowerston[Bowerston.length] = createMarker(new GPoint(-81.18246460,40.42316055),"
Bowerston Elementary School
600 Main St
Bowerston, OH 44695

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Bowerston Elementary School",'Bowerston=' + Bowerston.length); Cadiz[Cadiz.length] = createMarker(new GPoint(-80.99899292,40.28933334),"
Harrison Career Center
82500 Cadiz Jewett Rd
Cadiz, OH 43907

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Harrison Career Center",'Cadiz=' + Cadiz.length); Cadiz[Cadiz.length] = createMarker(new GPoint(-80.99248505,40.26958847),"
Harrison Central High School
440 E Market St
Cadiz, OH 43907

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Harrison Central High School",'Cadiz=' + Cadiz.length); Hopedale[Hopedale.length] = createMarker(new GPoint(-80.90180206,40.34629822),"
Harrison Hopedale Elementary School
Po Box 307
Hopedale, OH 43976

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Harrison Hopedale Elementary School",'Hopedale=' + Hopedale.length); Jewett[Jewett.length] = createMarker(new GPoint(-80.99459839,40.37490082),"
Harrison Jewett Elementary School
Po Box 336
Jewett, OH 43986

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Harrison Jewett Elementary School",'Jewett=' + Jewett.length); Scio[Scio.length] = createMarker(new GPoint(-81.08686066,40.39892578),"
Harrison Junior High School
322 W Main St
Scio, OH 43988

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Harrison Junior High School",'Scio=' + Scio.length); Freeport[Freeport.length] = createMarker(new GPoint(-81.25221252,40.22155380),"
Harrison Lakeland Elementary School
77520 Freeport Tippecanoe Rd
Freeport, OH 43973

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Harrison Lakeland Elementary School",'Freeport=' + Freeport.length); Cadiz[Cadiz.length] = createMarker(new GPoint(-81.00543213,40.27862167),"
Harrison Westgate Elementary School
730 Peppard Ave
Cadiz, OH 43907

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Harrison Westgate Elementary School",'Cadiz=' + Cadiz.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(Bowerston); map.removeOverlays(Cadiz); map.removeOverlays(Freeport); map.removeOverlays(Hopedale); map.removeOverlays(Jewett); map.removeOverlays(Scio); 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(Bowerston);map.removeOverlays(Bowerston); map.removeOverlays(Cadiz); map.removeOverlays(Freeport); map.removeOverlays(Hopedale); map.removeOverlays(Jewett); map.removeOverlays(Scio); map.addOverlays(Bowerston); centerByArray(Bowerston, false, false); cntMarker += Bowerston.length; map.addOverlays(Cadiz); centerByArray(Cadiz, false, false); cntMarker += Cadiz.length; map.addOverlays(Freeport); centerByArray(Freeport, false, false); cntMarker += Freeport.length; map.addOverlays(Hopedale); centerByArray(Hopedale, false, false); cntMarker += Hopedale.length; map.addOverlays(Jewett); centerByArray(Jewett, false, false); cntMarker += Jewett.length; map.addOverlays(Scio); centerByArray(Scio, false, false); cntMarker += Scio.length; centerByArray(Bowerston,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'); } }