function addMarkers() { mySelect = document.getElementById('selection'); Brigham_City = [];Tremonton = [];Garland = [];Bear_River_City = [];Corinne = [];Fielding = [];Grouse_Creek = [];Howell = [];Park_Valley = [];Snowville = [];Willard = [];Perry = [];mySelect.options[mySelect.options.length] = new Option("Bear River City schools",'all=Bear_River_City'); mySelect.options[mySelect.options.length] = new Option("Brigham City schools",'all=Brigham_City'); mySelect.options[mySelect.options.length] = new Option("Corinne schools",'all=Corinne'); mySelect.options[mySelect.options.length] = new Option("Fielding schools",'all=Fielding'); mySelect.options[mySelect.options.length] = new Option("Garland schools",'all=Garland'); mySelect.options[mySelect.options.length] = new Option("Grouse Creek schools",'all=Grouse_Creek'); mySelect.options[mySelect.options.length] = new Option("Howell schools",'all=Howell'); mySelect.options[mySelect.options.length] = new Option("Park Valley schools",'all=Park_Valley'); mySelect.options[mySelect.options.length] = new Option("Perry schools",'all=Perry'); mySelect.options[mySelect.options.length] = new Option("Snowville schools",'all=Snowville'); mySelect.options[mySelect.options.length] = new Option("Tremonton schools",'all=Tremonton'); mySelect.options[mySelect.options.length] = new Option("Willard schools",'all=Willard'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Brigham_City[Brigham_City.length] = createMarker(new GPoint(-112.02528381,41.49430847),"
",iconBl); mySelect.options[mySelect.options.length] = new Option("Adele C Young Inter Middle School",'Brigham_City=' + Brigham_City.length); Tremonton[Tremonton.length] = createMarker(new GPoint(-112.17482758,41.71811295),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Alice C Harris Inter Middle School",'Tremonton=' + Tremonton.length); Garland[Garland.length] = createMarker(new GPoint(-112.16238403,41.72674179),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Bear River High School",'Garland=' + Garland.length); Garland[Garland.length] = createMarker(new GPoint(-112.15660095,41.74200058),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Bear River Middle School",'Garland=' + Garland.length); Brigham_City[Brigham_City.length] = createMarker(new GPoint(-112.02548218,41.50361252),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Box Elder High School",'Brigham_City=' + Brigham_City.length); Brigham_City[Brigham_City.length] = createMarker(new GPoint(-112.00798035,41.50989151),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Box Elder Middle School",'Brigham_City=' + Brigham_City.length); Brigham_City[Brigham_City.length] = createMarker(new GPoint(-112.00553894,41.51543808),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Bunderson Elementary School",'Brigham_City=' + Brigham_City.length); Bear_River_City[Bear_River_City.length] = createMarker(new GPoint(-112.12958527,41.61500549),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Century Elementary School",'Bear_River_City=' + Bear_River_City.length); Corinne[Corinne.length] = createMarker(new GPoint(-112.30670166,41.52280045),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Corinne Elementary School",'Corinne=' + Corinne.length); Brigham_City[Brigham_City.length] = createMarker(new GPoint(-112.01945496,41.50623703),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Dale Young Community High School",'Brigham_City=' + Brigham_City.length); Brigham_City[Brigham_City.length] = createMarker(new GPoint(-112.02261353,41.52684402),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Discovery Elementary School",'Brigham_City=' + Brigham_City.length); Fielding[Fielding.length] = createMarker(new GPoint(-112.11759949,41.81389999),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Fielding Elementary School",'Fielding=' + Fielding.length); Brigham_City[Brigham_City.length] = createMarker(new GPoint(-112.01361847,41.52718353),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Foothill Elementary School",'Brigham_City=' + Brigham_City.length); Garland[Garland.length] = createMarker(new GPoint(-112.16251373,41.74348831),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Garland Elementary School",'Garland=' + Garland.length); Grouse_Creek[Grouse_Creek.length] = createMarker(new GPoint(-113.88526917,41.70674133),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Grouse Creek Elementary School",'Grouse_Creek=' + Grouse_Creek.length); Grouse_Creek[Grouse_Creek.length] = createMarker(new GPoint(-113.89030600,41.70500900),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Grouse Creek School",'Grouse_Creek=' + Grouse_Creek.length); Howell[Howell.length] = createMarker(new GPoint(-112.44116974,41.79589844),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Howell Elementary School",'Howell=' + Howell.length); Brigham_City[Brigham_City.length] = createMarker(new GPoint(-112.01901245,41.49472046),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Lake View Elementary School",'Brigham_City=' + Brigham_City.length); Brigham_City[Brigham_City.length] = createMarker(new GPoint(-112.01737976,41.51627350),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Lincoln Center",'Brigham_City=' + Brigham_City.length); Tremonton[Tremonton.length] = createMarker(new GPoint(-112.16761780,41.70552063),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Mc Kinley Elementary School",'Tremonton=' + Tremonton.length); Brigham_City[Brigham_City.length] = createMarker(new GPoint(-112.00597382,41.49566269),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Mountain View Elementary School",'Brigham_City=' + Brigham_City.length); Garland[Garland.length] = createMarker(new GPoint(-112.15638733,41.72629166),"",iconGr); mySelect.options[mySelect.options.length] = new Option("North Community High School",'Garland=' + Garland.length); Tremonton[Tremonton.length] = createMarker(new GPoint(-112.16458130,41.72076416),"",iconRd); mySelect.options[mySelect.options.length] = new Option("North Park Elementary School",'Tremonton=' + Tremonton.length); Park_Valley[Park_Valley.length] = createMarker(new GPoint(-113.32923126,41.81698990),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Park Valley Elementary School",'Park_Valley=' + Park_Valley.length); Park_Valley[Park_Valley.length] = createMarker(new GPoint(-113.32971900,41.81698000),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Park Valley School",'Park_Valley=' + Park_Valley.length); Snowville[Snowville.length] = createMarker(new GPoint(-112.71050262,41.96802139),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Snowville Elementary School",'Snowville=' + Snowville.length); Tremonton[Tremonton.length] = createMarker(new GPoint(-112.16761780,41.70552063),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Taft High School",'Tremonton=' + Tremonton.length); Brigham_City[Brigham_City.length] = createMarker(new GPoint(-112.03479767,41.51100159),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Triumph Youth Center (yic)",'Brigham_City=' + Brigham_City.length); Willard[Willard.length] = createMarker(new GPoint(-112.03723907,41.40827942),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Willard Elementary School",'Willard=' + Willard.length); Perry[Perry.length] = createMarker(new GPoint(-112.03635406,41.46449280),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Young-perry Elementary School",'Perry=' + Perry.length); Brigham_City[Brigham_City.length] = createMarker(new GPoint(-112.03479767,41.51100159),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Youth Track (yic)",'Brigham_City=' + Brigham_City.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(Bear_River_City); map.removeOverlays(Brigham_City); map.removeOverlays(Corinne); map.removeOverlays(Fielding); map.removeOverlays(Garland); map.removeOverlays(Grouse_Creek); map.removeOverlays(Howell); map.removeOverlays(Park_Valley); map.removeOverlays(Perry); map.removeOverlays(Snowville); map.removeOverlays(Tremonton); map.removeOverlays(Willard); 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(Brigham_City);map.removeOverlays(Bear_River_City); map.removeOverlays(Brigham_City); map.removeOverlays(Corinne); map.removeOverlays(Fielding); map.removeOverlays(Garland); map.removeOverlays(Grouse_Creek); map.removeOverlays(Howell); map.removeOverlays(Park_Valley); map.removeOverlays(Perry); map.removeOverlays(Snowville); map.removeOverlays(Tremonton); map.removeOverlays(Willard); map.addOverlays(Bear_River_City); centerByArray(Bear_River_City, false, false); cntMarker += Bear_River_City.length; map.addOverlays(Brigham_City); centerByArray(Brigham_City, false, false); cntMarker += Brigham_City.length; map.addOverlays(Corinne); centerByArray(Corinne, false, false); cntMarker += Corinne.length; map.addOverlays(Fielding); centerByArray(Fielding, false, false); cntMarker += Fielding.length; map.addOverlays(Garland); centerByArray(Garland, false, false); cntMarker += Garland.length; map.addOverlays(Grouse_Creek); centerByArray(Grouse_Creek, false, false); cntMarker += Grouse_Creek.length; map.addOverlays(Howell); centerByArray(Howell, false, false); cntMarker += Howell.length; map.addOverlays(Park_Valley); centerByArray(Park_Valley, false, false); cntMarker += Park_Valley.length; map.addOverlays(Perry); centerByArray(Perry, false, false); cntMarker += Perry.length; map.addOverlays(Snowville); centerByArray(Snowville, false, false); cntMarker += Snowville.length; map.addOverlays(Tremonton); centerByArray(Tremonton, false, false); cntMarker += Tremonton.length; map.addOverlays(Willard); centerByArray(Willard, false, false); cntMarker += Willard.length; centerByArray(Brigham_City,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'); } }