| Current Path : /home/gonzalx/www/media/com_widgetkit/js/ |
| Current File : /home/gonzalx/www/media/com_widgetkit/js/maps.js |
(function(){"use strict";var L={colors:{black:[0,0,0,1],blue:[0,0,255,1],brown:[165,42,42,1],cyan:[0,255,255,1],fuchsia:[255,0,255,1],gold:[255,215,0,1],green:[0,128,0,1],indigo:[75,0,130,1],khaki:[240,230,140,1],lime:[0,255,0,1],magenta:[255,0,255,1],maroon:[128,0,0,1],navy:[0,0,128,1],olive:[128,128,0,1],orange:[255,165,0,1],pink:[255,192,203,1],purple:[128,0,128,1],violet:[128,0,128,1],red:[255,0,0,1],silver:[192,192,192,1],white:[255,255,255,1],yellow:[255,255,0,1],transparent:[255,255,255,0]},getSVG:function(e,i){return e=this.parseColor(e||"#E65857"),i=this.parseColor(i||"rgba(255,255,255,0)"),'<?xml version="1.0" encoding="utf-8"?> <svg version="1.1" xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" width="22px" height="34px" viewBox="0 0 22 34" enable-background="new 0 0 22 34" xml:space="preserve"> <circle id="circle" fill="'+i+'" cx="11" cy="11" r="6.5"/> <path id="path" d="M11,0C4.94,0,0,4.876,0,10.9C0,19.458,11,34,11,34s11-14.581,11-23.1C22,4.876,17.061,0,11,0z M11,16.5 c-3.038,0-5.5-2.463-5.5-5.5c0-3.038,2.462-5.5,5.5-5.5c3.037,0,5.5,2.462,5.5,5.5C16.5,14.037,14.037,16.5,11,16.5z" fill="'+e+'"/> </svg>'},parseColor:function(e){var i,s;return(i=/#([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})/.exec(e))?s=[parseInt(i[1],16),parseInt(i[2],16),parseInt(i[3],16),1]:(i=/#([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])/.exec(e))?s=[parseInt(i[1],16)*17,parseInt(i[2],16)*17,parseInt(i[3],16)*17,1]:(i=/rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(e))?s=[parseInt(i[1]),parseInt(i[2]),parseInt(i[3]),1]:(i=/rgba\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9.]*)\s*\)/.exec(e))?s=[parseInt(i[1],10),parseInt(i[2],10),parseInt(i[3],10),parseFloat(i[4])]:s=this.colors[e]||[230,88,87,1],"rgba("+s[0]+", "+s[1]+", "+s[2]+", "+s[3]+")"},setIcon:function(e,i){var s,o=new google.maps.Point(11,40),a=function(){e.setIcon({url:s,anchor:o})};if(!i.trim())return s="https://maps.gstatic.com/mapfiles/api-3/images/spotlight-poi.png",a();if(i.indexOf("/")!==-1){var p=new Image;p.onload=function(){s=p.src,o=new google.maps.Point(Math.ceil(p.width/2),p.height),a()},p.onerror=function(){return s="https://maps.gstatic.com/mapfiles/api-3/images/spotlight-poi.png",a()},p.src=i}else s="data:image/svg+xml;base64,"+btoa(this.getSVG.apply(this,i.split(" "))),o=new google.maps.Point(11,34),a()}};function r(t,e,i){this.extend(r,google.maps.OverlayView),this.map_=t,this.markers_=[],this.clusters_=[],this.sizes=[53,56,66,78,90],this.styles_=[],this.ready_=!1;var s=i||{};this.gridSize_=s.gridSize||60,this.minClusterSize_=s.minimumClusterSize||2,this.maxZoom_=s.maxZoom||null,this.styles_=s.styles||[],this.imagePath_=s.imagePath||this.MARKER_CLUSTER_IMAGE_PATH_,this.imageExtension_=s.imageExtension||this.MARKER_CLUSTER_IMAGE_EXTENSION_,this.zoomOnClick_=!0,s.zoomOnClick!=null&&(this.zoomOnClick_=s.zoomOnClick),this.averageCenter_=!1,s.averageCenter!=null&&(this.averageCenter_=s.averageCenter),this.setupStyles_(),this.setMap(t),this.prevZoom_=this.map_.getZoom();var o=this;google.maps.event.addListener(this.map_,"zoom_changed",function(){var a=o.map_.getZoom();o.prevZoom_!=a&&(o.prevZoom_=a,o.resetViewport())}),google.maps.event.addListener(this.map_,"idle",function(){o.redraw()}),e&&e.length&&this.addMarkers(e,!1)}r.prototype.MARKER_CLUSTER_IMAGE_PATH_="https://raw.githubusercontent.com/googlemaps/js-marker-clusterer/gh-pages/images/m",r.prototype.MARKER_CLUSTER_IMAGE_EXTENSION_="png",r.prototype.extend=function(t,e){return function(i){for(var s in i.prototype)this.prototype[s]=i.prototype[s];return this}.apply(t,[e])},r.prototype.onAdd=function(){this.setReady_(!0)},r.prototype.draw=function(){},r.prototype.setupStyles_=function(){if(!this.styles_.length)for(var t=0,e;e=this.sizes[t];t++)this.styles_.push({url:this.imagePath_+(t+1)+"."+this.imageExtension_,height:e,width:e})},r.prototype.fitMapToMarkers=function(){for(var t=this.getMarkers(),e=new google.maps.LatLngBounds,i=0,s;s=t[i];i++)e.extend(s.getPosition());this.map_.fitBounds(e)},r.prototype.setStyles=function(t){this.styles_=t},r.prototype.getStyles=function(){return this.styles_},r.prototype.isZoomOnClick=function(){return this.zoomOnClick_},r.prototype.isAverageCenter=function(){return this.averageCenter_},r.prototype.getMarkers=function(){return this.markers_},r.prototype.getTotalMarkers=function(){return this.markers_.length},r.prototype.setMaxZoom=function(t){this.maxZoom_=t},r.prototype.getMaxZoom=function(){return this.maxZoom_},r.prototype.calculator_=function(t,e){for(var i=0,s=t.length,o=s;o!==0;)o=parseInt(o/10,10),i++;return i=Math.min(i,e),{text:s,index:i}},r.prototype.setCalculator=function(t){this.calculator_=t},r.prototype.getCalculator=function(){return this.calculator_},r.prototype.addMarkers=function(t,e){for(var i=0,s;s=t[i];i++)this.pushMarkerTo_(s);e||this.redraw()},r.prototype.pushMarkerTo_=function(t){if(t.isAdded=!1,t.draggable){var e=this;google.maps.event.addListener(t,"dragend",function(){t.isAdded=!1,e.repaint()})}this.markers_.push(t)},r.prototype.addMarker=function(t,e){this.pushMarkerTo_(t),e||this.redraw()},r.prototype.removeMarker_=function(t){var e=-1;if(this.markers_.indexOf)e=this.markers_.indexOf(t);else for(var i=0,s;s=this.markers_[i];i++)if(s==t){e=i;break}return e==-1?!1:(t.setMap(null),this.markers_.splice(e,1),!0)},r.prototype.removeMarker=function(t,e){var i=this.removeMarker_(t);return!e&&i?(this.resetViewport(),this.redraw(),!0):!1},r.prototype.removeMarkers=function(t,e){for(var i=!1,s=0,o;o=t[s];s++){var a=this.removeMarker_(o);i=i||a}if(!e&&i)return this.resetViewport(),this.redraw(),!0},r.prototype.setReady_=function(t){this.ready_||(this.ready_=t,this.createClusters_())},r.prototype.getTotalClusters=function(){return this.clusters_.length},r.prototype.getMap=function(){return this.map_},r.prototype.setMap=function(t){this.map_=t},r.prototype.getGridSize=function(){return this.gridSize_},r.prototype.setGridSize=function(t){this.gridSize_=t},r.prototype.getMinClusterSize=function(){return this.minClusterSize_},r.prototype.setMinClusterSize=function(t){this.minClusterSize_=t},r.prototype.getExtendedBounds=function(t){var e=this.getProjection(),i=new google.maps.LatLng(t.getNorthEast().lat(),t.getNorthEast().lng()),s=new google.maps.LatLng(t.getSouthWest().lat(),t.getSouthWest().lng()),o=e.fromLatLngToDivPixel(i);o.x+=this.gridSize_,o.y-=this.gridSize_;var a=e.fromLatLngToDivPixel(s);a.x-=this.gridSize_,a.y+=this.gridSize_;var p=e.fromDivPixelToLatLng(o),g=e.fromDivPixelToLatLng(a);return t.extend(p),t.extend(g),t},r.prototype.isMarkerInBounds_=function(t,e){return e.contains(t.getPosition())},r.prototype.clearMarkers=function(){this.resetViewport(!0),this.markers_=[]},r.prototype.resetViewport=function(t){for(var e,i=0,s;s=this.clusters_[i];i++)s.remove();for(;e=this.markers_[i];i++)e.isAdded=!1,t&&e.setMap(null);this.clusters_=[]},r.prototype.repaint=function(){var t=this.clusters_.slice();this.clusters_.length=0,this.resetViewport(),this.redraw(),window.setTimeout(function(){for(var e=0,i;i=t[e];e++)i.remove()},0)},r.prototype.redraw=function(){this.createClusters_()},r.prototype.distanceBetweenPoints_=function(t,e){if(!t||!e)return 0;var i=6371,s=(e.lat()-t.lat())*Math.PI/180,o=(e.lng()-t.lng())*Math.PI/180,a=Math.sin(s/2)*Math.sin(s/2)+Math.cos(t.lat()*Math.PI/180)*Math.cos(e.lat()*Math.PI/180)*Math.sin(o/2)*Math.sin(o/2),p=2*Math.atan2(Math.sqrt(a),Math.sqrt(1-a)),g=i*p;return g},r.prototype.addToClosestCluster_=function(t){for(var e=4e4,i=null,s=0,o;o=this.clusters_[s];s++){var a=o.getCenter();if(a){var p=this.distanceBetweenPoints_(a,t.getPosition());p<e&&(e=p,i=o)}}if(i&&i.isMarkerInClusterBounds(t))i.addMarker(t);else{var g=new u(this);g.addMarker(t),this.clusters_.push(g)}},r.prototype.createClusters_=function(){if(!!this.ready_)for(var t=new google.maps.LatLngBounds(this.map_.getBounds().getSouthWest(),this.map_.getBounds().getNorthEast()),e=this.getExtendedBounds(t),i=0,s;s=this.markers_[i];i++)!s.isAdded&&this.isMarkerInBounds_(s,e)&&this.addToClosestCluster_(s)};function u(t){this.markerClusterer_=t,this.map_=t.getMap(),this.gridSize_=t.getGridSize(),this.minClusterSize_=t.getMinClusterSize(),this.averageCenter_=t.isAverageCenter(),this.center_=null,this.markers_=[],this.bounds_=null,this.clusterIcon_=new l(this,t.getStyles(),t.getGridSize())}u.prototype.isMarkerAlreadyAdded=function(t){if(this.markers_.indexOf)return this.markers_.indexOf(t)!=-1;for(var e=0,i;i=this.markers_[e];e++)if(i==t)return!0;return!1},u.prototype.addMarker=function(t){if(this.isMarkerAlreadyAdded(t))return!1;if(!this.center_)this.center_=t.getPosition(),this.calculateBounds_();else if(this.averageCenter_){var e=this.markers_.length+1,i=(this.center_.lat()*(e-1)+t.getPosition().lat())/e,s=(this.center_.lng()*(e-1)+t.getPosition().lng())/e;this.center_=new google.maps.LatLng(i,s),this.calculateBounds_()}t.isAdded=!0,this.markers_.push(t);var o=this.markers_.length;if(o<this.minClusterSize_&&t.getMap()!=this.map_&&t.setMap(this.map_),o==this.minClusterSize_)for(var a=0;a<o;a++)this.markers_[a].setMap(null);return o>=this.minClusterSize_&&t.setMap(null),this.updateIcon(),!0},u.prototype.getMarkerClusterer=function(){return this.markerClusterer_},u.prototype.getBounds=function(){for(var t=new google.maps.LatLngBounds(this.center_,this.center_),e=this.getMarkers(),i=0,s;s=e[i];i++)t.extend(s.getPosition());return t},u.prototype.remove=function(){this.clusterIcon_.remove(),this.markers_.length=0,delete this.markers_},u.prototype.getSize=function(){return this.markers_.length},u.prototype.getMarkers=function(){return this.markers_},u.prototype.getCenter=function(){return this.center_},u.prototype.calculateBounds_=function(){var t=new google.maps.LatLngBounds(this.center_,this.center_);this.bounds_=this.markerClusterer_.getExtendedBounds(t)},u.prototype.isMarkerInClusterBounds=function(t){return this.bounds_.contains(t.getPosition())},u.prototype.getMap=function(){return this.map_},u.prototype.updateIcon=function(){var t=this.map_.getZoom(),e=this.markerClusterer_.getMaxZoom();if(e&&t>e){for(var i=0,s;s=this.markers_[i];i++)s.setMap(this.map_);return}if(this.markers_.length<this.minClusterSize_){this.clusterIcon_.hide();return}var o=this.markerClusterer_.getStyles().length,a=this.markerClusterer_.getCalculator()(this.markers_,o);this.clusterIcon_.setCenter(this.center_),this.clusterIcon_.setSums(a),this.clusterIcon_.show()};function l(t,e,i){t.getMarkerClusterer().extend(l,google.maps.OverlayView),this.styles_=e,this.padding_=i||0,this.cluster_=t,this.center_=null,this.map_=t.getMap(),this.div_=null,this.sums_=null,this.visible_=!1,this.setMap(this.map_)}l.prototype.triggerClusterClick=function(){var t=this.cluster_.getMarkerClusterer();google.maps.event.trigger(t,"clusterclick",this.cluster_),t.isZoomOnClick()&&this.map_.fitBounds(this.cluster_.getBounds())},l.prototype.onAdd=function(){if(this.div_=document.createElement("DIV"),this.visible_){var t=this.getPosFromLatLng_(this.center_);this.div_.style.cssText=this.createCss(t),this.div_.innerHTML=this.sums_.text}var e=this.getPanes();e.overlayMouseTarget.appendChild(this.div_);var i=this;google.maps.event.addDomListener(this.div_,"click",function(){i.triggerClusterClick()})},l.prototype.getPosFromLatLng_=function(t){var e=this.getProjection().fromLatLngToDivPixel(t);return e.x-=parseInt(this.width_/2,10),e.y-=parseInt(this.height_/2,10),e},l.prototype.draw=function(){if(this.visible_){var t=this.getPosFromLatLng_(this.center_);this.div_.style.top=t.y+"px",this.div_.style.left=t.x+"px"}},l.prototype.hide=function(){this.div_&&(this.div_.style.display="none"),this.visible_=!1},l.prototype.show=function(){if(this.div_){var t=this.getPosFromLatLng_(this.center_);this.div_.style.cssText=this.createCss(t),this.div_.style.display=""}this.visible_=!0},l.prototype.remove=function(){this.setMap(null)},l.prototype.onRemove=function(){this.div_&&this.div_.parentNode&&(this.hide(),this.div_.parentNode.removeChild(this.div_),this.div_=null)},l.prototype.setSums=function(t){this.sums_=t,this.text_=t.text,this.index_=t.index,this.div_&&(this.div_.innerHTML=t.text),this.useStyle()},l.prototype.useStyle=function(){var t=Math.max(0,this.sums_.index-1);t=Math.min(this.styles_.length-1,t);var e=this.styles_[t];this.url_=e.url,this.height_=e.height,this.width_=e.width,this.textColor_=e.textColor,this.anchor_=e.anchor,this.textSize_=e.textSize,this.backgroundPosition_=e.backgroundPosition},l.prototype.setCenter=function(t){this.center_=t},l.prototype.createCss=function(t){var e=[];e.push("background-image:url("+this.url_+");");var i=this.backgroundPosition_?this.backgroundPosition_:"0 0";e.push("background-position:"+i+";"),typeof this.anchor_=="object"?(typeof this.anchor_[0]=="number"&&this.anchor_[0]>0&&this.anchor_[0]<this.height_?e.push("height:"+(this.height_-this.anchor_[0])+"px; padding-top:"+this.anchor_[0]+"px;"):e.push("height:"+this.height_+"px; line-height:"+this.height_+"px;"),typeof this.anchor_[1]=="number"&&this.anchor_[1]>0&&this.anchor_[1]<this.width_?e.push("width:"+(this.width_-this.anchor_[1])+"px; padding-left:"+this.anchor_[1]+"px;"):e.push("width:"+this.width_+"px; text-align:center;")):e.push("height:"+this.height_+"px; line-height:"+this.height_+"px; width:"+this.width_+"px; text-align:center;");var s=this.textColor_?this.textColor_:"black",o=this.textSize_?this.textSize_:11;return e.push("cursor:pointer; top:"+t.y+"px; left:"+t.x+"px; color:"+s+"; position:absolute; font-size:"+o+"px; font-family:Arial,sans-serif; font-weight:bold"),e.join("")};var m=window.UIkitwk||window.UIkit;m==null||m.util.ready(function(){var t=m.util,e=t.$,i=t.$$,s=t.append,o=t.attr,a=t.css,p=t.html;i('script[type="widgetkit/map"]').forEach(function(g){var y=e("<div>");o(y,g.dataset);var n=JSON.parse(g.innerHTML);g.parentNode.replaceChild(y,g),b().then(function(){var _=n.markers,w=[],c,k,S,d,x,I=L;Object.keys(n).forEach(function(h){isNaN(n[h])||(n[h]=Number(n[h]))}),S=_.length?new google.maps.LatLng(_[0].lat,_[0].lng):new google.maps.LatLng(-34.397,150.644),k={zoom:parseInt(n.zoom,10),center:S,streetViewControl:n.mapctrl,navigationControl:n.mapctrl,mapTypeId:google.maps.MapTypeId[n.maptypeid.toUpperCase()],mapTypeControl:n.maptypecontrol,zoomControl:n.zoomcontrol,disableDefaultUI:n.disabledefaultui,gestureHandling:n.draggable||n.zoomwheel?"auto":"none",mapTypeControlOptions:{style:google.maps.MapTypeControlStyle.DROPDOWN_MENU,mapTypeIds:["styled_map",google.maps.MapTypeId.ROADMAP,google.maps.MapTypeId.SATELLITE]},zoomControlOptions:{style:n.mapctrl?google.maps.ZoomControlStyle.DEFAULT:google.maps.ZoomControlStyle.SMALL}},c=new google.maps.Map(y,k),_.length&&n.directions&&(d=a(e('<a target="_blank"></a>'),{padding:"5px 1px","text-decoration":"none"}),x=a(e("<div></div>"),{"-webkit-background-clip":"padding-box",padding:"1px 4px",backgroundColor:"white",borderColor:"rgba(0, 0, 0, 0.14902)",borderStyle:"solid",borderWidth:"1px",cursor:"pointer",textAlign:"center",fontFamily:"Roboto, Arial, sans-serif",fontWeight:500,boxShadow:"rgba(0, 0, 0, 0.298039) 0px 1px 4px -1px",index:1}),p(x,'<span style="color:#000;"><span style="color:blue;">↳</span>'+(n.directionsText||"Get Directions")+"</span>"),s(d,x),d.setHref=function(h,M){o(this,"href","https://maps.google.com/?daddr="+h+","+M)},c.controls[google.maps.ControlPosition.TOP_RIGHT].push(d)),_.length&&n.marker&&(_.forEach(function(h,M){var f=new google.maps.Marker({position:new google.maps.LatLng(h.lat,h.lng),map:c,title:h.title}),C;(I&&h.icon||n.marker_icon)&&I.setIcon(f,h.icon||n.marker_icon),w.push(f),n.marker>=1&&(C=new google.maps.InfoWindow({content:h.content,maxWidth:n.popup_max_width?parseInt(n.popup_max_width,10):300}),google.maps.event.addListener(f,"click",function(){n.marker>=2&&h.content&&C.open(c,f),d&&(d.setHref(h.lat,h.lng),a(d,"display","block"))}),M===0&&(n.marker===3&&h.content&&C.open(c,f),d&&(d.setHref(h.lat,h.lng),a(d,"display","block"))))}),c.panTo(new google.maps.LatLng(_[0].lat,_[0].lng))),n.markercluster&&new r(c,w);var z=new google.maps.StyledMapType([{featureType:"all",elementType:"all",stylers:[{invert_lightness:n.styler_invert_lightness},{hue:n.styler_hue},{saturation:n.styler_saturation},{lightness:n.styler_lightness},{gamma:n.styler_gamma}]}],{name:"Styled"});c.mapTypes.set("styled_map",z),n.maptypeid.toUpperCase()==="ROADMAP"&&c.setMapTypeId("styled_map")})})});var v;function b(){return v||(v=T("https://maps.google.com/maps/api/js?key="+(window.GOOGLE_MAPS_API_KEY||""))),v}function T(t){return new Promise(function(e,i){var s=document.createElement("script");s.src=t,s.onload=function(){return e(t)},s.onerror=function(){return i(t)},document.head.appendChild(s)})}})();