function addMarkers() { mySelect = document.getElementById('selection'); Burns = [];Crane = [];Diamond = [];Hines = [];Drewsey = [];Fields = [];Frenchglen = [];Riley = [];mySelect.options[mySelect.options.length] = new Option("Burns schools",'all=Burns'); mySelect.options[mySelect.options.length] = new Option("Crane schools",'all=Crane'); mySelect.options[mySelect.options.length] = new Option("Diamond schools",'all=Diamond'); mySelect.options[mySelect.options.length] = new Option("Drewsey schools",'all=Drewsey'); mySelect.options[mySelect.options.length] = new Option("Fields schools",'all=Fields'); mySelect.options[mySelect.options.length] = new Option("Frenchglen schools",'all=Frenchglen'); mySelect.options[mySelect.options.length] = new Option("Hines schools",'all=Hines'); mySelect.options[mySelect.options.length] = new Option("Riley schools",'all=Riley'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Burns[Burns.length] = createMarker(new GPoint(-119.05091800,43.58909400),"
",iconGr); mySelect.options[mySelect.options.length] = new Option("Bhs Alternative Education",'Burns=' + Burns.length); Burns[Burns.length] = createMarker(new GPoint(-119.07325745,43.57564545),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Burns High School",'Burns=' + Burns.length); Crane[Crane.length] = createMarker(new GPoint(-118.41829681,43.44110107),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Crane Elementary School",'Crane=' + Crane.length); Crane[Crane.length] = createMarker(new GPoint(-118.41829681,43.44110107),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Crane Union High School",'Crane=' + Crane.length); Diamond[Diamond.length] = createMarker(new GPoint(-118.73509979,43.11859894),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Diamond Elementary School",'Diamond=' + Diamond.length); Hines[Hines.length] = createMarker(new GPoint(-119.29409790,43.70550156),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Double O Elementary School",'Hines=' + Hines.length); Drewsey[Drewsey.length] = createMarker(new GPoint(-118.59140015,43.89670181),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Drewsey Elementary School",'Drewsey=' + Drewsey.length); Fields[Fields.length] = createMarker(new GPoint(-118.48139954,42.32740021),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Fields Elementary School",'Fields=' + Fields.length); Frenchglen[Frenchglen.length] = createMarker(new GPoint(-118.70829773,43.48828125),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Frenchglen Elementary School",'Frenchglen=' + Frenchglen.length); Burns[Burns.length] = createMarker(new GPoint(-119.06068420,43.59233856),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Henry L Slater Elementary School",'Burns=' + Burns.length); Hines[Hines.length] = createMarker(new GPoint(-119.29409790,43.70550156),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Hines Elementary School",'Hines=' + Hines.length); Burns[Burns.length] = createMarker(new GPoint(-119.05778503,43.58146667),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Lincoln Junior High School",'Burns=' + Burns.length); Burns[Burns.length] = createMarker(new GPoint(-119.07170868,43.58563614),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Monroe School",'Burns=' + Burns.length); Drewsey[Drewsey.length] = createMarker(new GPoint(-118.59140015,43.89670181),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Pine Creek Elementary School",'Drewsey=' + Drewsey.length); Riley[Riley.length] = createMarker(new GPoint(-119.05333710,43.58603287),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Suntex Elementary School",'Riley=' + Riley.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(Burns); map.removeOverlays(Crane); map.removeOverlays(Diamond); map.removeOverlays(Drewsey); map.removeOverlays(Fields); map.removeOverlays(Frenchglen); map.removeOverlays(Hines); map.removeOverlays(Riley); 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(Burns);map.removeOverlays(Burns); map.removeOverlays(Crane); map.removeOverlays(Diamond); map.removeOverlays(Drewsey); map.removeOverlays(Fields); map.removeOverlays(Frenchglen); map.removeOverlays(Hines); map.removeOverlays(Riley); map.addOverlays(Burns); centerByArray(Burns, false, false); cntMarker += Burns.length; map.addOverlays(Crane); centerByArray(Crane, false, false); cntMarker += Crane.length; map.addOverlays(Diamond); centerByArray(Diamond, false, false); cntMarker += Diamond.length; map.addOverlays(Drewsey); centerByArray(Drewsey, false, false); cntMarker += Drewsey.length; map.addOverlays(Fields); centerByArray(Fields, false, false); cntMarker += Fields.length; map.addOverlays(Frenchglen); centerByArray(Frenchglen, false, false); cntMarker += Frenchglen.length; map.addOverlays(Hines); centerByArray(Hines, false, false); cntMarker += Hines.length; map.addOverlays(Riley); centerByArray(Riley, false, false); cntMarker += Riley.length; centerByArray(Burns,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'); } }