function addMarkers() { mySelect = document.getElementById('selection'); Burlington = [];Gridley = [];Lebo = [];Leroy = [];Waverly = [];mySelect.options[mySelect.options.length] = new Option("Burlington schools",'all=Burlington'); mySelect.options[mySelect.options.length] = new Option("Gridley schools",'all=Gridley'); mySelect.options[mySelect.options.length] = new Option("Lebo schools",'all=Lebo'); mySelect.options[mySelect.options.length] = new Option("Leroy schools",'all=Leroy'); mySelect.options[mySelect.options.length] = new Option("Waverly schools",'all=Waverly'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Burlington[Burlington.length] = createMarker(new GPoint(-95.74344635,38.19293594),"
",iconRd); mySelect.options[mySelect.options.length] = new Option("Burlington Elementary K-5",'Burlington=' + Burlington.length); Burlington[Burlington.length] = createMarker(new GPoint(-95.74515533,38.20663834),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Burlington High School",'Burlington=' + Burlington.length); Burlington[Burlington.length] = createMarker(new GPoint(-95.74350739,38.20663834),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Burlington Middle 6-8",'Burlington=' + Burlington.length); Gridley[Gridley.length] = createMarker(new GPoint(-95.90381622,38.06912994),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Gridley Elementary School",'Gridley=' + Gridley.length); Lebo[Lebo.length] = createMarker(new GPoint(-95.79499817,38.43579865),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Lebo Elementary School",'Lebo=' + Lebo.length); Lebo[Lebo.length] = createMarker(new GPoint(-95.79499817,38.43579865),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Lebo High School",'Lebo=' + Lebo.length); Leroy[Leroy.length] = createMarker(new GPoint(-95.63387299,38.08674622),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Leroy Elementary School",'Leroy=' + Leroy.length); Leroy[Leroy.length] = createMarker(new GPoint(-95.63352203,38.08671951),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Southern Coffey County High School",'Leroy=' + Leroy.length); Gridley[Gridley.length] = createMarker(new GPoint(-95.88719940,38.09649658),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Southern Coffey County Junior High School",'Gridley=' + Gridley.length); Waverly[Waverly.length] = createMarker(new GPoint(-95.59809875,38.37099838),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Waverly Elementary School",'Waverly=' + Waverly.length); Waverly[Waverly.length] = createMarker(new GPoint(-95.59809875,38.37099838),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Waverly High School",'Waverly=' + Waverly.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(Burlington); map.removeOverlays(Gridley); map.removeOverlays(Lebo); map.removeOverlays(Leroy); map.removeOverlays(Waverly); 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(Burlington);map.removeOverlays(Burlington); map.removeOverlays(Gridley); map.removeOverlays(Lebo); map.removeOverlays(Leroy); map.removeOverlays(Waverly); map.addOverlays(Burlington); centerByArray(Burlington, false, false); cntMarker += Burlington.length; map.addOverlays(Gridley); centerByArray(Gridley, false, false); cntMarker += Gridley.length; map.addOverlays(Lebo); centerByArray(Lebo, false, false); cntMarker += Lebo.length; map.addOverlays(Leroy); centerByArray(Leroy, false, false); cntMarker += Leroy.length; map.addOverlays(Waverly); centerByArray(Waverly, false, false); cntMarker += Waverly.length; centerByArray(Burlington,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'); } }