function addMarkers() { mySelect = document.getElementById('selection'); Palmer = [];Big_Lake = [];Wasilla = [];Talkeetna = [];Sutton = [];Trapper_Creek = [];Willow = [];mySelect.options[mySelect.options.length] = new Option("Big Lake schools",'all=Big_Lake'); mySelect.options[mySelect.options.length] = new Option("Palmer schools",'all=Palmer'); mySelect.options[mySelect.options.length] = new Option("Sutton schools",'all=Sutton'); mySelect.options[mySelect.options.length] = new Option("Talkeetna schools",'all=Talkeetna'); mySelect.options[mySelect.options.length] = new Option("Trapper Creek schools",'all=Trapper_Creek'); mySelect.options[mySelect.options.length] = new Option("Wasilla schools",'all=Wasilla'); mySelect.options[mySelect.options.length] = new Option("Willow schools",'all=Willow'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Palmer[Palmer.length] = createMarker(new GPoint(-149.10769653,61.60660553),"
",iconRd); mySelect.options[mySelect.options.length] = new Option("Academy Charter School",'Palmer=' + Palmer.length); Palmer[Palmer.length] = createMarker(new GPoint(-149.11518860,61.59934235),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Beryozava School",'Palmer=' + Palmer.length); Big_Lake[Big_Lake.length] = createMarker(new GPoint(-149.44009399,61.58420181),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Big Lake Elementary School",'Big_Lake=' + Big_Lake.length); Wasilla[Wasilla.length] = createMarker(new GPoint(-149.49491882,61.57937622),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Burchell High School",'Wasilla=' + Wasilla.length); Palmer[Palmer.length] = createMarker(new GPoint(-149.10594177,61.59273529),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Butte Elementary School",'Palmer=' + Palmer.length); Palmer[Palmer.length] = createMarker(new GPoint(-149.11245728,61.60021591),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Colony High School",'Palmer=' + Palmer.length); Palmer[Palmer.length] = createMarker(new GPoint(-149.11245728,61.60021591),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Colony Middle School",'Palmer=' + Palmer.length); Wasilla[Wasilla.length] = createMarker(new GPoint(-149.43522644,61.57992172),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Corresp. Study School",'Wasilla=' + Wasilla.length); Wasilla[Wasilla.length] = createMarker(new GPoint(-149.36013794,61.58893967),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Cottonwood Creek Elementary School",'Wasilla=' + Wasilla.length); Wasilla[Wasilla.length] = createMarker(new GPoint(-149.10594177,61.59273529),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Finger Lake Elementary School",'Wasilla=' + Wasilla.length); Palmer[Palmer.length] = createMarker(new GPoint(-149.15170288,61.66619873),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Glacier View School",'Palmer=' + Palmer.length); Wasilla[Wasilla.length] = createMarker(new GPoint(-149.65029907,61.55920029),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Goose Bay Elementary School",'Wasilla=' + Wasilla.length); Palmer[Palmer.length] = createMarker(new GPoint(-148.81059265,61.65769958),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Horizon Charter",'Palmer=' + Palmer.length); Big_Lake[Big_Lake.length] = createMarker(new GPoint(-149.44009399,61.58420181),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Houston High School",'Big_Lake=' + Big_Lake.length); Big_Lake[Big_Lake.length] = createMarker(new GPoint(-149.44009399,61.58420181),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Houston Middle School",'Big_Lake=' + Big_Lake.length); Wasilla[Wasilla.length] = createMarker(new GPoint(-149.44393921,61.58744431),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Iditarod Elementary School",'Wasilla=' + Wasilla.length); Wasilla[Wasilla.length] = createMarker(new GPoint(-149.40034485,61.61382294),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Larson Elementary School",'Wasilla=' + Wasilla.length); Palmer[Palmer.length] = createMarker(new GPoint(-149.11518860,61.59934235),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Mat-su Youth Facility",'Palmer=' + Palmer.length); Wasilla[Wasilla.length] = createMarker(new GPoint(-149.10594177,61.59273529),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Meadow Lakes Elementary School",'Wasilla=' + Wasilla.length); Wasilla[Wasilla.length] = createMarker(new GPoint(-149.56329346,61.56610107),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Mid-valley High School",'Wasilla=' + Wasilla.length); Wasilla[Wasilla.length] = createMarker(new GPoint(-149.43940735,61.58140182),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Midnight Sun Family Learning Center",'Wasilla=' + Wasilla.length); Palmer[Palmer.length] = createMarker(new GPoint(-149.11848450,61.60658264),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Palmer High School",'Palmer=' + Palmer.length); Palmer[Palmer.length] = createMarker(new GPoint(-149.11076355,61.59512711),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Palmer Middle School",'Palmer=' + Palmer.length); Palmer[Palmer.length] = createMarker(new GPoint(-149.22419739,61.62099838),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Pioneer Peak Elementary School",'Palmer=' + Palmer.length); Palmer[Palmer.length] = createMarker(new GPoint(-149.10360718,61.60970306),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Sherrod Elementary School",'Palmer=' + Palmer.length); Wasilla[Wasilla.length] = createMarker(new GPoint(-149.10594177,61.59273529),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Snowshoe Elementary School",'Wasilla=' + Wasilla.length); Talkeetna[Talkeetna.length] = createMarker(new GPoint(-149.23699951,62.25419998),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Susitna Valley High School",'Talkeetna=' + Talkeetna.length); Sutton[Sutton.length] = createMarker(new GPoint(-148.89410400,61.71129990),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Sutton Elementary School",'Sutton=' + Sutton.length); Palmer[Palmer.length] = createMarker(new GPoint(-149.10444641,61.61470413),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Swanson Elementary School",'Palmer=' + Palmer.length); Talkeetna[Talkeetna.length] = createMarker(new GPoint(-149.23699951,62.25419998),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Talkeetna Elementary School",'Talkeetna=' + Talkeetna.length); Wasilla[Wasilla.length] = createMarker(new GPoint(-149.45103455,61.60507965),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Tanaina Elementary School",'Wasilla=' + Wasilla.length); Wasilla[Wasilla.length] = createMarker(new GPoint(-149.40330505,61.58309937),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Teeland Middle School",'Wasilla=' + Wasilla.length); Trapper_Creek[Trapper_Creek.length] = createMarker(new GPoint(-150.53370667,62.24959946),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Trapper Creek Elementary School",'Trapper_Creek=' + Trapper_Creek.length); Wasilla[Wasilla.length] = createMarker(new GPoint(-149.44320200,61.58424800),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Twindly-bridge Charter School",'Wasilla=' + Wasilla.length); Palmer[Palmer.length] = createMarker(new GPoint(-149.11518860,61.59934235),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Valley Pathways",'Palmer=' + Palmer.length); Wasilla[Wasilla.length] = createMarker(new GPoint(-149.43122864,61.58667374),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Wasilla High School",'Wasilla=' + Wasilla.length); Wasilla[Wasilla.length] = createMarker(new GPoint(-149.43299866,61.58634186),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Wasilla Middle School",'Wasilla=' + Wasilla.length); Willow[Willow.length] = createMarker(new GPoint(-150.08270264,61.74560165),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Willow Elementary School",'Willow=' + Willow.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(Big_Lake); map.removeOverlays(Palmer); map.removeOverlays(Sutton); map.removeOverlays(Talkeetna); map.removeOverlays(Trapper_Creek); map.removeOverlays(Wasilla); map.removeOverlays(Willow); 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(Palmer);map.removeOverlays(Big_Lake); map.removeOverlays(Palmer); map.removeOverlays(Sutton); map.removeOverlays(Talkeetna); map.removeOverlays(Trapper_Creek); map.removeOverlays(Wasilla); map.removeOverlays(Willow); map.addOverlays(Big_Lake); centerByArray(Big_Lake, false, false); cntMarker += Big_Lake.length; map.addOverlays(Palmer); centerByArray(Palmer, false, false); cntMarker += Palmer.length; map.addOverlays(Sutton); centerByArray(Sutton, false, false); cntMarker += Sutton.length; map.addOverlays(Talkeetna); centerByArray(Talkeetna, false, false); cntMarker += Talkeetna.length; map.addOverlays(Trapper_Creek); centerByArray(Trapper_Creek, false, false); cntMarker += Trapper_Creek.length; map.addOverlays(Wasilla); centerByArray(Wasilla, false, false); cntMarker += Wasilla.length; map.addOverlays(Willow); centerByArray(Willow, false, false); cntMarker += Willow.length; centerByArray(Palmer,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'); } }