-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgoogle-transparency.min.js
More file actions
1 lines (1 loc) · 8.45 KB
/
Copy pathgoogle-transparency.min.js
File metadata and controls
1 lines (1 loc) · 8.45 KB
1
OpacityControl=function(c,b){var a=this;a._init=function(e,d){a.map=e;a.initialOpacity=d.opacity?d.opacity:100;a.backgroundColor=d.backgroundColor?d.backgroundColor:"transparent";a.getTileUrl=d.getTileUrl?d.getTileUrl:function(g,f){return false};a.sliderImageUrl=d.sliderImageUrl?d.sliderImageUrl:"opacity-slider3d14.png";a.position=d.position?d.position:google.maps.ControlPosition.RIGHT_TOP;a.OPACITY_MAX_PIXELS=57;a.overlay=new OpacityControl.TileOverlay(a.map,a.initialOpacity,a.getTileUrl,a.backgroundColor);a.overlay.show();google.maps.event.addListener(a.map,"tilesloaded",function(){a.overlay.deleteHiddenTiles(a.map.getZoom())});a.createOpacityControl(a.initialOpacity)};a.createOpacityControl=function(e){var g=document.createElement("DIV");g.setAttribute("style","margin:5px;overflow-x:hidden;overflow-y:hidden;background:url("+a.sliderImageUrl+") no-repeat;width:71px;height:21px;cursor:pointer;");var f=document.createElement("DIV");f.setAttribute("style","padding:0;margin:0;overflow-x:hidden;overflow-y:hidden;background:url("+a.sliderImageUrl+") no-repeat -71px 0;width:14px;height:21px;");g.appendChild(f);a.opacityCtrlKnob=new OpacityControl.ExtDraggableObject(f,{restrictY:true,container:g});google.maps.event.addListener(a.opacityCtrlKnob,"dragend",function(){a.setOpacity(a.opacityCtrlKnob.valueX())});google.maps.event.addDomListener(g,"click",function(j){var i=a.findPosLeft(this);var h=j.pageX-i-5;a.opacityCtrlKnob.setValueX(h);a.setOpacity(h)});a.map.controls[a.position].push(g);var d=a.OPACITY_MAX_PIXELS/(100/e);a.opacityCtrlKnob.setValueX(d);a.setOpacity(d)};a.setOpacity=function(d){var e=(100/a.OPACITY_MAX_PIXELS)*d;if(e<0){e=0}if(e==0){if(a.overlay.visible==true){a.overlay.hide()}}else{a.overlay.setOpacity(e);if(a.overlay.visible==false){a.overlay.show()}}};a.findPosLeft=function(d){var e=0;if(d.offsetParent){do{e+=d.offsetLeft}while(d=d.offsetParent);return e}return undefined};a._init(c,b)};OpacityControl.TileOverlay=function(c,b,d,a){this.tileSize=new google.maps.Size(256,256);this.map=c;this.opacity=b;this.tiles=[];this.visible=false;this.initialized=false;this.getTileUrl=d;this.backgroundColor=a?a:"#000";this.self=this};OpacityControl.TileOverlay.prototype=new google.maps.OverlayView();OpacityControl.TileOverlay.prototype.getTile=function(d,f,a){for(var g=0;g<this.tiles.length;g++){if(this.tiles[g].id=="t_"+d.x+"_"+d.y+"_"+f){return this.tiles[g]}}var b=a.createElement("div");var e=this.getTileUrlCoord(d,f);b.id="t_"+e.x+"_"+e.y+"_"+f;b.style.width=this.tileSize.width+"px";b.style.height=this.tileSize.height+"px";var c=this.getTileUrl(e,f);if(c){b.style.backgroundImage="url("+c+")";b.style.backgroundRepeat="no-repeat"}else{if(this.backgroundColor=="transparent"){this.backgroundColor=this.map.getDiv().firstChild.style.backgroundColor}b.style.backgroundColor=this.backgroundColor}if(!this.visible){b.style.display="none"}this.tiles.push(b);this.setObjectOpacity(b);return b};OpacityControl.TileOverlay.prototype.deleteHiddenTiles=function(o){var c=this.map.getBounds();var e=this.getTileUrlCoordFromLatLng(c.getNorthEast(),o);var k=this.getTileUrlCoordFromLatLng(c.getSouthWest(),o);var g=k.x-1;var d=e.x+1;var f=k.y-1;var b=e.y+1;var h=[];var n=this.tiles.length;for(var j=0;j<n;j++){var l=this.tiles[j].id.split("_");var a=Number(l[1]);var p=Number(l[2]);var m=Number(l[3]);if(((g<d&&(a>=g&&a<=d))||(g>d&&((a>=g&&a<=(Math.pow(2,o)-1))||(a>=0&&a<=d))))&&(p>=f&&p<=b)&&m==o){h.push(this.tiles[j])}else{delete this.tiles[j]}}this.tiles=h};OpacityControl.TileOverlay.prototype.pointToTile=function(b,f){var a=this.map.getProjection();var c=a.fromLatLngToPoint(b);var d=new google.maps.Point(c.x*Math.pow(2,f),c.y*Math.pow(2,f));var e=new google.maps.Point(Math.floor(d.x/this.tileSize.width),Math.floor(d.y/this.tileSize.height));return e};OpacityControl.TileOverlay.prototype.getTileUrlCoordFromLatLng=function(b,a){return this.getTileUrlCoord(this.pointToTile(b,a),a)};OpacityControl.TileOverlay.prototype.getTileUrlCoord=function(e,b){var c=1<<b;var d=c-e.y-1;var a=e.x;if(a<0||a>=c){a=(a%c+c)%c}return new google.maps.Point(a,d)};OpacityControl.TileOverlay.prototype.initialize=function(){if(this.initialized){return}var a=this.self;this.map.overlayMapTypes.insertAt(0,a);a.setMap(this.map);this.initialized=true};OpacityControl.TileOverlay.prototype.hide=function(){this.visible=false;var a=this.tiles.length;for(var b=0;b<a;b++){this.tiles[b].style.display="none"}};OpacityControl.TileOverlay.prototype.show=function(){this.initialize();this.visible=true;var a=this.tiles.length;for(var b=0;b<a;b++){this.tiles[b].style.display=""}};OpacityControl.TileOverlay.prototype.releaseTile=function(a){a=null};OpacityControl.TileOverlay.prototype.setOpacity=function(c){this.opacity=c;var a=this.tiles.length;for(var b=0;b<a;b++){this.setObjectOpacity(this.tiles[b])}};OpacityControl.TileOverlay.prototype.setObjectOpacity=function(a){if(this.opacity>0){if(typeof(a.style.filter)=="string"){a.style.filter="alpha(opacity:"+this.opacity+")"}if(typeof(a.style.KHTMLOpacity)=="string"){a.style.KHTMLOpacity=this.opacity/100}if(typeof(a.style.MozOpacity)=="string"){a.style.MozOpacity=this.opacity/100}if(typeof(a.style.opacity)=="string"){a.style.opacity=this.opacity/100}}};OpacityControl.TileOverlay.prototype.draw=function(){var a=this.self;if(!a.map.getMapPanes){a.map.getMapPanes=function(){return a.getPanes()}}};OpacityControl.ExtDraggableObject=function(f,j){var t=this;var m=(window.GEvent||google.maps.Event||google.maps.event);var y=j||{};var A=y.draggingCursor||"default";var z=y.draggableCursor||"default";var k=false,n;var D,e,B,p,g,u;var x,s;var C,r,c;var i,v;var b=Math.round(y.intervalX/2);var o=Math.round(y.intervalY/2);var h=f.setCapture?f:document;if(typeof y.intervalX!=="number"){y.intervalX=1}if(typeof y.intervalY!=="number"){y.intervalY=1}if(typeof y.toleranceX!=="number"){y.toleranceX=Infinity}if(typeof y.toleranceY!=="number"){y.toleranceY=Infinity}C=m.addDomListener(f,"mousedown",q);r=m.addDomListener(h,"mouseup",d);w(false);if(y.container){}f.style.position="absolute";y.left=y.left||f.offsetLeft;y.top=y.top||f.offsetTop;y.interval=y.interval||1;a(y.left,y.top,false);function w(E){if(E){f.style.cursor=A}else{f.style.cursor=z}}function a(E,I,F){var G,H;s=Math.round(E);x=Math.round(I);if(y.intervalX>1){G=Math.round(s%y.intervalX);s=(G<b)?(s-G):(s+(y.intervalX-G))}if(y.intervalY>1){H=Math.round(x%y.intervalY);x=(H<o)?(x-H):(x+(y.intervalY-H))}if(y.container&&y.container.offsetWidth){s=Math.max(0,Math.min(s,y.container.offsetWidth-f.offsetWidth));x=Math.max(0,Math.min(x,y.container.offsetHeight-f.offsetHeight))}if(typeof D==="number"){if(((s-D)>y.toleranceX||(D-(s+f.offsetWidth))>y.toleranceX)||((x-e)>y.toleranceY||(e-(x+f.offsetHeight))>y.toleranceY)){s=i;x=v}}if(!y.restrictX&&!F){f.style.left=s+"px"}if(!y.restrictY&&!F){f.style.top=x+"px"}}function l(E){var F=E||event;D=p+((F.pageX||(F.clientX+document.body.scrollLeft+document.documentElement.scrollLeft))-g);e=B+((F.pageY||(F.clientY+document.body.scrollTop+document.documentElement.scrollTop))-u);p=D;B=e;g=F.pageX||(F.clientX+document.body.scrollLeft+document.documentElement.scrollLeft);u=F.pageY||(F.clientY+document.body.scrollTop+document.documentElement.scrollTop);if(k){a(D,e,n);m.trigger(t,"drag",{mouseX:g,mouseY:u,startLeft:i,startTop:v,event:F})}}function q(E){var F=E||event;w(true);m.trigger(t,"mousedown",F);if(f.style.position!=="absolute"){f.style.position="absolute";return}g=F.pageX||(F.clientX+document.body.scrollLeft+document.documentElement.scrollLeft);u=F.pageY||(F.clientY+document.body.scrollTop+document.documentElement.scrollTop);i=f.offsetLeft;v=f.offsetTop;p=i;B=v;c=m.addDomListener(h,"mousemove",l);if(f.setCapture){f.setCapture()}if(F.preventDefault){F.preventDefault();F.stopPropagation()}else{F.cancelBubble=true;F.returnValue=false}k=true;m.trigger(t,"dragstart",{mouseX:g,mouseY:u,startLeft:i,startTop:v,event:F})}function d(E){var F=E||event;if(k){w(false);m.removeListener(c);if(f.releaseCapture){f.releaseCapture()}k=false;m.trigger(t,"dragend",{mouseX:g,mouseY:u,startLeft:i,startTop:v,event:F})}D=e=null;m.trigger(t,"mouseup",F)}t.moveTo=function(E){a(E.x,E.y,false)};t.moveBy=function(E){a(f.offsetLeft+E.width,f.offsetHeight+E.height,false)};t.setDraggingCursor=function(E){A=E;w(k)};t.setDraggableCursor=function(E){z=E;w(k)};t.left=function(){return s};t.top=function(){return x};t.valueX=function(){var E=y.intervalX||1;return Math.round(s/E)};t.valueY=function(){var E=y.intervalY||1;return Math.round(x/E)};t.setValueX=function(E){a(E*y.intervalX,x,false)};t.setValueY=function(E){a(s,E*y.intervalY,false)};t.preventDefaultMovement=function(E){n=E}};