var map; var markers = []; var iconCat1; var iconCat2; var iconCat3; var iconCat4; var iconCat5; var iconBlank; var infoWindows = []; var dynLatlng = []; var mapPano; var activeInfoWindow = ""; var activeMarkers = []; function InitializeMap() { var mapOptions = { zoom: 5, center: new google.maps.LatLng(32.295819, -90.190261), mapTypeId: google.maps.MapTypeId.ROADMAP, streetViewControl: true, // How you would like to style the map. // This is where you would paste any style found on Snazzy Maps. styles: [ {'featureType':'poi','elementType':'labels','stylers':[{'visibility':'off'}]}, {'featureType':'water',stylers:[{hue:'#4F6BA7'}]}, {'featureType':'landscape',stylers:[{hue:'#D6C8AD'}]}, {'featureType':'road.local','elementType':'geometry','stylers':[{'color':'#CBA679'}]}, {'featureType':'road.local','elementType':'labels.text.fill','stylers':[{'color':'#ffffff'}]}, {'featureType':'road.local','elementType':'labels.text.stroke','stylers':[{'color':'#887155'}]}, {'featureType':'road.arterial','elementType':'geometry','stylers':[{'color':'#CBA679'}]}, {'featureType':'road.arterial','elementType':'labels.text','stylers':[{'color':'#ffffff'}]}, {'featureType':'road.arterial','elementType':'labels.text.stroke','stylers':[{'color':'#887155'}]}, {'featureType':'transit.line','elementType':'geometry','stylers':[{'visibility':'on'}]}, {'featureType':'transit.line','elementType':'geometry.stroke','stylers':[{'color':'#808080'},{'visibility':'on'},{'weight':2}]}, {'featureType':'transit.line','elementType':'geometry.fill','stylers':[{'weight':2}]} ] }; // initiate the map map = new google.maps.Map(document.getElementById("GMapCanvas"), mapOptions); // Setup streetview mapPano = map.getStreetView(); mapPano.setOptions({ visible: false }); // set icons iconCat3 = new google.maps.MarkerImage('/images/icons/pin_cat3.png', new google.maps.Size(30, 30), new google.maps.Point(0,0), new google.maps.Point(14, 30)); iconCat2 = new google.maps.MarkerImage('/images/icons/pin_cat2.png', new google.maps.Size(30, 30), new google.maps.Point(0,0), new google.maps.Point(14, 30)); iconCat4 = new google.maps.MarkerImage('/images/icons/pin_cat4.png', new google.maps.Size(30, 30), new google.maps.Point(0,0), new google.maps.Point(14, 30)); iconCat1 = new google.maps.MarkerImage('/images/icons/pin_cat1.png', new google.maps.Size(30, 30), new google.maps.Point(0,0), new google.maps.Point(14, 30)); iconCat5 = new google.maps.MarkerImage('/images/icons/pin_cat5.png', new google.maps.Size(30, 30), new google.maps.Point(0,0), new google.maps.Point(14, 30)); iconBlank = new google.maps.MarkerImage('/images/interface/spacer.gif', new google.maps.Size(1, 1), new google.maps.Point(0,0), new google.maps.Point(14, 30)); // set icon shadow //var shadow = new google.maps.MarkerImage('/images/icons/tsusa_pin_shadow.png', new google.maps.Size(46, 30), new google.maps.Point(0,0), new google.maps.Point(16, 30)); // get all the markers from the DB markers[0] = SetMarker(0, 48, 39.09048, -108.56271, 'St. Mary’s Hospital', 'cat3', '4'); markers[1] = SetMarker(1, 47, 39.120927, -108.320748, 'Palisade Rim', 'cat1', '1'); markers[2] = SetMarker(2, 46, 39.177903, -108.827506, 'Kokopelli (Loma)', 'cat1', '1'); markers[3] = SetMarker(3, 45, 39.309986, -108.706210, '18 Road Trailhead (Zippity Edge)', 'cat1', '1'); markers[4] = SetMarker(4, 44, 39.050006, -108.605514, 'Lunch Loops (Tabegauche/Monument Road trailhead)', 'cat1', '1'); markers[5] = SetMarker(5, 43, 39.028942, -108.048675, 'Mesa Top', 'cat1', '1'); markers[6] = SetMarker(6, 42, 38.997119, -108.110763, 'Carson Lake', 'cat1', '1'); markers[7] = SetMarker(7, 41, 38.954961, -108.104300, 'Flowing Park Reservoir', 'cat1', '1'); markers[8] = SetMarker(8, 40, 38.960957, -108.231110, 'Kannah Creek Road', 'cat1', '1'); markers[9] = SetMarker(9, 39, 39.099046, -108.348257, 'Palisade Section', 'cat1', '1'); markers[10] = SetMarker(10, 38, 39.055652, -108.491944, 'Clifton Nature Park Section', 'cat1', '1'); markers[11] = SetMarker(11, 37, 39.055652, -108.491944, 'Parks & Wildlife Section', 'cat1', '1'); markers[12] = SetMarker(12, 36, 39.054050, -108.556874, 'Las Colonias Section', 'cat1', '1'); markers[13] = SetMarker(13, 35, 39.061563, -108.575646, 'Riverside Section', 'cat1', '1'); markers[14] = SetMarker(14, 34, 39.069833, -108.599469, 'Audubon Section', 'cat1', '1'); markers[15] = SetMarker(15, 33, 39.089847, -108.611698, 'Blue Heron Section', 'cat1', '1'); markers[16] = SetMarker(16, 32, 39.077388, -108.608267, 'Connected Lakes Section', 'cat1', '1'); markers[17] = SetMarker(17, 31, 39.118581, -108.664081, 'Monument View Section', 'cat1', '1'); markers[18] = SetMarker(18, 30, 39.09763, -108.58682, 'Western Colorado Community College', 'cat2', '2'); markers[19] = SetMarker(19, 29, 39.07890, -108.55412, 'Colorado Mesa University', 'cat2', '3'); markers[20] = SetMarker(20, 28, 39.07629, -108.54102, 'VA Hospital', 'cat3', '13'); markers[21] = SetMarker(21, 26, 39.07814, -108.53366, 'MindSprings Hospital', 'cat3', '4'); markers[22] = SetMarker(22, 25, 39.16370, -108.73661, 'Family Health West', 'cat3', '4'); markers[23] = SetMarker(23, 24, 39.10520, -108.61527, 'Community Hospital', 'cat3', '4'); markers[24] = SetMarker(24, 23, 39.05752, -108.69390, 'Colorado National Monument', '', '10'); markers[25] = SetMarker(25, 22, 39.54642, -107.32440, 'Glenwood Springs', '', '10'); markers[26] = SetMarker(26, 21, 39.54511, -107.32450, 'Hanging Lake', '', '9'); markers[27] = SetMarker(27, 20, 38.57329, -109.55027, 'Arches National Parks', '', '8'); markers[28] = SetMarker(28, 19, 38.57329, -109.55027, 'Westwater, UT', '', '10'); markers[29] = SetMarker(29, 18, 38.57329, -109.55078, 'Moab, UT', '', '10'); markers[30] = SetMarker(30, 17, 38.71744, -108.05516, 'Grand Mesa National Forest', '', '7'); markers[31] = SetMarker(31, 16, 39.06938, -108.15408, 'Powderhorn Ski Resort', 'cat4', '5'); markers[32] = SetMarker(32, 15, 37.93768, -107.81345, 'Telluride Ski Resort', 'cat4', '5'); markers[33] = SetMarker(33, 14, 38.899791, -106.965463, 'Crested Butte Ski Resort', 'cat4', '5'); markers[34] = SetMarker(34, 13, 39.60614, -106.35497, 'Vail Ski Resort', 'cat4', '5'); markers[35] = SetMarker(35, 12, 39.220757, -106.862223, 'Aspen Mountain Ski Resort', 'cat4', '5'); markers[36] = SetMarker(36, 11, 39.08006, -108.50466, 'Mesa County Workforce Center', '', '12'); markers[37] = SetMarker(37, 10, 39.06762, -108.55966, 'Factory Coworking', '', '12'); markers[38] = SetMarker(38, 9, 39.04198, -108.57284, 'Business Incubator Center', '', '11'); markers[39] = SetMarker(39, 8, 39.07058, -108.56641, 'GJ Chamber', 'cat5', '6'); markers[40] = SetMarker(40, 7, 39.15859, -108.72933, 'Fruita Chamber', 'cat5', '6'); markers[41] = SetMarker(41, 6, 39.11004, -108.35076, 'Palisade Chamber', 'cat5', '6'); if (window.location.search.substring(1).indexOf("id=") != -1) { var thisID = window.location.search.substring(1).split("=")[1]; // set the markers on the map activeMarkers = []; var k = 0; for(i = 0; i < markers.length; i++) { if (markers[i].id == thisID) { k = i; markers[i].setMap(map); activeMarkers.push(markers[i]); CenterMap(); } else {markers[i].setMap(null);} } infoWindows[k].open(map, markers[k]); activeInfoWindow = infoWindows[k]; // center the map around the markers CenterMap(); } else if (markers[0] && !markers[1]) { activeMarkers = []; markers[0].setMap(map); activeMarkers.push(markers[0]); CenterMap(); infoWindows[0].open(map, markers[0]); } else if (markers[0] && markers[1]) { // set the markers on the map activeMarkers = []; for(i = 0; i < markers.length; i++) { markers[i].setMap(null); activeMarkers.push(markers[i]); } // center the map around the markers CenterMap(); } else { document.getElementById('GMapNoResults').style.display = 'block'; } // Remove preloader var x = setTimeout(function(){ document.getElementById('GMapPreloader').style.display = 'none'; return; },1000); } function SetMarker(mrkrIndex, mrkrID, mrkrLat, mrkrLng, mrkrTitle, mrkrCat, mrkrSubCat) { // set the marker icon based on category var thisIcon = null; if (mrkrCat == "cat3") { thisIcon = iconCat3; } else if (mrkrCat == "cat2") { thisIcon = iconCat2; } else if (mrkrCat == "cat4") { thisIcon = iconCat4; } else if (mrkrCat == "cat1") { thisIcon = iconCat1; } else if (mrkrCat == "cat5") { thisIcon = iconCat5; } else if (mrkrCat == "blank") { thisIcon = iconBlank; } // setup the marker var mrkr = new google.maps.Marker({ position: new google.maps.LatLng(mrkrLat, mrkrLng), map: map, title: mrkrTitle, icon: thisIcon }); // setup the marker's info windows infoWindows[mrkrIndex] = new google.maps.InfoWindow({ content: "", size: new google.maps.Size(350,175) }); // this click pops open the info window google.maps.event.addListener(mrkr, 'click', function() { HideActiveInfoWindow(); infoWindows[mrkrIndex].open(map, mrkr); //map.setCenter(mrkr.getPosition()); activeInfoWindow = infoWindows[mrkrIndex]; }); // this double click opens the info window and zooms in google.maps.event.addListener(mrkr, 'dblclick', function() { mapPano.setPosition(new google.maps.LatLng(mrkrLat, mrkrLng)); mapPano.setOptions({ visible: true }); }); // set the marker attributes mrkr.id = mrkrID; mrkr.name = mrkrTitle; mrkr.cat = mrkrCat; mrkr.subcat = mrkrSubCat; return mrkr; } function HideActiveInfoWindow() { if(activeInfoWindow) {activeInfoWindow.close();} } function CenterMap() { if (markers[0]) { var latlngbounds = new google.maps.LatLngBounds() for (var i = 0; i < activeMarkers.length; i++) {latlngbounds.extend(activeMarkers[i].getPosition());} map.setCenter(latlngbounds.getCenter(), map.fitBounds(latlngbounds)); } } function ShowAllMarkers() { HideActiveInfoWindow(); if (markers[0]) { activeMarkers = []; for(k = 0; k < markers.length; k++) { markers[k].setMap(map); activeMarkers.push(markers[k]); } } } function ResetMap() { HideActiveInfoWindow(); ShowAllMarkers(); CenterMap() UnCheckAll(); document.getElementById('GMapNoResults').style.display = "none"; } function ToggleZeroRes() { HideActiveInfoWindow(); var zeroObj = document.getElementById('GMapNoResults'); if(zeroObj.style.display == 'none') { zeroObj.style.display = 'block'; var x = setTimeout(function(){ResetMap()},5000); } else { zeroObj.style.display = 'none'; } return; } function CheckAll() { HideActiveInfoWindow(); var oldCat = ""; activeMarkers = []; for(i = 0; i < markers.length; i++) { markers[i].setMap(map); activeMarkers.push(markers[i]); var newCat = markers[i].cat; if(oldCat == "" || oldCat != newCat) { document.getElementById("chk" + newCat).checked = true; document.getElementById("chk" + newCat + "DD").checked = true; var checkBoxes = document.getElementsByName("chk" + newCat); for(j = 0; j < checkBoxes.length; j++) { checkBoxes[j].checked = true;; } } oldCat = newCat; } } function UnCheckAll() { HideActiveInfoWindow(); var oldCat = ""; activeMarkers = []; for(i = 0; i < markers.length; i++) { markers[i].setMap(map); activeMarkers.push(markers[i]); var newCat = markers[i].cat; if(oldCat == "" || oldCat != newCat) { document.getElementById("chk" + newCat).checked = false; document.getElementById("chk" + newCat + "DD").checked = false; var checkBoxes = document.getElementsByName("chk" + newCat); for(j = 0; j < checkBoxes.length; j++) { checkBoxes[j].checked = false;; } } oldCat = newCat; } } function SearchText() { HideActiveInfoWindow(); var oSearch = document.getElementById("txtSearch"); var searchString = oSearch.value; activeMarkers = []; for(k = 0; k < markers.length; k++) { if(markers[k].name.toLowerCase().indexOf(searchString.toLowerCase()) == -1) {markers[k].setMap(null);} else { markers[k].setMap(map); activeMarkers.push(markers[k]); } } if (activeMarkers.length == 0) document.getElementById('GMapNoResults').style.display = 'block'; CenterMap(); } function ToggleCatChk(theCheckbox, catName, toggle) { HideActiveInfoWindow(); theCheckbox.checked = !theCheckbox.checked; if(toggle) { ToggleMarkers(theCheckbox, catName) } } function ToggleMarkers(theCheckbox, catName) { HideActiveInfoWindow(); activeMarkers = []; for(k = 0; k < markers.length; k++) { if(theCheckbox.checked && markers[k].cat == catName) {markers[k].setMap(map);} else if(!theCheckbox.checked && markers[k].cat == catName) { markers[k].setMap(null); activeMarkers.push(markers[k]); } } var checkBoxes = document.getElementsByName("chk" + catName); for(j =0; j < checkBoxes.length; j++) { if(theCheckbox.checked) { checkBoxes[j].checked = true; } else { checkBoxes[j].checked = false; } } document.getElementById("chk" + catName).checked = theCheckbox.checked; document.getElementById("chk" + catName + "DD").checked = theCheckbox.checked; } function ToggleSubMarkers(theCheckbox, catName, subCatName) { HideActiveInfoWindow(); activeMarkers = []; for(k = 0; k < markers.length; k++) { if(markers[k].subcat == subCatName && markers[k].cat == catName) { if(theCheckbox.checked) { markers[k].setMap(map); activeMarkers.push(markers[k]); } else {markers[k].setMap(null);} } } var checkBoxes = document.getElementsByName("chk" + catName); var count = 0; for(j = 0; j < checkBoxes.length; j++) { if(checkBoxes[j].checked) { count = count + 1; } } document.getElementById("chk" + catName + "DD").checked = count == checkBoxes.length; if( document.getElementById("chk" + catName).checked ) count = count - 1; document.getElementById("chk" + catName).checked = count > 0; } $(document).ready(function () { google.load("maps", "3", {callback: InitializeMap, other_params:"sensor=false"}); UnCheckAll(); });