function addMarkers() { mySelect = document.getElementById('selection'); Belvidere = [];Caledonia = [];Capron = [];Garden_Prairie = [];Poplar_Grove = [];mySelect.options[mySelect.options.length] = new Option("Belvidere schools",'all=Belvidere'); mySelect.options[mySelect.options.length] = new Option("Caledonia schools",'all=Caledonia'); mySelect.options[mySelect.options.length] = new Option("Capron schools",'all=Capron'); mySelect.options[mySelect.options.length] = new Option("Garden Prairie schools",'all=Garden_Prairie'); mySelect.options[mySelect.options.length] = new Option("Poplar Grove schools",'all=Poplar_Grove'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Belvidere[Belvidere.length] = createMarker(new GPoint(-88.86088562,42.27812576),"
",iconBl); mySelect.options[mySelect.options.length] = new Option("Belvidere Central Middle School",'Belvidere=' + Belvidere.length); Belvidere[Belvidere.length] = createMarker(new GPoint(-88.83171082,42.24456406),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Belvidere High School",'Belvidere=' + Belvidere.length); Belvidere[Belvidere.length] = createMarker(new GPoint(-88.82939148,42.24767685),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Belvidere South Middle School",'Belvidere=' + Belvidere.length); Belvidere[Belvidere.length] = createMarker(new GPoint(-88.83171082,42.24727249),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Boone County Center",'Belvidere=' + Belvidere.length); Caledonia[Caledonia.length] = createMarker(new GPoint(-88.89523315,42.36580658),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Caledonia Elementary School",'Caledonia=' + Caledonia.length); Capron[Capron.length] = createMarker(new GPoint(-88.74508667,42.40063858),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Capron Elementary School",'Capron=' + Capron.length); Garden_Prairie[Garden_Prairie.length] = createMarker(new GPoint(-88.72501373,42.25678253),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Kishwaukee Elementary School",'Garden_Prairie=' + Garden_Prairie.length); Belvidere[Belvidere.length] = createMarker(new GPoint(-88.83161163,42.27495193),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Lincoln Elementary School",'Belvidere=' + Belvidere.length); Poplar_Grove[Poplar_Grove.length] = createMarker(new GPoint(-88.87028503,42.44707108),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Manchester Elementary School",'Poplar_Grove=' + Poplar_Grove.length); Belvidere[Belvidere.length] = createMarker(new GPoint(-88.82332611,42.24781418),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Meehan Elementary School",'Belvidere=' + Belvidere.length); Poplar_Grove[Poplar_Grove.length] = createMarker(new GPoint(-88.82213400,42.36585000),"",iconRd); mySelect.options[mySelect.options.length] = new Option("North Boone Elementary School",'Poplar_Grove=' + Poplar_Grove.length); Poplar_Grove[Poplar_Grove.length] = createMarker(new GPoint(-88.82159424,42.40856934),"",iconGr); mySelect.options[mySelect.options.length] = new Option("North Boone High School",'Poplar_Grove=' + Poplar_Grove.length); Poplar_Grove[Poplar_Grove.length] = createMarker(new GPoint(-88.82165500,42.41483000),"",iconBl); mySelect.options[mySelect.options.length] = new Option("North Boone Middle School",'Poplar_Grove=' + Poplar_Grove.length); Belvidere[Belvidere.length] = createMarker(new GPoint(-88.85278320,42.25962067),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Perry Elementary School",'Belvidere=' + Belvidere.length); Poplar_Grove[Poplar_Grove.length] = createMarker(new GPoint(-88.82201385,42.36901093),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Poplar Grove Elementary School",'Poplar_Grove=' + Poplar_Grove.length); Belvidere[Belvidere.length] = createMarker(new GPoint(-88.83267975,42.25464630),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Regional Learning Center Ark",'Belvidere=' + Belvidere.length); Belvidere[Belvidere.length] = createMarker(new GPoint(-88.84668732,42.25064850),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Washington Elementary School",'Belvidere=' + Belvidere.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(Belvidere); map.removeOverlays(Caledonia); map.removeOverlays(Capron); map.removeOverlays(Garden_Prairie); map.removeOverlays(Poplar_Grove); 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(Belvidere);map.removeOverlays(Belvidere); map.removeOverlays(Caledonia); map.removeOverlays(Capron); map.removeOverlays(Garden_Prairie); map.removeOverlays(Poplar_Grove); map.addOverlays(Belvidere); centerByArray(Belvidere, false, false); cntMarker += Belvidere.length; map.addOverlays(Caledonia); centerByArray(Caledonia, false, false); cntMarker += Caledonia.length; map.addOverlays(Capron); centerByArray(Capron, false, false); cntMarker += Capron.length; map.addOverlays(Garden_Prairie); centerByArray(Garden_Prairie, false, false); cntMarker += Garden_Prairie.length; map.addOverlays(Poplar_Grove); centerByArray(Poplar_Grove, false, false); cntMarker += Poplar_Grove.length; centerByArray(Belvidere,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'); } }