function addMarkers() { mySelect = document.getElementById('selection'); Albion = [];Almo = [];Burley = [];Declo = [];Oakley = [];Malta = [];mySelect.options[mySelect.options.length] = new Option("Albion schools",'all=Albion'); mySelect.options[mySelect.options.length] = new Option("Almo schools",'all=Almo'); mySelect.options[mySelect.options.length] = new Option("Burley schools",'all=Burley'); mySelect.options[mySelect.options.length] = new Option("Declo schools",'all=Declo'); mySelect.options[mySelect.options.length] = new Option("Malta schools",'all=Malta'); mySelect.options[mySelect.options.length] = new Option("Oakley schools",'all=Oakley'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Albion[Albion.length] = createMarker(new GPoint(-113.44850159,42.40330124),"
Albion Elementary School
Po Box 38
Albion, ID 83311

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Albion Elementary School",'Albion=' + Albion.length); Almo[Almo.length] = createMarker(new GPoint(-113.63339996,42.09849930),"
Almo Elementary School
Po Box 168
Almo, ID 83312

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Almo Elementary School",'Almo=' + Almo.length); Burley[Burley.length] = createMarker(new GPoint(-113.80106354,42.53308868),"
Burley Junior High School
700 W 16th St
Burley, ID 83318

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Burley Junior High School",'Burley=' + Burley.length); Burley[Burley.length] = createMarker(new GPoint(-113.80302429,42.52687836),"
Burley Senior High School
2100 Park Avenue
Burley, ID 83318

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Burley Senior High School",'Burley=' + Burley.length); Burley[Burley.length] = createMarker(new GPoint(-113.80326843,42.53163910),"
Cassia County Education Center
1010 West 17th Street
Burley, ID 83318

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Cassia County Education Center",'Burley=' + Burley.length); Burley[Burley.length] = createMarker(new GPoint(-113.80358124,42.53160095),"
Cassia Education Center (alt)
1010 W 17th Street
Burley, ID 83318

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Cassia Education Center (alt)",'Burley=' + Burley.length); Burley[Burley.length] = createMarker(new GPoint(-113.80543518,42.53311920),"
Cassia Regional Technical Center
1143 W 16th Street
Burley, ID 83318

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Cassia Regional Technical Center",'Burley=' + Burley.length); Declo[Declo.length] = createMarker(new GPoint(-113.86383820,42.24291992),"
Declo Elementary School
120 E Main
Declo, ID 83323

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Declo Elementary School",'Declo=' + Declo.length); Declo[Declo.length] = createMarker(new GPoint(-113.86383820,42.24291992),"
Declo Junior High School
205 E Main St
Declo, ID 83323

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Declo Junior High School",'Declo=' + Declo.length); Declo[Declo.length] = createMarker(new GPoint(-113.86383820,42.24291992),"
Declo Senior High School
505 E Main St
Declo, ID 83323

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Declo Senior High School",'Declo=' + Declo.length); Burley[Burley.length] = createMarker(new GPoint(-113.79187775,42.52934265),"
Dworshak Elementary School
102 E 19th St
Burley, ID 83318

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Dworshak Elementary School",'Burley=' + Burley.length); Burley[Burley.length] = createMarker(new GPoint(-113.79637909,42.51863861),"
Mountain View Elementary School
333 W 27th St
Burley, ID 83318

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Mountain View Elementary School",'Burley=' + Burley.length); Burley[Burley.length] = createMarker(new GPoint(-113.80302429,42.53163147),"
Newcomer Center
1144 W 17th St
Burley, ID 83318

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Newcomer Center",'Burley=' + Burley.length); Oakley[Oakley.length] = createMarker(new GPoint(-113.87731171,42.24499893),"
Oakley Elementary School
Po Box 72
Oakley, ID 83346

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Oakley Elementary School",'Oakley=' + Oakley.length); Oakley[Oakley.length] = createMarker(new GPoint(-113.97139740,42.22919846),"
Oakley Junior Senior High School
Po Box 135
Oakley, ID 83346

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Oakley Junior Senior High School",'Oakley=' + Oakley.length); Malta[Malta.length] = createMarker(new GPoint(-113.26860046,42.20249939),"
Raft River Elementary School
Po Box 615
Malta, ID 83342

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Raft River Elementary School",'Malta=' + Malta.length); Malta[Malta.length] = createMarker(new GPoint(-113.26860046,42.20249939),"
Raft River Junior Senior High School
Po Box 68
Malta, ID 83342

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Raft River Junior Senior High School",'Malta=' + Malta.length); Burley[Burley.length] = createMarker(new GPoint(-113.78358459,42.52916336),"
White Pine Elementary School
1900 Hiland Ave
Burley, ID 83318

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("White Pine Elementary School",'Burley=' + Burley.length); Burley[Burley.length] = createMarker(new GPoint(-113.78339386,42.52926636),"
White Pine Intermediate
1900 Hiland Avenue
Burley, ID 83318

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("White Pine Intermediate",'Burley=' + Burley.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(Albion); map.removeOverlays(Almo); map.removeOverlays(Burley); map.removeOverlays(Declo); map.removeOverlays(Malta); map.removeOverlays(Oakley); 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(Albion);map.removeOverlays(Albion); map.removeOverlays(Almo); map.removeOverlays(Burley); map.removeOverlays(Declo); map.removeOverlays(Malta); map.removeOverlays(Oakley); map.addOverlays(Albion); centerByArray(Albion, false, false); cntMarker += Albion.length; map.addOverlays(Almo); centerByArray(Almo, false, false); cntMarker += Almo.length; map.addOverlays(Burley); centerByArray(Burley, false, false); cntMarker += Burley.length; map.addOverlays(Declo); centerByArray(Declo, false, false); cntMarker += Declo.length; map.addOverlays(Malta); centerByArray(Malta, false, false); cntMarker += Malta.length; map.addOverlays(Oakley); centerByArray(Oakley, false, false); cntMarker += Oakley.length; centerByArray(Albion,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'); } }