function addMarkers() { mySelect = document.getElementById('selection'); Amboy = [];Ashton = [];Dixon = [];Franklin_Grove = [];Nachusa = [];Nelson = [];Paw_Paw = [];Steward = [];mySelect.options[mySelect.options.length] = new Option("Amboy schools",'all=Amboy'); mySelect.options[mySelect.options.length] = new Option("Ashton schools",'all=Ashton'); mySelect.options[mySelect.options.length] = new Option("Dixon schools",'all=Dixon'); mySelect.options[mySelect.options.length] = new Option("Franklin Grove schools",'all=Franklin_Grove'); mySelect.options[mySelect.options.length] = new Option("Nachusa schools",'all=Nachusa'); mySelect.options[mySelect.options.length] = new Option("Nelson schools",'all=Nelson'); mySelect.options[mySelect.options.length] = new Option("Paw Paw schools",'all=Paw_Paw'); mySelect.options[mySelect.options.length] = new Option("Steward schools",'all=Steward'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Amboy[Amboy.length] = createMarker(new GPoint(-89.33285522,41.71693802),"
",iconRd); mySelect.options[mySelect.options.length] = new Option("Amboy Central Elementary School",'Amboy=' + Amboy.length); Amboy[Amboy.length] = createMarker(new GPoint(-89.33350372,41.72036362),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Amboy High School",'Amboy=' + Amboy.length); Amboy[Amboy.length] = createMarker(new GPoint(-89.33668518,41.71330643),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Amboy Junior High School",'Amboy=' + Amboy.length); Ashton[Ashton.length] = createMarker(new GPoint(-89.22837067,41.86668015),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Ashton Elementary School",'Ashton=' + Ashton.length); Ashton[Ashton.length] = createMarker(new GPoint(-89.22837067,41.86668015),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Ashton High School",'Ashton=' + Ashton.length); Ashton[Ashton.length] = createMarker(new GPoint(-89.22837067,41.86668015),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Ashton Junior High School",'Ashton=' + Ashton.length); Dixon[Dixon.length] = createMarker(new GPoint(-89.48000336,41.84049988),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Dixon Correctional Center",'Dixon=' + Dixon.length); Dixon[Dixon.length] = createMarker(new GPoint(-89.48555756,41.84621811),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Dixon High School",'Dixon=' + Dixon.length); Franklin_Grove[Franklin_Grove.length] = createMarker(new GPoint(-89.32530212,41.85919952),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Franklin Center Elementary School",'Franklin_Grove=' + Franklin_Grove.length); Franklin_Grove[Franklin_Grove.length] = createMarker(new GPoint(-89.32530212,41.85919952),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Franklin Center Junior Senior High School",'Franklin_Grove=' + Franklin_Grove.length); Dixon[Dixon.length] = createMarker(new GPoint(-89.49641418,41.85320282),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Jefferson Elementary School",'Dixon=' + Dixon.length); Dixon[Dixon.length] = createMarker(new GPoint(-89.49718475,41.83584213),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Lincoln Elementary School",'Dixon=' + Dixon.length); Nachusa[Nachusa.length] = createMarker(new GPoint(-89.39028200,41.83762500),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Nachusa Campus School",'Nachusa=' + Nachusa.length); Nachusa[Nachusa.length] = createMarker(new GPoint(-89.38970184,41.83129883),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Nachusa Education Center",'Nachusa=' + Nachusa.length); Nelson[Nelson.length] = createMarker(new GPoint(-89.60160065,41.79629898),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Nelson Elementary School",'Nelson=' + Nelson.length); Paw_Paw[Paw_Paw.length] = createMarker(new GPoint(-88.99829865,41.69810104),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Paw Paw Elementary School",'Paw_Paw=' + Paw_Paw.length); Paw_Paw[Paw_Paw.length] = createMarker(new GPoint(-88.99829865,41.69810104),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Paw Paw Jr/sr High School",'Paw_Paw=' + Paw_Paw.length); Dixon[Dixon.length] = createMarker(new GPoint(-89.47374725,41.83316422),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Reagan Middle School",'Dixon=' + Dixon.length); Steward[Steward.length] = createMarker(new GPoint(-89.02285004,41.84746170),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Steward Elementary School",'Steward=' + Steward.length); Dixon[Dixon.length] = createMarker(new GPoint(-89.47764587,41.85347748),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Washington Elementary School",'Dixon=' + Dixon.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(Amboy); map.removeOverlays(Ashton); map.removeOverlays(Dixon); map.removeOverlays(Franklin_Grove); map.removeOverlays(Nachusa); map.removeOverlays(Nelson); map.removeOverlays(Paw_Paw); map.removeOverlays(Steward); 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(Amboy);map.removeOverlays(Amboy); map.removeOverlays(Ashton); map.removeOverlays(Dixon); map.removeOverlays(Franklin_Grove); map.removeOverlays(Nachusa); map.removeOverlays(Nelson); map.removeOverlays(Paw_Paw); map.removeOverlays(Steward); map.addOverlays(Amboy); centerByArray(Amboy, false, false); cntMarker += Amboy.length; map.addOverlays(Ashton); centerByArray(Ashton, false, false); cntMarker += Ashton.length; map.addOverlays(Dixon); centerByArray(Dixon, false, false); cntMarker += Dixon.length; map.addOverlays(Franklin_Grove); centerByArray(Franklin_Grove, false, false); cntMarker += Franklin_Grove.length; map.addOverlays(Nachusa); centerByArray(Nachusa, false, false); cntMarker += Nachusa.length; map.addOverlays(Nelson); centerByArray(Nelson, false, false); cntMarker += Nelson.length; map.addOverlays(Paw_Paw); centerByArray(Paw_Paw, false, false); cntMarker += Paw_Paw.length; map.addOverlays(Steward); centerByArray(Steward, false, false); cntMarker += Steward.length; centerByArray(Amboy,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'); } }