function addMarkers() { mySelect = document.getElementById('selection'); Grand_Junction = [];Clifton = [];De_Beque = [];Fruita = [];Gateway = [];Collbran = [];Loma = [];Palisade = [];mySelect.options[mySelect.options.length] = new Option("Clifton schools",'all=Clifton'); mySelect.options[mySelect.options.length] = new Option("Collbran schools",'all=Collbran'); mySelect.options[mySelect.options.length] = new Option("De Beque schools",'all=De_Beque'); mySelect.options[mySelect.options.length] = new Option("Fruita schools",'all=Fruita'); mySelect.options[mySelect.options.length] = new Option("Gateway schools",'all=Gateway'); mySelect.options[mySelect.options.length] = new Option("Grand Junction schools",'all=Grand_Junction'); mySelect.options[mySelect.options.length] = new Option("Loma schools",'all=Loma'); mySelect.options[mySelect.options.length] = new Option("Palisade schools",'all=Palisade'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Grand_Junction[Grand_Junction.length] = createMarker(new GPoint(-108.61607361,39.12070084),"
",iconRd); mySelect.options[mySelect.options.length] = new Option("Appleton Elementary School",'Grand_Junction=' + Grand_Junction.length); Grand_Junction[Grand_Junction.length] = createMarker(new GPoint(-108.50854492,39.08448029),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Bookcliff Middle School",'Grand_Junction=' + Grand_Junction.length); Grand_Junction[Grand_Junction.length] = createMarker(new GPoint(-108.63294983,39.07707977),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Broadway Elementary School",'Grand_Junction=' + Grand_Junction.length); Grand_Junction[Grand_Junction.length] = createMarker(new GPoint(-108.47276306,39.04133606),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Central High School",'Grand_Junction=' + Grand_Junction.length); Grand_Junction[Grand_Junction.length] = createMarker(new GPoint(-108.55022430,39.06441879),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Chatfield Elementary School",'Grand_Junction=' + Grand_Junction.length); Clifton[Clifton.length] = createMarker(new GPoint(-108.44552612,39.09178162),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Clifton Elementary School",'Clifton=' + Clifton.length); Grand_Junction[Grand_Junction.length] = createMarker(new GPoint(-108.55774689,39.07257462),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Columbine Elementary School",'Grand_Junction=' + Grand_Junction.length); De_Beque[De_Beque.length] = createMarker(new GPoint(-108.55370331,39.44480133),"",iconRd); mySelect.options[mySelect.options.length] = new Option("De Beque Elementary School",'De_Beque=' + De_Beque.length); De_Beque[De_Beque.length] = createMarker(new GPoint(-108.55370331,39.44480133),"",iconGr); mySelect.options[mySelect.options.length] = new Option("De Beque Undivided High School",'De_Beque=' + De_Beque.length); Grand_Junction[Grand_Junction.length] = createMarker(new GPoint(-108.52880096,39.04191971),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Deep River School",'Grand_Junction=' + Grand_Junction.length); Grand_Junction[Grand_Junction.length] = createMarker(new GPoint(-108.55715179,39.04117966),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Dos Rios Elementary School",'Grand_Junction=' + Grand_Junction.length); Grand_Junction[Grand_Junction.length] = createMarker(new GPoint(-108.55439600,39.04841600),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Dual Immersion Academy School",'Grand_Junction=' + Grand_Junction.length); Grand_Junction[Grand_Junction.length] = createMarker(new GPoint(-108.55892944,39.07348251),"",iconBl); mySelect.options[mySelect.options.length] = new Option("East Middle School",'Grand_Junction=' + Grand_Junction.length); Fruita[Fruita.length] = createMarker(new GPoint(-108.72881317,39.16118622),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Fruita Middle School",'Fruita=' + Fruita.length); Fruita[Fruita.length] = createMarker(new GPoint(-108.68679810,39.14960098),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Fruita Monument High School",'Fruita=' + Fruita.length); Grand_Junction[Grand_Junction.length] = createMarker(new GPoint(-108.49655914,39.08948898),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Fruitvale Elementary School",'Grand_Junction=' + Grand_Junction.length); Gateway[Gateway.length] = createMarker(new GPoint(-108.80690002,38.79280090),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Gateway School",'Gateway=' + Gateway.length); Grand_Junction[Grand_Junction.length] = createMarker(new GPoint(-108.56455231,39.07987976),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Grand Junction High School",'Grand_Junction=' + Grand_Junction.length); Collbran[Collbran.length] = createMarker(new GPoint(-107.98761749,39.23683929),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Grand Mesa High School",'Collbran=' + Collbran.length); Grand_Junction[Grand_Junction.length] = createMarker(new GPoint(-108.46884918,39.08909225),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Grand Mesa Middle School",'Grand_Junction=' + Grand_Junction.length); Grand_Junction[Grand_Junction.length] = createMarker(new GPoint(-108.56598663,39.07448196),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Hawthorne Building Elementary School",'Grand_Junction=' + Grand_Junction.length); Grand_Junction[Grand_Junction.length] = createMarker(new GPoint(-108.51753998,39.04123688),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Lincoln Orchard Mesa Elementary School",'Grand_Junction=' + Grand_Junction.length); Grand_Junction[Grand_Junction.length] = createMarker(new GPoint(-108.54914856,39.07228088),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Lincoln Park Elementary School",'Grand_Junction=' + Grand_Junction.length); Loma[Loma.length] = createMarker(new GPoint(-108.81259918,39.20196152),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Loma Elementary School",'Loma=' + Loma.length); Grand_Junction[Grand_Junction.length] = createMarker(new GPoint(-108.50294495,39.03388214),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Mesa View Elementary School",'Grand_Junction=' + Grand_Junction.length); Clifton[Clifton.length] = createMarker(new GPoint(-108.42714691,39.09366226),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Mount Garfield Middle School",'Clifton=' + Clifton.length); Grand_Junction[Grand_Junction.length] = createMarker(new GPoint(-108.55424500,39.04838181),"",iconRd); mySelect.options[mySelect.options.length] = new Option("New Emerson School At Columbus",'Grand_Junction=' + Grand_Junction.length); Grand_Junction[Grand_Junction.length] = createMarker(new GPoint(-108.51997375,39.08293533),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Nisley Elementary School",'Grand_Junction=' + Grand_Junction.length); Grand_Junction[Grand_Junction.length] = createMarker(new GPoint(-108.54415131,39.08457947),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Orchard Avenue Elementary School",'Grand_Junction=' + Grand_Junction.length); Grand_Junction[Grand_Junction.length] = createMarker(new GPoint(-108.48769379,39.04850769),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Orchard Mesa Middle School",'Grand_Junction=' + Grand_Junction.length); Palisade[Palisade.length] = createMarker(new GPoint(-108.36693573,39.10570145),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Palisade High School",'Palisade=' + Palisade.length); Collbran[Collbran.length] = createMarker(new GPoint(-107.98761749,39.23683929),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Plateau Valley Elementary School",'Collbran=' + Collbran.length); Collbran[Collbran.length] = createMarker(new GPoint(-107.98761749,39.23683929),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Plateau Valley High School",'Collbran=' + Collbran.length); Collbran[Collbran.length] = createMarker(new GPoint(-107.98761749,39.23683929),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Plateau Valley Middle School",'Collbran=' + Collbran.length); Grand_Junction[Grand_Junction.length] = createMarker(new GPoint(-108.55022430,39.06441879),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Pomona Elementary School",'Grand_Junction=' + Grand_Junction.length); Grand_Junction[Grand_Junction.length] = createMarker(new GPoint(-108.56114960,39.06939316),"",iconGr); mySelect.options[mySelect.options.length] = new Option("R-5 High School",'Grand_Junction=' + Grand_Junction.length); Grand_Junction[Grand_Junction.length] = createMarker(new GPoint(-108.64485168,39.07258224),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Redlands Middle School",'Grand_Junction=' + Grand_Junction.length); Clifton[Clifton.length] = createMarker(new GPoint(-108.44808960,39.09032059),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Rocky Mountain Elementary School",'Clifton=' + Clifton.length); Grand_Junction[Grand_Junction.length] = createMarker(new GPoint(-108.60986328,39.07147980),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Scenic Elementary School",'Grand_Junction=' + Grand_Junction.length); Grand_Junction[Grand_Junction.length] = createMarker(new GPoint(-108.56114960,39.06939316),"",iconGr); mySelect.options[mySelect.options.length] = new Option("School Without Walls",'Grand_Junction=' + Grand_Junction.length); Fruita[Fruita.length] = createMarker(new GPoint(-108.73342133,39.16316605),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Shelledy Elementary School",'Fruita=' + Fruita.length); Palisade[Palisade.length] = createMarker(new GPoint(-108.35263824,39.10205841),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Taylor Elementary School",'Palisade=' + Palisade.length); Grand_Junction[Grand_Junction.length] = createMarker(new GPoint(-108.55022430,39.06441879),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Thunder Mountain Elementary School",'Grand_Junction=' + Grand_Junction.length); Grand_Junction[Grand_Junction.length] = createMarker(new GPoint(-108.56114960,39.08699799),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Tope Elementary School",'Grand_Junction=' + Grand_Junction.length); Grand_Junction[Grand_Junction.length] = createMarker(new GPoint(-108.60520172,39.11249924),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Valley School",'Grand_Junction=' + Grand_Junction.length); Grand_Junction[Grand_Junction.length] = createMarker(new GPoint(-108.57117462,39.08457947),"",iconBl); mySelect.options[mySelect.options.length] = new Option("West Middle School",'Grand_Junction=' + Grand_Junction.length); Grand_Junction[Grand_Junction.length] = createMarker(new GPoint(-108.63851929,39.04893875),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Wingate Elementary School",'Grand_Junction=' + Grand_Junction.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(Clifton); map.removeOverlays(Collbran); map.removeOverlays(De_Beque); map.removeOverlays(Fruita); map.removeOverlays(Gateway); map.removeOverlays(Grand_Junction); map.removeOverlays(Loma); map.removeOverlays(Palisade); 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(Grand_Junction);map.removeOverlays(Clifton); map.removeOverlays(Collbran); map.removeOverlays(De_Beque); map.removeOverlays(Fruita); map.removeOverlays(Gateway); map.removeOverlays(Grand_Junction); map.removeOverlays(Loma); map.removeOverlays(Palisade); map.addOverlays(Clifton); centerByArray(Clifton, false, false); cntMarker += Clifton.length; map.addOverlays(Collbran); centerByArray(Collbran, false, false); cntMarker += Collbran.length; map.addOverlays(De_Beque); centerByArray(De_Beque, false, false); cntMarker += De_Beque.length; map.addOverlays(Fruita); centerByArray(Fruita, false, false); cntMarker += Fruita.length; map.addOverlays(Gateway); centerByArray(Gateway, false, false); cntMarker += Gateway.length; map.addOverlays(Grand_Junction); centerByArray(Grand_Junction, false, false); cntMarker += Grand_Junction.length; map.addOverlays(Loma); centerByArray(Loma, false, false); cntMarker += Loma.length; map.addOverlays(Palisade); centerByArray(Palisade, false, false); cntMarker += Palisade.length; centerByArray(Grand_Junction,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'); } }