-
Notifications
You must be signed in to change notification settings - Fork 0
/
aframe-wms-component.min.js
1 lines (1 loc) · 2.15 KB
/
aframe-wms-component.min.js
1
!function(t){function e(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,e),o.l=!0,o.exports}var r={};e.m=t,e.c=r,e.d=function(t,r,n){e.o(t,r)||Object.defineProperty(t,r,{configurable:!1,enumerable:!0,get:n})},e.n=function(t){var r=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(r,"a",r),r},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=0)}([function(t,e,r){r(1)},function(t,e){if("undefined"==typeof AFRAME)throw new Error("Component attempted to register before AFRAME was available.");AFRAME.registerComponent("wms",{schema:{url:{type:"string",default:""},bbox:{type:"array",default:[]},projection:{type:"string",default:""},version:{type:"string",default:"1.3.0",oneOf:["1.3.0","1.3","1.0.0","1.1.1","1.1.0","1.1","1.0"]},format:{type:"string",default:"png"},transparent:{type:"string",default:"true"},layers:{type:"string",default:""},styles:{type:"string",default:""},width:{type:"number",default:250},height:{type:"number",default:250}},init:function(){},update:function(t){var e=this.data,r=this.el;if(a=r,b=e,!AFRAME.utils.deepEqual(t,e)){if(""==e.url)return void console.warn("WMS component: URL not specified. Aborting!");if(""==e.bbox||4!=e.bbox.length)return void console.warn("WMS component: BBOX not correct. Aborting!");if(""==e.projection)return void console.warn("WMS component: PROJECTION not specified. Aborting!");if(""==e.layers)return void console.warn("WMS component: LAYERS not specified. Aborting!");if(!["1.3.0","1.3","1.0.0","1.1.1","1.1.0","1.1","1.0"].includes(e.version))return void console.warn("WMS component: Version not correct. Aborting!");var n=this.constructURL(e);r.setAttribute("material","src",n),r.removeAttribute("material","color")}},constructURL:function(t){"1.3.0"==t.version.toLowerCase()?projParam="CRS":projParam="SRS";var e=t.url+"?SERVICE=WMS&REQUEST=GetMap&BBOX="+t.bbox+"&FORMAT=image/"+t.format.toLowerCase()+"&HEIGHT="+String(t.height)+"&WIDTH="+String(t.width)+"&LAYERS="+t.layers+"&"+projParam+"="+t.projection.replace(/\s/g,"")+"&STYLES="+t.styles+"&TRANSPARENT="+t.transparent+"&VERSION="+t.version;return encodeURI(e)}})}]);