function addMarkers() { mySelect = document.getElementById('selection'); Bedford = [];Mitchell = [];Oolitic = [];Heltonville = [];Springville = [];mySelect.options[mySelect.options.length] = new Option("Bedford schools",'all=Bedford'); mySelect.options[mySelect.options.length] = new Option("Heltonville schools",'all=Heltonville'); mySelect.options[mySelect.options.length] = new Option("Mitchell schools",'all=Mitchell'); mySelect.options[mySelect.options.length] = new Option("Oolitic schools",'all=Oolitic'); mySelect.options[mySelect.options.length] = new Option("Springville schools",'all=Springville'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Bedford[Bedford.length] = createMarker(new GPoint(-86.42109680,38.89319992),"
",iconGr); mySelect.options[mySelect.options.length] = new Option("Bedford-north Lawrence High School",'Bedford=' + Bedford.length); Mitchell[Mitchell.length] = createMarker(new GPoint(-86.46890259,38.72539902),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Burris Elementary School",'Mitchell=' + Mitchell.length); Oolitic[Oolitic.length] = createMarker(new GPoint(-86.52118683,38.89267731),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Dollens Elementary School",'Oolitic=' + Oolitic.length); Bedford[Bedford.length] = createMarker(new GPoint(-86.49827576,38.84525681),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Englewood Elementary School",'Bedford=' + Bedford.length); Bedford[Bedford.length] = createMarker(new GPoint(-86.59547424,38.86376953),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Fayetteville Elementary School",'Bedford=' + Bedford.length); Mitchell[Mitchell.length] = createMarker(new GPoint(-86.46890259,38.72539902),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Hatfield Elementary School",'Mitchell=' + Mitchell.length); Heltonville[Heltonville.length] = createMarker(new GPoint(-86.37740326,38.97380066),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Heltonville Elementary School",'Heltonville=' + Heltonville.length); Bedford[Bedford.length] = createMarker(new GPoint(-86.47812653,38.85638428),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Lincoln Elementary School",'Bedford=' + Bedford.length); Mitchell[Mitchell.length] = createMarker(new GPoint(-86.47942352,38.73704147),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Mitchell High School",'Mitchell=' + Mitchell.length); Mitchell[Mitchell.length] = createMarker(new GPoint(-86.47961426,38.73699951),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Mitchell Junior High School",'Mitchell=' + Mitchell.length); Bedford[Bedford.length] = createMarker(new GPoint(-86.47630310,38.86660004),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Needmore Elementary School",'Bedford=' + Bedford.length); Bedford[Bedford.length] = createMarker(new GPoint(-86.50028229,38.83771896),"",iconGr); mySelect.options[mySelect.options.length] = new Option("North Lawrence A/v Tech Center",'Bedford=' + Bedford.length); Oolitic[Oolitic.length] = createMarker(new GPoint(-86.52118683,38.89267731),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Oolitic Middle School",'Oolitic=' + Oolitic.length); Bedford[Bedford.length] = createMarker(new GPoint(-86.47630310,38.86660004),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Park Hill Elementary School",'Bedford=' + Bedford.length); Bedford[Bedford.length] = createMarker(new GPoint(-86.50046539,38.86096191),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Parkview Intermediate School",'Bedford=' + Bedford.length); Bedford[Bedford.length] = createMarker(new GPoint(-86.49727631,38.86024475),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Parkview Primary School",'Bedford=' + Bedford.length); Bedford[Bedford.length] = createMarker(new GPoint(-86.44840240,38.88930130),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Shawswick Elementary School",'Bedford=' + Bedford.length); Bedford[Bedford.length] = createMarker(new GPoint(-86.39444733,38.87428665),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Shawswick Middle School",'Bedford=' + Bedford.length); Springville[Springville.length] = createMarker(new GPoint(-86.61789703,38.95640182),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Springville Elementary School",'Springville=' + Springville.length); Bedford[Bedford.length] = createMarker(new GPoint(-86.50062561,38.87500763),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Stalker Elementary School",'Bedford=' + Bedford.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(Bedford); map.removeOverlays(Heltonville); map.removeOverlays(Mitchell); map.removeOverlays(Oolitic); map.removeOverlays(Springville); 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(Bedford);map.removeOverlays(Bedford); map.removeOverlays(Heltonville); map.removeOverlays(Mitchell); map.removeOverlays(Oolitic); map.removeOverlays(Springville); map.addOverlays(Bedford); centerByArray(Bedford, false, false); cntMarker += Bedford.length; map.addOverlays(Heltonville); centerByArray(Heltonville, false, false); cntMarker += Heltonville.length; map.addOverlays(Mitchell); centerByArray(Mitchell, false, false); cntMarker += Mitchell.length; map.addOverlays(Oolitic); centerByArray(Oolitic, false, false); cntMarker += Oolitic.length; map.addOverlays(Springville); centerByArray(Springville, false, false); cntMarker += Springville.length; centerByArray(Bedford,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'); } }