function addMarkers(){ mySelect = document.getElementById('selection'); Casper = [];Riverton = [];Torrington = [];Cheyenne = [];Powell = [];Sheridan = [];Rock_Springs = [];Laramie = [];mySelect.options[mySelect.options.length] = new Option("Casper Schools",'all=Casper'); mySelect.options[mySelect.options.length] = new Option("Cheyenne Schools",'all=Cheyenne'); mySelect.options[mySelect.options.length] = new Option("Laramie Schools",'all=Laramie'); mySelect.options[mySelect.options.length] = new Option("Powell Schools",'all=Powell'); mySelect.options[mySelect.options.length] = new Option("Riverton Schools",'all=Riverton'); mySelect.options[mySelect.options.length] = new Option("Rock Springs Schools",'all=Rock_Springs'); mySelect.options[mySelect.options.length] = new Option("Sheridan Schools",'all=Sheridan'); mySelect.options[mySelect.options.length] = new Option("Torrington Schools",'all=Torrington'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); var tmpLatLng=0; var tmpLen=0; tmpLatLng=new GLatLng(42.83396499999999917,-106.324342000000001); tmpLen=Casper.length; Casper[tmpLen] = createMarker(tmpLatLng,"
Casper College
125 College Dr
Casper, WY 82601

[ View School Profile ]
",iconGr); Casper[tmpLen].point = tmpLatLng; mySelect.options[mySelect.options.length] = new Option("Casper College",'Casper=' + Casper.length); tmpLatLng=new GLatLng(43.02969199999999716,-108.425740000000004); tmpLen=Riverton.length; Riverton[tmpLen] = createMarker(tmpLatLng,"
Central Wyoming College
2660 Peck Avenue
Riverton, WY 82501

[ View School Profile ]
",iconGr); Riverton[tmpLen].point = tmpLatLng; mySelect.options[mySelect.options.length] = new Option("Central Wyoming College",'Riverton=' + Riverton.length); tmpLatLng=new GLatLng(42.07300399999999740,-104.180543999999997); tmpLen=Torrington.length; Torrington[tmpLen] = createMarker(tmpLatLng,"
Eastern Wyoming College
3200 West C St
Torrington, WY 82240

[ View School Profile ]
",iconGr); Torrington[tmpLen].point = tmpLatLng; mySelect.options[mySelect.options.length] = new Option("Eastern Wyoming College",'Torrington=' + Torrington.length); tmpLatLng=new GLatLng(41.10218100000000163,-104.800323000000005); tmpLen=Cheyenne.length; Cheyenne[tmpLen] = createMarker(tmpLatLng,"
Laramie County Community College
1400 E College Dr
Cheyenne, WY 82007

[ View School Profile ]
",iconGr); Cheyenne[tmpLen].point = tmpLatLng; mySelect.options[mySelect.options.length] = new Option("Laramie County Community College",'Cheyenne=' + Cheyenne.length); tmpLatLng=new GLatLng(44.75950199999999767,-108.760908999999998); tmpLen=Powell.length; Powell[tmpLen] = createMarker(tmpLatLng,"
Northwest College
231 W 6th St
Powell, WY 82435

[ View School Profile ]
",iconGr); Powell[tmpLen].point = tmpLatLng; mySelect.options[mySelect.options.length] = new Option("Northwest College",'Powell=' + Powell.length); tmpLatLng=new GLatLng(44.76399800000000084,-106.944907999999998); tmpLen=Sheridan.length; Sheridan[tmpLen] = createMarker(tmpLatLng,"
Sheridan College
3059 S Coffeen Ave
Sheridan, WY 82801

[ View School Profile ]
",iconGr); Sheridan[tmpLen].point = tmpLatLng; mySelect.options[mySelect.options.length] = new Option("Sheridan College",'Sheridan=' + Sheridan.length); tmpLatLng=new GLatLng(41.58671600000000268,-109.232967000000002); tmpLen=Rock_Springs.length; Rock_Springs[tmpLen] = createMarker(tmpLatLng,"
Western Wyoming Community College
2500 College Drive
Rock Springs, WY 82901

[ View School Profile ]
",iconGr); Rock_Springs[tmpLen].point = tmpLatLng; mySelect.options[mySelect.options.length] = new Option("Western Wyoming Community College",'Rock_Springs=' + Rock_Springs.length); tmpLatLng=new GLatLng(41.34012899999999746,-105.590491000000000); tmpLen=Laramie.length; Laramie[tmpLen] = createMarker(tmpLatLng,"
Wyo Tech
4373 N 3rd
Laramie, WY 82072

[ View School Profile ]
",iconRd); Laramie[tmpLen].point = tmpLatLng; mySelect.options[mySelect.options.length] = new Option("Wyo Tech",'Laramie=' + Laramie.length); map.removeOverlays(Casper); map.removeOverlays(Cheyenne); map.removeOverlays(Laramie); map.removeOverlays(Powell); map.removeOverlays(Riverton); map.removeOverlays(Rock_Springs); map.removeOverlays(Sheridan); map.removeOverlays(Torrington); setTimeout(function(){map.addOverlays(Casper)},1000); setTimeout(function(){map.addOverlays(Cheyenne)},1000); setTimeout(function(){map.addOverlays(Laramie)},1000); setTimeout(function(){map.addOverlays(Powell)},1000); setTimeout(function(){map.addOverlays(Riverton)},1000); setTimeout(function(){map.addOverlays(Rock_Springs)},1000); setTimeout(function(){map.addOverlays(Sheridan)},1000); setTimeout(function(){map.addOverlays(Torrington)},1000); getPoly("","state","","WY");} // End addStateMarkers JavaScript Function //open all when map is defined function openAll() { if (map) { selectChange("all"); } else { setTimeout("openAll()",200); } } // 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].point.x; var markLat = myArray[i].point.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].point.x; maxLat = myArray[0].point.y; minLng = myArray[0].point.x; minLat = myArray[0].point.y; } // Recenter map based on global max/mins function reCenterMap(){ //alert('#' + minLat + '#' + minLng + '#' + maxLat + '#' + maxLng); 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) { if (selection.options) { var _openNewWindow=true; var myVal = selection.options[selection.selectedIndex].value; } else { var _openNewWindow=false; var myVal=selection; } 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('schools-by-distance') == -1) window.open(location.href + '/map/all'); else window.open('/search////all'); map.removeOverlays(Casper); map.removeOverlays(Cheyenne); map.removeOverlays(Laramie); map.removeOverlays(Powell); map.removeOverlays(Riverton); map.removeOverlays(Rock_Springs); map.removeOverlays(Sheridan); map.removeOverlays(Torrington); 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(Casper);map.removeOverlays(Casper); map.removeOverlays(Cheyenne); map.removeOverlays(Laramie); map.removeOverlays(Powell); map.removeOverlays(Riverton); map.removeOverlays(Rock_Springs); map.removeOverlays(Sheridan); map.removeOverlays(Torrington); map.addOverlays(Casper); centerByArray(Casper, false, false); cntMarker += Casper.length; map.addOverlays(Cheyenne); centerByArray(Cheyenne, false, false); cntMarker += Cheyenne.length; map.addOverlays(Laramie); centerByArray(Laramie, false, false); cntMarker += Laramie.length; map.addOverlays(Powell); centerByArray(Powell, false, false); cntMarker += Powell.length; map.addOverlays(Riverton); centerByArray(Riverton, false, false); cntMarker += Riverton.length; map.addOverlays(Rock_Springs); centerByArray(Rock_Springs, false, false); cntMarker += Rock_Springs.length; map.addOverlays(Sheridan); centerByArray(Sheridan, false, false); cntMarker += Sheridan.length; map.addOverlays(Torrington); centerByArray(Torrington, false, false); cntMarker += Torrington.length; reCenterMap(); //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'); } } function createMarker(point, label, icon){ var marker = new GMarker(point, icon); var html = label; GEvent.addListener(marker, "click", function() { marker.openInfoWindowHtml(html); }); return marker; }