//pull these out so i can grab them elsewhere var map; var allMarkers = []; var layer; var polygon; var overlay; var bounds = new google.maps.LatLngBounds(); var minilocs=[]; var locations = []; var allMarkersMin = []; var allMarkersEvent = []; var eventlocations = []; function getsetcookie() { try { var mapzoom=map.getZoom(); var mapcenter=map.getCenter(); var maplat=mapcenter.lat(); var maplng=mapcenter.lng(); var maptypeid=map.getMapTypeId(); var cookiestring=maplat+"_"+maplng+"_"+mapzoom+"_"+maptypeid; var exp = new Date(); //set new date object exp.setTime(exp.getTime() + (1000 * 60 * 60 * 24 * 90)); //set it 30 days ahead // // console.log("cookie:"+cookiestring); setCookie("yycbeerlastpos",cookiestring,exp); } catch(e) { // alert('The browser you are using is not a fully functional browser,some features may not be available.'); } } function setCookie(name,value,expires) { document.cookie = name + "=" + escape(value) + "; path=/" + ((expires == null) ? "" : "; expires=" + expires.toGMTString()); } function toggleLayer() { $("#layeron").toggleClass('layeron layeroff'); if( layer.getMap() ){ layer.setMap(null); }else{ layer.setMap(map); } } function toggletips() { $("#mtipson").toggleClass('layeron layeroff'); if( layer.getMap() ){ layer.setMap(null); }else{ layer.setMap(map); } } var tipObj = null; var offset = {x: 20,y: 20}; function poponly() { window.scrollTo(0,0); google.maps.event.trigger(allMarkers[0],'click'); } function dobounds() { map.fitBounds(bounds); } function popmapbyid(id) { // map.setZoom(17); // setTimeout("map.setZoom(16)",1000); var index = id; google.maps.event.trigger(allMarkers[index],'click'); } (function ($) { "use strict"; var markerIcon = { anchor: new google.maps.Point(22,16),url: '/images/marker.png' } setTimeout("getsetcookie()",10000); function mainMap() { function locationData(locationURL,locationCategory,locationImg,locationTitle,locationAddress,locationPhone,locationStarRating,locationRevievsCounter,tagline) { if (locationCategory.length <4) {locationCategory ='Brewery';} return ('
' + locationCategory + '

' + locationTitle + '

'+ tagline +'
' + locationAddress + '' + locationPhone + '' + locationRevievsCounter + ' Taps' + '
') } function locationDatamini(locationURL,locationCategory,locationImg,locationTitle,locationAddress,locationPhone,locationStarRating,locationRevievsCounter,tagline) { if (locationCategory=="Alcohol In City Parks") { if (locationRevievsCounter !=="0") { console.log("pkbid"); var pkbid= "#" + locationRevievsCounter + " p.bookings"; console.log("pkbid",pkbid); var pv = $(pkbid).html(); } else { console.log("pkbid=00"); } if (pv == "undefined" || pv == undefined || !pv) { pv = "Visit The #YYCParkBeers For Booking Details." } return ('
' + locationCategory + '

' + locationTitle + '

'+ tagline +'
' + locationAddress + '' + pv + '
'); } else{ return ('
' + locationCategory + '

' + locationTitle + '

'+ tagline +'
' + locationAddress + '' + locationPhone + '
') } } minilocs = [ //poi-map starts [locationDatamini('/noticed_venue/Confluence_Distilling/51.0212758/-114.0533179/6/Craft_Beer_Calgary/','Top Spot','/images/pois/confluence_distilling_calgary.png','Confluence Distilling'," 507 36th AVE SE,Calgary ","(587)771-1286","5","0","Distillery in the heart of Calgary,handcrafting small-batch Gin\'s and more! Visit the Distillery for a craft cocktail,or grab a limited release spirit."),51.0212758,-114.0533179,4,{ anchor: new google.maps.Point(22,16),url: 'http://yycbeer.ca/mapicons/bar_coktail.png' }], ]; //events map. one at a time function eventlocationData(locationURL,locationCategory,locationImg,locationTitle,locationAddress,locationPhone,locationStarRating,locationRevievsCounter,tagline) { return ('
' + locationCategory + '

' + locationTitle + '

'+ tagline +'
' + locationAddress + 'Visit Poutine With A Purpose!
') } eventlocations = [ ]; //end events map locations = [ [locationData('/calgary_brewery_profile/44/Eighty-Eight_Brewing_Company/','Fills,Pints,Bottles,Merch','/markerbacking.asp?status=3&id=44','Eighty-Eight Brewing Company'," 1070 - 2600 Portland St SE ","403-452-5880","5","32","In the spirit of Calgary '88"),51.031135,-114.0322188,0,{ anchor: new google.maps.Point(22,16),url: '/custommarker.asp?id=44&status=3'},'Eighty-Eight Brewing Company',3,51.031135,-114.0322188,44 ], [locationData('/calgary_brewery_profile/23/Cold_Garden_Beverage_Company/','Pints,Fills,Lounge','/markerbacking.asp?status=2&id=23','Cold Garden Beverage Company'," 1100 11 St SE ","403-764-2653","5","10","Inglewood based micro-brewery and tasting room"),51.039746,-114.036862,1,{ anchor: new google.maps.Point(22,16),url: '/custommarker.asp?id=23&status=2'},'Cold Garden Beverage Company',2,51.039746,-114.036862,23 ], [locationData('/calgary_brewery_profile/26/High_Line_Brewing/','','/markerbacking.asp?status=2&id=26','High Line Brewing'," #113 - 1318 9th Avenue S.E ","587-786-2337","5","0","LOCALLY BREWED AND CRAFTED IN INGLEWOOD"),51.0408886,-114.0330473,2,{ anchor: new google.maps.Point(22,16),url: '/custommarker.asp?id=26&status=2'},'High Line Brewing',2,51.0408886,-114.0330473,26 ], [locationData('/calgary_brewery_profile/10/Ol_Beautiful_Brewing_Co/','Fills,Pints,Snacks','/markerbacking.asp?status=2&id=10','Ol` Beautiful Brewing Co.'," 1103 12 St SE ","403-978-4721","5","8","Now Open! - WE PUT CRAFT FIRST"),51.03958,-114.036338,3,{ anchor: new google.maps.Point(22,16),url: '/custommarker.asp?id=10&status=2'},'Ol` Beautiful Brewing Co.',2,51.03958,-114.036338,10 ], [locationData('/calgary_brewery_profile/37/The_Dandy_Brewing_Company_And_Tasting_Room/','Brewery Restaurant','/markerbacking.asp?status=2&id=37','The Dandy Brewing Company And Tasting Room'," 2003 11 St SE ","403-769-9399","5","20",""),51.035139,-114.0371571,4,{ anchor: new google.maps.Point(22,16),url: '/custommarker.asp?id=37&status=2'},'The Dandy Brewing Company And Tasting Room',2,51.035139,-114.0371571,37 ], [locationData('/calgary_brewery_profile/34/Burn_Block_Social/','','/markerbacking.asp?status=1&id=34','Burn Block Social'," 1217B 9 Ave SE ","587-893-2337","5","8","Formerly Revival Brewcade"),51.0415675,-114.0357889,5,{ anchor: new google.maps.Point(22,16),url: '/custommarker.asp?id=34&status=1'},'Burn Block Social',1,51.0415675,-114.0357889,34 ] ]; var cooks = getCookie("yycbeerlastpos"); // console.log(cooks); if (cooks !="") { cooks = cooks.split("_"); var cookz = Number(cooks[2]); var cooklat = Number(cooks[0]); var cooklon = Number(cooks[1]); //if (cooklat > 52 || cooklat < 50) { //cooklat = 51.0228354; //} //if (cooklon < -115 || cooklat > -112) { //cooklon = -114.0536417 //} } else { var cookz = 13; var cooklat = 51.0228354; var cooklon = -114.0536417; } map = new google.maps.Map(document.getElementById('map-main'),{ zoom: cookz, scrollwheel: true, center: new google.maps.LatLng(cooklat,cooklon), mapTypeId: google.maps.MapTypeId.ROADMAP, zoomControl: false, mapTypeControl: false, scaleControl: false, panControl: false, fullscreenControl: true, navigationControl: false, streetViewControl: false, animation: google.maps.Animation.BOUNCE, gestureHandling: 'greedy', styles: [{ "featureType": "administrative", "elementType": "labels.text.fill", "stylers": [{ "color": "#444444" }] }] }); dobounds(); map.addListener('center_changed',function() { getsetcookie(); }); map.addListener('zoom_changed',function() { // console.log('Zoom: ' + map.getZoom()); getsetcookie(); var aoms = []; aoms = oms.getMarkers(); for(i = 0 ; i< aoms.length; i++) { //// console.log(oms.getMarkers()); } var zoom = map.getZoom(); for (i = 0; i < minilocs.length; i++) { //markers[i].setVisible(zoom <= 15); if (zoom >= 15) { allMarkersMin[i].setVisible(true); } else { allMarkersMin[i].setVisible(false); } // console.log(zoom); //// console.log(allMarkersMin[i].setVisible()); // console.log(allMarkersMin[i]); } }); // // // // function openAllClusters() { var markers = oms.markersNearAnyOtherMarker(); $.each(markers,function (i,marker) { google.maps.event.trigger(markers[i],'spider_click'); }); setTimeout(openAllClusters,200); } setTimeout(openAllClusters,2000); // // // // var legend = document.createElement('div'); legend.id = 'legend'; var content = []; content.push('

'); legend.innerHTML = content.join(''); map.controls[google.maps.ControlPosition.LEFT_TOP].push(legend); legend.index = 1; layer = new google.maps.FusionTablesLayer({ map: map, heatmap: { enabled: false }, query: { select: "col2", from: "11WUGDwMb62zuS2NfmQS2rkqIzVBj388UfilKfYDv", where: "" }, options: { styleId: 2, templateId: 2 } }); // // console.log(layer); layer.setMap(null); var boxText = document.createElement("div"); boxText.className = 'map-box' var currentInfobox; var boxOptions = { content: boxText, disableAutoPan: true, alignBottom: true, maxWidth: 0, pixelOffset: new google.maps.Size(-145,-45), zIndex: null, boxStyle: { width: "260px" }, closeBoxMargin: "0", closeBoxURL: "", infoBoxClearance: new google.maps.Size(1,1), isHidden: false, pane: "floatPane", enableEventPropagation: false, }; var markerCluster,marker,i; var clusterStyles = [{ textColor: 'white', url: '', height: 50, width: 50 }]; var clusterStylesMin = [{ textColor: 'white', url: '', height: 5, width: 5 }]; var oms = new OverlappingMarkerSpiderfier(map,{ keepSpiderfied:true, markersWontMove: true,// we promise not to move any markers,allowing optimizations markersWontHide: true,// we promise not to change visibility of any markers,allowing optimizations basicFormatEvents: true // allow the library to skip calculating advanced formatting information }); for (i = 0; i < minilocs.length; i++) { marker = new google.maps.Marker({ position: new google.maps.LatLng(minilocs[i][1],minilocs[i][2]), icon: minilocs[i][4], map: map }); allMarkersMin.push(marker); var ib = new InfoBox(); google.maps.event.addListener(ib,"domready",function () { cardRaining() }); google.maps.event.addListener(marker,'click',(function (marker,i) { return function () { ib.setOptions(boxOptions); boxText.innerHTML = minilocs[i][0]; ib.close(); ib.open(map,marker); currentInfobox = marker.id; var latLng = new google.maps.LatLng(minilocs[i][1],minilocs[i][2]); map.panTo(latLng); map.panBy(0,-180); google.maps.event.addListener(ib,'domready',function () { $('.infoBox-close').click(function (e) { e.preventDefault(); ib.close(); }); }); } })(marker,i)); } for (i = 0; i < eventlocations.length; i++) { marker = new google.maps.Marker({ position: new google.maps.LatLng(eventlocations[i][1],eventlocations[i][2]), icon: '/images/poutine-icon.png', name:eventlocations[i][5], adminstatus:eventlocations[i][6], lat:eventlocations[i][7], lng:eventlocations[i][8], id: i }); allMarkersEvent.push(marker); bounds.extend(marker.getPosition()); var ib = new InfoBox(); google.maps.event.addListener(ib,"domready",function () { cardRaining() }); oms.addMarker(marker); google.maps.event.addListener(marker,'click',(function (marker,i) { return function () { $("#legend").hide(); ib.setOptions(boxOptions); boxText.innerHTML = eventlocations[i][0]; ib.close(); ib.open(map,marker); currentInfobox = marker.id; var latLng = new google.maps.LatLng(eventlocations[i][1],eventlocations[i][2]); map.panTo(latLng); map.panBy(0,-180); google.maps.event.addListener(ib,'domready',function () { $('.infoBox-close').click(function (e) { e.preventDefault(); ib.close(); }); }); } })(marker,i)); } for (i = 0; i < locations.length; i++) { marker = new google.maps.Marker({ position: new google.maps.LatLng(locations[i][1],locations[i][2]), icon: locations[i][4], name:locations[i][5], adminstatus:locations[i][6], lat:locations[i][7], lng:locations[i][8], id: i, bid:locations[i][9] }); allMarkers.push(marker); bounds.extend(marker.getPosition()); var ib = new InfoBox(); google.maps.event.addListener(ib,"domready",function () { cardRaining() }); oms.addMarker(marker); google.maps.event.addListener(marker,'click',(function (marker,i) { return function () { // console.log('pop marker action.'); pophandler(locations[i][9]); $("#legend").hide(); ib.setOptions(boxOptions); boxText.innerHTML = locations[i][0]; ib.close(); ib.open(map,marker); currentInfobox = marker.id; var latLng = new google.maps.LatLng(locations[i][1],locations[i][2]); map.panTo(latLng); map.panBy(0,-180); google.maps.event.addListener(ib,'domready',function () { $('.infoBox-close').click(function (e) { e.preventDefault(); ib.close(); }); }); } })(marker,i)); } var coptions = { imagePath: 'images/', styles: clusterStyles, minClusterSize: 4, extra:'drew is extra' }; var optionsmin = { imagePath: 'images/', styles: clusterStylesMin, minClusterSize: 1000 }; // markerCluster = new MarkerClusterer(map,allMarkersMin,optionsmin); markerCluster = new MarkerClusterer(map,allMarkers,coptions); google.maps.event.addDomListener(window,"resize",function () { var center = map.getCenter(); google.maps.event.trigger(map,"resize"); map.setCenter(center); }); $('.nextmap-nav').click(function (e) { e.preventDefault(); map.setZoom(17); var index = currentInfobox; if (index + 1 < allMarkers.length) { google.maps.event.trigger(allMarkers[index + 1],'click'); } else { google.maps.event.trigger(allMarkers[0],'click'); } }); $('.prevmap-nav').click(function (e) { e.preventDefault(); map.setZoom(15); if (typeof (currentInfobox) == "undefined") { google.maps.event.trigger(allMarkers[allMarkers.length - 1],'click'); } else { var index = currentInfobox; if (index - 1 < 0) { google.maps.event.trigger(allMarkers[allMarkers.length - 1],'click'); } else { google.maps.event.trigger(allMarkers[index - 1],'click'); } } }); $('.map-item').click(function (e) { e.preventDefault(); map.setZoom(15); var index = currentInfobox; var marker_index = parseInt($(this).attr('href').split('#')[1],10); google.maps.event.trigger(allMarkers[marker_index],"click"); if ($(this).hasClass("scroll-top-map")){ $('html,body').animate({ scrollTop: $(".map-container").offset().top+ "-80px" },500) } else if ($(window).width()<1064){ $('html,body').animate({ scrollTop: $(".map-container").offset().top+ "-80px" },500) } }); var zoomControlDiv = document.createElement('div'); var zoomControl = new ZoomControl(zoomControlDiv,map); function ZoomControl(controlDiv,map) { zoomControlDiv.index = 1; map.controls[google.maps.ControlPosition.RIGHT_CENTER].push(zoomControlDiv); controlDiv.style.padding = '5px'; var controlWrapper = document.createElement('div'); controlDiv.appendChild(controlWrapper); var zoomInButton = document.createElement('div'); zoomInButton.className = "mapzoom-in"; controlWrapper.appendChild(zoomInButton); var zoomOutButton = document.createElement('div'); zoomOutButton.className = "mapzoom-out"; controlWrapper.appendChild(zoomOutButton); google.maps.event.addDomListener(zoomInButton,'click',function () { map.setZoom(map.getZoom() + 1); }); google.maps.event.addDomListener(zoomOutButton,'click',function () { map.setZoom(map.getZoom() - 1); }); } var infolocs = [ //["",51.0454191,-114.0715827,4,{ anchor: new google.maps.Point(22,16),url: 'http://yycbeer.ca/mapicons/restaurant.png' }], //["",51.045363,-114.0916535,4,{ anchor: new google.maps.Point(22,16),url: 'http://yycbeer.ca/mapicons/restaurant.png' }], //["",51.0359131,-114.0615035,4,{ anchor: new google.maps.Point(22,16),url: 'http://yycbeer.ca/mapicons/cycling.png' }], ]; for (i = 0; i < infolocs.length; i++) { marker = new google.maps.Marker({ position: new google.maps.LatLng(infolocs[i][1],infolocs[i][2]), icon: infolocs[i][4], map: map }); google.map.addListener('center_changed',function() { getsetcookie(); }); google.maps.event.addListener(marker,'click',function(e){ var keys = Object.keys(e); var x,y; for (var i = 0; i < keys.length; i++) { // console.log(e[keys[i]]); if (MouseEvent.prototype.isPrototypeOf(e[keys[i]])) { x = e[keys[i]].clientX; y = e[keys[i]].clientY; } } // console.log('clientx '+eval(e.va)); //deleteTooltip(e); injectTooltip(e,"test",x,y); }); //overlay.setMap(null); } } map = document.getElementById('map-main'); //map.fitBounds(bounds); // // console.log("bounds"); // // console.log(bounds); if (typeof (map) != 'undefined' && map != null) { google.maps.event.addDomListener(window,'load',mainMap); } function singleMap() { var myLatLng = { lng: $('#singleMap').data('longitude'), lat: $('#singleMap').data('latitude'), }; var smarkerIcon = { anchor: new google.maps.Point(22,16),url: $('#singleMap').data('icon') } var single_map = new google.maps.Map(document.getElementById('singleMap'),{ zoom: 14, center: myLatLng, scrollwheel: false, zoomControl: false, mapTypeControl: false, scaleControl: false, panControl: false, navigationControl: false, streetViewControl: false, styles: [{ "featureType": "landscape", "elementType": "all", "stylers": [{ "color": "#f2f2f2" }] }] }); var marker = new google.maps.Marker({ position: myLatLng, map: single_map, icon: smarkerIcon, gestureHandling: 'greedy', title: 'Our Location' }); function locationDatamini(locationURL,locationCategory,locationImg,locationTitle,locationAddress,locationPhone,locationStarRating,locationRevievsCounter,tagline) { if (locationCategory=="Alcohol In City Parks") { return ('
!!' + locationCategory + '

' + locationTitle + '

'+ tagline +'
' + locationAddress + '' + locationPhone + '
'); } else{ return ('
' + locationCategory + '

' + locationTitle + '

'+ tagline +'
' + locationAddress + '' + locationPhone + '
'); } } allMarkersMin = []; minilocs = [ //poi-map starts [locationDatamini('/noticed_venue/Confluence_Distilling/51.0212758/-114.0533179/6/Craft_Beer_Calgary/','Top Spot','/images/pois/confluence_distilling_calgary.png','Confluence Distilling'," 507 36th AVE SE,Calgary ","(587)771-1286","5","0","Distillery in the heart of Calgary,handcrafting small-batch Gin\'s and more! Visit the Distillery for a craft cocktail,or grab a limited release spirit."),51.0212758,-114.0533179,4,{ anchor: new google.maps.Point(22,16),url: 'http://yycbeer.ca/mapicons/bar_coktail.png' }], ]; var i=0; for (i = 0; i < minilocs.length; i++) { marker = new google.maps.Marker({ position: new google.maps.LatLng(minilocs[i][1],minilocs[i][2]), icon: minilocs[i][4], map: single_map }); allMarkersMin.push(marker); var ib = new InfoBox(); google.maps.event.addListener(ib,"domready",function () { cardRaining() }); google.maps.event.addListener(marker,'click',(function (marker,i) { return function () { ib.setOptions(boxOptions); boxText.innerHTML = minilocs[i][0]; ib.close(); ib.open(single_map,marker); currentInfobox = marker.id; var latLng = new google.maps.LatLng(minilocs[i][1],minilocs[i][2]); single_map.panTo(latLng); single_map.panBy(0,-180); google.maps.event.addListener(ib,'domready',function () { $('.infoBox-close').click(function (e) { e.preventDefault(); ib.close(); }); }); } })(marker,i)); } var zoomControlDiv = document.createElement('div'); var zoomControl = new ZoomControl(zoomControlDiv,single_map); function ZoomControl(controlDiv,single_map) { zoomControlDiv.index = 1; single_map.controls[google.maps.ControlPosition.RIGHT_CENTER].push(zoomControlDiv); controlDiv.style.padding = '5px'; var controlWrapper = document.createElement('div'); controlDiv.appendChild(controlWrapper); var zoomInButton = document.createElement('div'); zoomInButton.className = "mapzoom-in"; controlWrapper.appendChild(zoomInButton); var zoomOutButton = document.createElement('div'); zoomOutButton.className = "mapzoom-out"; controlWrapper.appendChild(zoomOutButton); google.maps.event.addDomListener(zoomInButton,'click',function () { single_map.setZoom(single_map.getZoom() + 1); }); google.maps.event.addDomListener(zoomOutButton,'click',function () { single_map.setZoom(single_map.getZoom() - 1); }); } } var single_map = document.getElementById('singleMap'); if (typeof (single_map) != 'undefined' && single_map != null) { google.maps.event.addDomListener(window,'load',singleMap); } })(this.jQuery); var coordPropName = null; function injectTooltip(event,data,x,y){ if(!tipObj && event){ //create the tooltip object tipObj = document.createElement("div"); tipObj.style.width = '100px'; tipObj.style.height = '40px'; tipObj.style.background = "white"; tipObj.style.borderRadius = "5px"; tipObj.style.padding = "10px"; tipObj.style.fontFamily = "Arial,Helvetica"; tipObj.style.textAlign = "center"; tipObj.innerHTML = data; // console.log('tip attempt'); //fix for the version issue eventPropNames = Object.keys(event); if(!coordPropName){ //discover the name of the prop with MouseEvent // console.log(eval(Object.keys)); // console.log(Object.keys("va")); for(var i in eventPropNames){ var name = eventPropNames[i]; // console.log(name); if(event[name] instanceof MouseEvent){ coordPropName = name; // console.log("--> mouse event in",coordPropName) break; } } } tipObj.style.zIndex = "8"; if(coordPropName){ //position it // console.log('propname='+coordPropName); tipObj.style.position = "fixed"; tipObj.style.top = event[coordPropName].clientY + window.scrollY + offset.y + "px"; tipObj.style.left = event[coordPropName].clientX + window.scrollX + offset.x + "px"; //add it to the body document.body.appendChild(tipObj); }else { tipObj.style.position = "fixed"; tipObj.style.top = y + "px"; tipObj.style.left = x + "px"; document.body.appendChild(tipObj); // console.log(x+' x '+y); // console.log(tipObj); } } } /******************************************************************** * moveTooltip(e) * update the position of the tooltip based on the event data ********************************************************************/ function moveTooltip(event){ if(tipObj && event && coordPropName){ //position it tipObj.style.top = event[coordPropName].clientY + window.scrollY + offset.y + "px"; tipObj.style.left = event[coordPropName].clientX + window.scrollX + offset.x + "px"; } } /******************************************************************** * deleteTooltip(e) * delete the tooltip if it exists in the DOM ********************************************************************/ function deleteTooltip(event){ if(tipObj){ //delete the tooltip if it exists in the DOM document.body.removeChild(tipObj); tipObj = null; } } function handler(e) { e = e || window.event; var pageX = e.pageX; var pageY = e.pageY; // IE 8 if (pageX === undefined) { pageX = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft; pageY = e.clientY + document.body.scrollTop + document.documentElement.scrollTop; } //// console.log(pageX,pageY); } // attach handler to the click event of the document if (document.attachEvent) document.attachEvent('mousemove',handler); else document.addEventListener('mousemove',handler); function pophandler(bid) { // console.log('zoomed on icon'); $.get( "/ajax/mpz/?"+bid,function( data ) { // console.log( data ); }); outterpophandler(bid); // console.log(bid); } // function getCookie(cname) { var name = cname + "="; var decodedCookie = decodeURIComponent(document.cookie); var ca = decodedCookie.split(';'); for(var i = 0; i