function soGoogleMapInitialize(){new sowb.SiteOriginGoogleMap(jQuery).initMaps()}window.sowb=window.sowb||{},sowb.SiteOriginGoogleMapInstances=[],sowb.SiteOriginGoogleMap=function(e){return{DEFAULT_LOCATIONS:["Addo Elephant National Park, R335, Addo","Cape Town, Western Cape, South Africa","San Francisco Bay Area, CA, United States","New York, NY, United States"],showMap:function(e,o,t){var i=Number(t.zoom);i||(i=14),window.matchMedia("(max-width: "+t.breakpoint+"px)").matches&&(i=t.mobileZoom);var n,a={zoom:i,gestureHandling:t.gestureHandling,disableDefaultUI:t.disableUi,zoomControl:t.zoomControl,panControl:t.panControl,center:o,mapTypeControlOptions:{mapTypeIds:[google.maps.MapTypeId.ROADMAP,google.maps.MapTypeId.SATELLITE,"user_map_style"]}},s=new google.maps.Map(e,a),r={name:t.mapName},l=t.mapStyles;if(l){var p=new google.maps.StyledMapType(l,r);s.mapTypes.set("user_map_style",p),s.setMapTypeId("user_map_style")}(t.markerAtCenter&&(this.centerMarker=new google.maps.Marker({position:o,map:s,draggable:t.markersDraggable,icon:t.markerIcon,title:""}),s.centerMarker=this.centerMarker),t.keepCentered)&&(google.maps.event.addDomListener(s,"idle",(function(){n=s.getCenter()})),google.maps.event.addDomListener(window,"resize",(function(){s.setCenter(n)})));this.linkAutocompleteField(t.autocomplete,t.autocompleteElement,s,t),this.showMarkers(t.markerPositions,s,t),this.showDirections(t.directions,s,t),sowb.SiteOriginGoogleMapInstances.push(s)},linkAutocompleteField:function(o,t,i,n){if(o&&t){var a=function(e){this.inputAddress!==e&&(this.inputAddress=e,this.getLocation(this.inputAddress).done(function(e){i.setZoom(15),i.setCenter(e),this.centerMarker&&(this.centerMarker.setPosition(e),this.centerMarker.setTitle(this.inputAddress))}.bind(this)))}.bind(this),s=e(t);o.addListener("place_changed",function(){var e=o.getPlace();i.setZoom(15),e.geometry&&(i.setCenter(e.geometry.location),this.centerMarker&&this.centerMarker.setPosition(e.geometry.location))}.bind(this)),google.maps.event.addDomListener(t,"keypress",(function(e){"13"===(e.keyCode||e.which)&&e.preventDefault()})),s.on("focusin",function(){if(!this.resultsObserver){var o=document.querySelector(".pac-container");this.resultsObserver=new MutationObserver((function(){var o=e(e(".pac-item").get(0)),t=o.find(".pac-item-query").text(),i=o.find("span").not("[class]").text(),n=t+(i?", "+i:"");n&&a(n)}));this.resultsObserver.observe(o,{attributes:!0,childList:!0,characterData:!0})}}.bind(this));var r=function(e){this.getGeocoder().geocode({location:e},function(o,t){if(t===google.maps.GeocoderStatus.OK&&o.length>0){var i=o[0].formatted_address;s.val(i),this.centerMarker&&(this.centerMarker.setPosition(e),this.centerMarker.setTitle(i))}}.bind(this))}.bind(this);i.addListener("click",(function(e){r(e.latLng)})),this.centerMarker.addListener("dragend",(function(e){r(e.latLng)}))}},showMarkers:function(e,o,t){if(e&&e.length){this.infoWindows=[];for(var i=[],n=0;n0){var s=a.data("options");s.autocomplete=n,s.autocompleteElement=i,this.getLocation(s.address).done(function(e){this.showMap(a.get(0),e,s),a.data("initialized",!0),t.resolve()}.bind(this)).fail((function(){a.append("

"+soWidgetsGoogleMap.geocode.noResults+"

"),t.reject()}))}}else t.reject('Sorry, we couldn\'t load the "places" library due to another plugin, so the autocomplete feature is not available.')}.bind(this)),t.always(function(){e(".sow-google-map-canvas").each(function(o,t){var i=e(t);if(i.data("initialized"))return!0;var n=i.data("options"),a=n.address;if(!a){var s=n.markerPositions;s&&s.length&&(a=s[0].place)}this.getLocation(a).done(function(e){this.showMap(i.get(0),e,n),i.data("initialized",!0)}.bind(this)).fail((function(){i.append("

"+soWidgetsGoogleMap.geocode.noResults+"

")}))}.bind(this))}.bind(this)).fail((function(e){console.log(e)})).done((function(){e(sowb).trigger("maps_loaded")}))},getGeocoder:function(){return this._geocoder||(this._geocoder=new google.maps.Geocoder),this._geocoder},getLocation:function(o){var t,i=new e.Deferred,n={address:o};if(o&&o.indexOf(",")>-1){var a=o.replace(/[\(\)]/g,"").split(",");a&&2===a.length&&(t=new google.maps.LatLng(a[0],a[1]),isNaN(t.lat())||isNaN(t.lng())||(n={location:{lat:t.lat(),lng:t.lng()}}))}if(n.hasOwnProperty("location"))i.resolve(n.location);else if(n.hasOwnProperty("address")){if(!n.address){var s=parseInt(Math.random()*this.DEFAULT_LOCATIONS.length);n.address=this.DEFAULT_LOCATIONS[s]}var r=0,l=function(e,o){o===google.maps.GeocoderStatus.OK?i.resolve(e[0].geometry.location):o===google.maps.GeocoderStatus.OVER_QUERY_LIMIT?++r<3?setTimeout(function(){this.getGeocoder().geocode.call(this,n,l)}.bind(this),1e3):i.reject(o):o!==google.maps.GeocoderStatus.ZERO_RESULTS&&o!==google.maps.GeocoderStatus.OVER_DAILY_LIMIT||i.reject(o)}.bind(this);this.getGeocoder().geocode(n,l)}return i}}},jQuery((function(e){sowb.setupGoogleMaps=function(){var o,t=[],i=e(".sow-google-map-canvas");if(i.length){i.each((function(i,n){var a=e(n);if(!a.parent().is(":visible")||a.data("apiInitialized"))return a;var s=a.data("options");s&&(void 0!==s.libraries&&null!==s.libraries&&(t=t.concat(s.libraries)),!o&&s.apiKey&&(o=s.apiKey)),a.data("apiInitialized",!0)}));var n=void 0!==window.google&&void 0!==window.google.maps;if(sowb.mapsApiInitialized)var a=setTimeout((function(){n&&(clearTimeout(a),soGoogleMapInitialize())}),100);else{o||(console.warn("SiteOrigin Google Maps: Could not find API key. Google Maps API key is required."),o="");var s="https://maps.googleapis.com/maps/api/js?key="+o+"&callback=soGoogleMapInitialize";if(t&&t.length&&(s+="&libraries="+t.join(",")),window.console&&window.console.error){var r=window.console.error;sowb.onLoadMapsApiError=function(o){var t;"string"==typeof o&&(t=o.match(/^Google Maps API (error|warning): ([^\s]*)\s([^\s]*)(?:\s(.*))?/)),t&&t.length&&t[0]&&e(".sow-google-map-canvas").each((function(o,t){var i=e(t);if(i.data("fallbackImage")){var n=i.data("fallbackImage");n.hasOwnProperty("img")&&i.append(n.img)}})),r.apply(window.console,arguments)},window.console.error=sowb.onLoadMapsApiError}soWidgetsGoogleMap.map_consent?e(".sow-google-map-consent button").on("click",(function(){e(".sow-google-map-consent").remove(),e(".sow-google-map-canvas").show(),e("body").append('