function addMarkers() { mySelect = document.getElementById('selection'); Anna = [];Botkins = [];Sidney = [];Pemberton = [];Fort_Loramie = [];Houston = [];Jackson_Center = [];Russia = [];mySelect.options[mySelect.options.length] = new Option("Anna schools",'all=Anna'); mySelect.options[mySelect.options.length] = new Option("Botkins schools",'all=Botkins'); mySelect.options[mySelect.options.length] = new Option("Fort Loramie schools",'all=Fort_Loramie'); mySelect.options[mySelect.options.length] = new Option("Houston schools",'all=Houston'); mySelect.options[mySelect.options.length] = new Option("Jackson Center schools",'all=Jackson_Center'); mySelect.options[mySelect.options.length] = new Option("Pemberton schools",'all=Pemberton'); mySelect.options[mySelect.options.length] = new Option("Russia schools",'all=Russia'); mySelect.options[mySelect.options.length] = new Option("Sidney schools",'all=Sidney'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Anna[Anna.length] = createMarker(new GPoint(-84.20880127,40.40589905),"
",iconRd); mySelect.options[mySelect.options.length] = new Option("Anna Elementary School",'Anna=' + Anna.length); Anna[Anna.length] = createMarker(new GPoint(-84.20880127,40.40589905),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Anna High School",'Anna=' + Anna.length); Anna[Anna.length] = createMarker(new GPoint(-84.20880127,40.40589905),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Anna Middle School",'Anna=' + Anna.length); Botkins[Botkins.length] = createMarker(new GPoint(-84.17870331,40.46360016),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Botkins Elementary School",'Botkins=' + Botkins.length); Botkins[Botkins.length] = createMarker(new GPoint(-84.17870331,40.46360016),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Botkins High School",'Botkins=' + Botkins.length); Sidney[Sidney.length] = createMarker(new GPoint(-84.15332031,40.28575897),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Central Elementary School",'Sidney=' + Sidney.length); Sidney[Sidney.length] = createMarker(new GPoint(-84.16888428,40.28026199),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Emerson Elementary School",'Sidney=' + Sidney.length); Pemberton[Pemberton.length] = createMarker(new GPoint(-84.03299713,40.29410172),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Fairlawn Elementary School",'Pemberton=' + Pemberton.length); Sidney[Sidney.length] = createMarker(new GPoint(-84.07656097,40.26749039),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Fairlawn High School",'Sidney=' + Sidney.length); Fort_Loramie[Fort_Loramie.length] = createMarker(new GPoint(-84.37590027,40.33039856),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Fort Loramie Elementary School",'Fort_Loramie=' + Fort_Loramie.length); Fort_Loramie[Fort_Loramie.length] = createMarker(new GPoint(-84.37590027,40.33039856),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Fort Loramie Junior-senior High School",'Fort_Loramie=' + Fort_Loramie.length); Sidney[Sidney.length] = createMarker(new GPoint(-84.24015045,40.28694916),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Hardin Elementary School",'Sidney=' + Sidney.length); Houston[Houston.length] = createMarker(new GPoint(-84.33338928,40.24601364),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Houston High School",'Houston=' + Houston.length); Jackson_Center[Jackson_Center.length] = createMarker(new GPoint(-84.03881836,40.44076157),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Jackson Center Elementary School",'Jackson_Center=' + Jackson_Center.length); Jackson_Center[Jackson_Center.length] = createMarker(new GPoint(-84.03881836,40.44076157),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Jackson Center High School",'Jackson_Center=' + Jackson_Center.length); Sidney[Sidney.length] = createMarker(new GPoint(-84.17390442,40.29253769),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Longfellow Elementary School",'Sidney=' + Sidney.length); Sidney[Sidney.length] = createMarker(new GPoint(-84.15471649,40.27854919),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Lowell Elementary School",'Sidney=' + Sidney.length); Sidney[Sidney.length] = createMarker(new GPoint(-84.16230011,40.29928970),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Northwood Elementary School",'Sidney=' + Sidney.length); Sidney[Sidney.length] = createMarker(new GPoint(-84.15929413,40.30213928),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Parkwood Elementary School",'Sidney=' + Sidney.length); Russia[Russia.length] = createMarker(new GPoint(-84.41307400,40.23374000),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Russia Elementary School",'Russia=' + Russia.length); Russia[Russia.length] = createMarker(new GPoint(-84.41307400,40.23374000),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Russia High School",'Russia=' + Russia.length); Sidney[Sidney.length] = createMarker(new GPoint(-84.17280579,40.28026199),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Sidney High School",'Sidney=' + Sidney.length); Sidney[Sidney.length] = createMarker(new GPoint(-84.15307617,40.28703690),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Sidney Middle School",'Sidney=' + Sidney.length); Sidney[Sidney.length] = createMarker(new GPoint(-84.15177917,40.29936218),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Whittier Elementary School",'Sidney=' + Sidney.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(Anna); map.removeOverlays(Botkins); map.removeOverlays(Fort_Loramie); map.removeOverlays(Houston); map.removeOverlays(Jackson_Center); map.removeOverlays(Pemberton); map.removeOverlays(Russia); map.removeOverlays(Sidney); 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(Anna);map.removeOverlays(Anna); map.removeOverlays(Botkins); map.removeOverlays(Fort_Loramie); map.removeOverlays(Houston); map.removeOverlays(Jackson_Center); map.removeOverlays(Pemberton); map.removeOverlays(Russia); map.removeOverlays(Sidney); map.addOverlays(Anna); centerByArray(Anna, false, false); cntMarker += Anna.length; map.addOverlays(Botkins); centerByArray(Botkins, false, false); cntMarker += Botkins.length; map.addOverlays(Fort_Loramie); centerByArray(Fort_Loramie, false, false); cntMarker += Fort_Loramie.length; map.addOverlays(Houston); centerByArray(Houston, false, false); cntMarker += Houston.length; map.addOverlays(Jackson_Center); centerByArray(Jackson_Center, false, false); cntMarker += Jackson_Center.length; map.addOverlays(Pemberton); centerByArray(Pemberton, false, false); cntMarker += Pemberton.length; map.addOverlays(Russia); centerByArray(Russia, false, false); cntMarker += Russia.length; map.addOverlays(Sidney); centerByArray(Sidney, false, false); cntMarker += Sidney.length; centerByArray(Anna,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'); } }