PluginProbe
Themify Builder / trunk
Themify Builder vtrunk
7.8.1 7.8.0 7.7.9 7.7.8 7.7.7 7.7.6 7.7.5 7.7.4 7.7.3 7.7.2 trunk 7.6.0 7.6.1 7.6.2 7.6.3 7.6.4 7.6.5 7.6.6 7.6.7 7.6.8 7.6.9 7.7.0 7.7.1
themify-builder / themify / js / modules / google-map.js

google-map.js in Themify Builder trunk, at themify/js/modules/google-map.js

1 lines 2.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 ((e,a,t,o)=>{"use strict";let i=0;const n=e=>{t.google?.maps?.importLibrary||(e=>{let i,n,s;const r="google",c="importLibrary",d="__ib__",l=a,p=t[r]||(t[r]={}),m=p.maps||(p.maps={}),_=new Set,w=new URLSearchParams;m[c]||(m[c]=(a,...t)=>_.add(a)&&(()=>i||(i=new o((async(a,t)=>{for(s in await(n=l.createElement("script")),w.set("libraries",[..._]+""),e)w.set(s.replace(/[A-Z]/g,(e=>"_"+e[0].toLowerCase())),e[s]);w.set("callback",r+".maps."+d),n.src="https://maps."+r+"apis.com/maps/api/js?"+w,m[d]=a,n.onerror=()=>{i=t(Error("The Google Maps JavaScript API could not load."))},n.nonce=l.querySelector("script[nonce]")?.nonce||"",l.head.append(n)}))))().then((()=>m[c](a,...t))))})({key:e||"",v:"weekly"})},s=(e,a)=>(n(themify_vars.map_key||""),t.google.maps.importLibrary(e,a)),r=t=>{for(let n=t.length-1;n>-1;--n){let r=t[n];r.classList.contains("tf_map_loaded")||(r.classList.add("tf_map_loaded"),e.requestIdleCallback((async()=>{const t=r.dataset,{address:n,type:c,reverseGeocoding:d,infoWindow:l}=t,p=!d||"false"===d,m=e.isTouch?"0"!==t.mdrag:"1"===t.drag,_=m&&"1"===t.scroll,[{Map:w,MapTypeId:f},{LatLng:y},{Geocoder:u},{AdvancedMarkerElement:g}]=await o.all([s("maps"),s("core"),p?s("geocoding"):{},s("marker")]);let h,b={zoom:~~t.zoom,center:new y(-34.397,150.644),mapTypeId:f[c.toUpperCase()]||f.ROADMAP,gestureHandling:m?_?"auto":"cooperative":"none",disableDefaultUI:"1"===t.control,mapId:t.mapid||"tf_map_"+i++},v=new w(r,b);if(v.addListener("idle",(()=>{e.trigger("themify_map_loaded",[r,v])})),p){const{results:e}=await(new u).geocode({address:n});h=e[0].geometry.location}else{const e=n.split(",",2);h=new y(parseFloat(e[0]),parseFloat(e[1]))}const k=new g({map:v,position:h});if(v.setCenter(h),l){let t;k.addListener("click",(async function(){const o="themify_builder_map_w";if(!a.tfId(o)){const t=e.createElement("style",{id:o});t.textContent=".themify_builder_map_info_window{color:#000}",a.head.appendChild(t)}if(!t){const{InfoWindow:e}=await s("streetView");t=new e({content:'<div class="themify_builder_map_info_window">'+l+"</div>"})}t.open(this.map,this)}))}}),-1,1e3*(n+1)))}};e.on("tf_gmap_init",(e=>{queueMicrotask((()=>{setTimeout((()=>{r(e)}),0)}))}))})(Themify,document,window,Promise);