
/* Smart UI v18.0.1 (2024-01-22) 
Copyright (c) 2011-2023 jQWidgets. 
License: https://htmlelements.com/license/ */ //

Smart("smart-map",class extends Smart.BaseElement{static get properties(){return{apiKey:{type:"string",value:""},query:{type:"string",value:"sofia"},mode:{allowedTypes:["place","search","view","directions","streetview"],type:"string",value:"place"},mapType:{allowedTypes:["roadmap","satellite","hybrid","terrain"],value:"",type:"string"},heading:{type:"string",value:"210"},pitch:{type:"string",value:"10"},terrain:{type:"string",value:"terrain"},zoom:{type:"string",value:"12"}}}static get styleUrls(){return["smart.map.css"]}template(){return'<div id=mapId><iframe width="100%" height="100%" id="map"  mode=\'[[mode]]\' class="smart-map-container" api-key=\'apiKey\' map-type=\'[[mapType]]\' query=\'[[query]]\'  frameborder="0" alllowfullscreen  aria-hidden="false" tabindex="0"> </iframe></div>'}render(){const e=this;if("roadmap"===e.$.map.mapType||"satellite"===e.mapType)return e.$.map.src="https://www.google.com/maps/embed/v1/"+e.mode+"?key="+e.apiKey+"&maptype="+e.mapType+"&q="+e.query,void super.render();if("streetview"===e.$.map.mode){const a=e.query;let t,r;window.initMap=function(){(new window.google.maps.Geocoder).geocode({address:a},(function(a,o){return o===window.google.maps.GeocoderStatus.OK?(t=a[0].geometry.location.lat(),r=a[0].geometry.location.lng()):console.error("Loading the map was not successful for the following reason: "+o),e.$.map.src="https://www.google.com/maps/embed/v1/"+e.mode+"?key="+e.apiKey+"&location="+t+","+r+"&heading="+e.heading+"&pitch="+e.pitch+"&fov=35"}))};const o=document.createElement("script");o.type="text/javascript",o.src="https://maps.googleapis.com/maps/api/js?key="+e.apiKey+"&callback=initMap&libraries=&v=weekly",o.defer=!0,document.body.appendChild(o)}if("terrain"===e.$.map.mapType){const o=e.query;var a,t,r;if(window.initTerrainMap=function(){(new window.google.maps.Geocoder).geocode({address:o},(function(o,n){if(n===window.google.maps.GeocoderStatus.OK){a=o[0].geometry.location.lat(),t=o[0].geometry.location.lng(),r=new window.google.maps.LatLng(a,t),e.querySelectorAll(".smart-container").length;const n=new window.google.maps.Map(e.querySelectorAll(".smart-container")[0],{zoom:parseInt(e.zoom),center:r,mapTypeId:"terrain"});new window.google.maps.Marker({position:r,map:n})}else console.error("Loading the map was not successful for the following reason: "+n)}))},e.querySelectorAll(".smart-container").length<2){const a=document.createElement("script");a.type="text/javascript",a.src="https://maps.googleapis.com/maps/api/js?key="+e.apiKey+"&callback=initTerrainMap",a.defer=!0,document.head.appendChild(a)}}super.render()}propertyChangedHandler(e,a,t){super.propertyChangedHandler(e,a,t),this.render()}});