Files
adsPRO/libraries/framework/vendor/plugins/gmap/jquery.ui.map.min.js
2024-12-10 23:24:15 +01:00

1 line
3.8 KiB
JavaScript

(function(e){e.a=function(t,n){var r=t.split(".")[0];t=t.split(".")[1];e[r]=e[r]||{};e[r][t]=function(e,t){if(arguments.length){this._setup(e,t)}};e[r][t].prototype=e.extend({namespace:r,pluginName:t},n);e.fn[t]=function(n){var i=typeof n==="string",s=Array.prototype.slice.call(arguments,1),o=this;if(i&&n.substring(0,1)==="_"){return o}this.each(function(){var u=e.data(this,t);if(!u){u=e.data(this,t,new e[r][t](n,this))}if(i){o=u[n].apply(u,s)}});return o}};e.a("ui.gmap",{options:{mapTypeId:"roadmap",zoom:5},option:function(e,t){if(t){this.options[e]=t;this.get("map").set(e,t);return this}return this.options[e]},_setup:function(e,t){this.el=t;e=e||{};jQuery.extend(this.options,e,{center:this._latLng(e.center)});this._create();if(this._init){this._init()}},_create:function(){var t=this;this.instance={map:new google.maps.Map(t.el,t.options),markers:[],overlays:[],services:[]};google.maps.event.addListenerOnce(t.instance.map,"bounds_changed",function(){e(t.el).trigger("init",t.instance.map)});t._call(t.options.callback,t.instance.map)},addBounds:function(e){var t=this.get("bounds",new google.maps.LatLngBounds);t.extend(this._latLng(e));this.get("map").fitBounds(t);return this},inViewport:function(e){var t=this.get("map").getBounds();return t?t.contains(e.getPosition()):false},addControl:function(e,t){this.get("map").controls[t].push(this._unwrap(e));return this},addMarker:function(t,n){t.map=this.get("map");t.position=this._latLng(t.position);var r=new(t.marker||google.maps.Marker)(t);var i=this.get("markers");if(r.id){i[r.id]=r}else{i.push(r)}if(r.bounds){this.addBounds(r.getPosition())}this._call(n,t.map,r);return e(r)},clear:function(e){this._c(this.get(e));this.set(e,[]);return this},_c:function(e){for(var t in e){if(e.hasOwnProperty(t)){if(e[t]instanceof google.maps.MVCObject){google.maps.event.clearInstanceListeners(e[t]);if(e[t].setMap){e[t].setMap(null)}}else if(e[t]instanceof Array){this._c(e[t])}e[t]=null}}},find:function(t,n,r){var i=this.get(t);n.value=e.isArray(n.value)?n.value:[n.value];for(var s in i){if(i.hasOwnProperty(s)){var o=false;for(var u in n.value){if(e.inArray(n.value[u],i[s][n.property])>-1){o=true}else{if(n.operator&&n.operator==="AND"){o=false;break}}}r(i[s],o)}}return this},get:function(e,t){var n=this.instance;if(!n[e]){if(e.indexOf(">")>-1){var r=e.replace(/ /g,"").split(">");for(var i=0;i<r.length;i++){if(!n[r[i]]){if(t){n[r[i]]=i+1<r.length?[]:t}else{return null}}n=n[r[i]]}return n}else if(t&&!n[e]){this.set(e,t)}}return n[e]},openInfoWindow:function(e,t,n){var r=this.get("iw",e.infoWindow||new google.maps.InfoWindow);r.setOptions(e);r.open(this.get("map"),this._unwrap(t));this._call(n,r);return this},closeInfoWindow:function(){if(this.get("iw")!=null){this.get("iw").close()}return this},set:function(e,t){this.instance[e]=t;return this},refresh:function(){var t=this.get("map");var n=t.getCenter();e(t).triggerEvent("resize");t.setCenter(n);return this},destroy:function(){this.clear("markers").clear("services").clear("overlays")._c(this.instance);jQuery.removeData(this.el,this.name)},_call:function(t){if(t&&e.isFunction(t)){t.apply(this,Array.prototype.slice.call(arguments,1))}},_latLng:function(e){if(!e){return new google.maps.LatLng(0,0)}if(e instanceof google.maps.LatLng){return e}else{e=e.replace(/ /g,"").split(",");return new google.maps.LatLng(e[0],e[1])}},_unwrap:function(t){return!t?null:t instanceof jQuery?t[0]:t instanceof Object?t:e("#"+t)[0]}});jQuery.fn.extend({triggerEvent:function(e){google.maps.event.trigger(this[0],e);return this},addEventListener:function(e,t,n){if(google.maps&&this[0]instanceof google.maps.MVCObject){google.maps.event.addListener(this[0],e,t)}else{if(n){this.bind(e,t,n)}else{this.bind(e,t)}}return this}});jQuery.each("click rightclick dblclick mouseover mouseout drag dragend".split(" "),function(e,t){jQuery.fn[t]=function(e,n){return this.addEventListener(t,e,n)}})})(jQuery)