function addMarkers() { mySelect = document.getElementById('selection'); Craig = [];Glennallen = [];Copper_Center = [];Kodiak = [];Homer = [];Petersburg = [];Metlakatla = [];Seward = [];Anchorage = [];mySelect.options[mySelect.options.length] = new Option("Anchorage schools",'all=Anchorage'); mySelect.options[mySelect.options.length] = new Option("Copper Center schools",'all=Copper_Center'); mySelect.options[mySelect.options.length] = new Option("Craig schools",'all=Craig'); mySelect.options[mySelect.options.length] = new Option("Glennallen schools",'all=Glennallen'); mySelect.options[mySelect.options.length] = new Option("Homer schools",'all=Homer'); mySelect.options[mySelect.options.length] = new Option("Kodiak schools",'all=Kodiak'); mySelect.options[mySelect.options.length] = new Option("Metlakatla schools",'all=Metlakatla'); mySelect.options[mySelect.options.length] = new Option("Petersburg schools",'all=Petersburg'); mySelect.options[mySelect.options.length] = new Option("Seward schools",'all=Seward'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Craig[Craig.length] = createMarker(new GPoint(-133.13349915,55.47909927),"
Craig Middle School
Box 800
Craig, AK 99921

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Craig Middle School",'Craig=' + Craig.length); Glennallen[Glennallen.length] = createMarker(new GPoint(-145.62950134,62.13909912),"
Glennallen Elementary School
Box 108
Glennallen, AK 99588

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Glennallen Elementary School",'Glennallen=' + Glennallen.length); Copper_Center[Copper_Center.length] = createMarker(new GPoint(-144.70339966,61.86199951),"
Kenny Lake School
Hc 60 Box 224
Copper Center, AK 99573

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Kenny Lake School",'Copper_Center=' + Copper_Center.length); Kodiak[Kodiak.length] = createMarker(new GPoint(-152.39561462,57.79416656),"
Main Elementary School
722 Mill Bay Road
Kodiak, AK 99615

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Main Elementary School",'Kodiak=' + Kodiak.length); Homer[Homer.length] = createMarker(new GPoint(-151.21711731,59.75477219),"
Mcneil Canyon Elementary School
52188 East End Road
Homer, AK 99603

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Mcneil Canyon Elementary School",'Homer=' + Homer.length); Petersburg[Petersburg.length] = createMarker(new GPoint(-133.81849670,57.24879837),"
Rae C. Stedman Elementary School
Box 289
Petersburg, AK 99833

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Rae C. Stedman Elementary School",'Petersburg=' + Petersburg.length); Metlakatla[Metlakatla.length] = createMarker(new GPoint(-131.57809448,55.11059952),"
Richard Johnson Elementary School
Po Box 7
Metlakatla, AK 99926

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Richard Johnson Elementary School",'Metlakatla=' + Metlakatla.length); Seward[Seward.length] = createMarker(new GPoint(-149.37530518,60.12480164),"
Seward Elementary School
Box 247
Seward, AK 99664

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Seward Elementary School",'Seward=' + Seward.length); Anchorage[Anchorage.length] = createMarker(new GPoint(-149.89288330,61.19784164),"
Steller Secondary School
2508 Blueberry Lane
Anchorage, AK 99503

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Steller Secondary School",'Anchorage=' + Anchorage.length); map.removeOverlays(Anchorage); map.removeOverlays(Copper_Center); map.removeOverlays(Craig); map.removeOverlays(Glennallen); map.removeOverlays(Homer); map.removeOverlays(Kodiak); map.removeOverlays(Metlakatla); map.removeOverlays(Petersburg); map.removeOverlays(Seward); setTimeout(function(){map.addOverlays(Anchorage)},1000); setTimeout(function(){map.addOverlays(Copper_Center)},1000); setTimeout(function(){map.addOverlays(Craig)},1000); setTimeout(function(){map.addOverlays(Glennallen)},1000); setTimeout(function(){map.addOverlays(Homer)},1000); setTimeout(function(){map.addOverlays(Kodiak)},1000); setTimeout(function(){map.addOverlays(Metlakatla)},1000); setTimeout(function(){map.addOverlays(Petersburg)},1000); setTimeout(function(){map.addOverlays(Seward)},1000); maxLng = -131.57809448; maxLat = 62.13909912; minLng = -152.39561462; minLat = 55.11059952; reCenterMap(); } // 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(Anchorage); map.removeOverlays(Copper_Center); map.removeOverlays(Craig); map.removeOverlays(Glennallen); map.removeOverlays(Homer); map.removeOverlays(Kodiak); map.removeOverlays(Metlakatla); map.removeOverlays(Petersburg); map.removeOverlays(Seward); 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(Craig);map.removeOverlays(Anchorage); map.removeOverlays(Copper_Center); map.removeOverlays(Craig); map.removeOverlays(Glennallen); map.removeOverlays(Homer); map.removeOverlays(Kodiak); map.removeOverlays(Metlakatla); map.removeOverlays(Petersburg); map.removeOverlays(Seward); map.addOverlays(Anchorage); centerByArray(Anchorage, false, false); cntMarker += Anchorage.length; map.addOverlays(Copper_Center); centerByArray(Copper_Center, false, false); cntMarker += Copper_Center.length; map.addOverlays(Craig); centerByArray(Craig, false, false); cntMarker += Craig.length; map.addOverlays(Glennallen); centerByArray(Glennallen, false, false); cntMarker += Glennallen.length; map.addOverlays(Homer); centerByArray(Homer, false, false); cntMarker += Homer.length; map.addOverlays(Kodiak); centerByArray(Kodiak, false, false); cntMarker += Kodiak.length; map.addOverlays(Metlakatla); centerByArray(Metlakatla, false, false); cntMarker += Metlakatla.length; map.addOverlays(Petersburg); centerByArray(Petersburg, false, false); cntMarker += Petersburg.length; map.addOverlays(Seward); centerByArray(Seward, false, false); cntMarker += Seward.length; centerByArray(Craig,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///1552,1468,1468,1476,1468,1467,1651,1674,1741,1807,1638,/all'); } }