UNPKG

sic-mapping-toolkit

Version:

SICMapping Toolkit es una biblioteca para Angular que permite la creación de aplicaciones de Web Mapping por medio de OpenLayers

2 lines 11.8 kB
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core"),require("ol/source/Vector"),require("ol/layer/Vector"),require("cuid"),require("ol"),require("ol/layer/Tile"),require("ol/source/TileWMS"),require("ol/source/TileArcGISRest"),require("ol/layer/Image"),require("ol/source/ImageWMS")):"function"==typeof define&&define.amd?define("sic-mapping-toolkit",["exports","@angular/core","ol/source/Vector","ol/layer/Vector","cuid","ol","ol/layer/Tile","ol/source/TileWMS","ol/source/TileArcGISRest","ol/layer/Image","ol/source/ImageWMS"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["sic-mapping-toolkit"]={},e.ng.core,e.VectorSource,e.VectorLayer,e.cuid,e.ol,e.TileLayer,e.TileWMS,e.TileArcGISRest,e.ImageLayer,e.ImageWMS)}(this,(function(e,t,r,o,n,i,a,p,s,u,c){"use strict";function l(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var y=l(r),h=l(o),f=l(n),d=l(a),g=l(p),m=l(s),v=l(u),I=l(c),E=function(e,t){return(E=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])})(e,t)};function L(e,t){function r(){this.constructor=e}E(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}Object.create;function w(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var o,n,i=r.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(o=i.next()).done;)a.push(o.value)}catch(e){n={error:e}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}return a}function b(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(w(arguments[t]));return e}var M;Object.create;(M=e.MapEventType||(e.MapEventType={})).CHANGE="change",M.CHANGE_LAYERGROUP="change:layerGroup",M.CHANGE_SIZE="change:size",M.CHANGE_TARGET="change:target",M.CHANGE_VIEW="change:view",M.CLICK="click",M.DOUBLECLICK="dblclick",M.MOVEEND="moveend",M.POINTERDRAG="pointerdrag",M.POINTERMOVE="pointermove",M.POSTCOMPOSE="postcompose",M.POSTRENDER="postrender",M.PRECOMPOSE="precompose",M.PROPERTYCHANGE="propertychange",M.SINGLECLICK="singleclick";var S=["change","change:layerGroup","change:size","change:target","change:view","click","dblclick","moveend","pointerdrag","pointermove","postcompose","postrender","precompose","propertychange","singleclick"],O={hasHighlight:!0,hasSnap:!1},T=function(){function e(e,t){var r=this;if(this.map=e,this.id=t.id||f.default(),this.layers=[],this.eventHandlers={},S.forEach((function(e){r.eventHandlers[e]=[]})),this.map.on(S,(function(e){if(r.eventHandlers[e.type]){var t=r.eventHandlers[e.type].filter((function(e){return"SPECIAL"===e.priority})),o=r.eventHandlers[e.type].filter((function(e){return"HIGH"===e.priority})),n=r.eventHandlers[e.type].filter((function(e){return"NORMAL"===e.priority})),i=r.eventHandlers[e.type].filter((function(e){return"LOW"===e.priority}));o.length>0?b(o,t).forEach((function(t){return t.fn(e)})):n.length>0?b(n,t).forEach((function(t){return t.fn(e)})):b(i,t).forEach((function(t){return t.fn(e)}))}})),t.hasHighlight){this.highlightSource=new y.default({wrapX:!0});var o=new h.default({source:this.highlightSource,zIndex:1e3});this.map.addLayer(o)}}return e.initMap=function(t,r){return void 0===r&&(r={}),new e(t,Object.assign(Object.assign({},O),r))},Object.defineProperty(e.prototype,"Id",{get:function(){return this.id},enumerable:!1,configurable:!0}),e.prototype.setBaseLayer=function(e){return this.baseLayer=e,this.baseLayer.Layer.setZIndex(-1),this.map.addLayer(e.Layer),this.baseLayer.Id},e.prototype.clearBaseLayer=function(){this.baseLayer&&(this.map.removeLayer(this.baseLayer.Layer),this.baseLayer=null)},e.prototype.addLayer=function(e){return this.layers.push(e),this.map.addLayer(e.Layer),e.Id},e.prototype.removeLayer=function(e){var t=this.layers.find((function(t){return t.Id===e}));t&&this.map.removeLayer(t.Layer),this.layers=this.layers.filter((function(t){return t.Id!==e}))},e.prototype.addOverlay=function(e){this.map.addOverlay(e)},e.prototype.removeOverlay=function(e){this.map.removeOverlay(e)},e.prototype.addEventHandler=function(e,t,r){void 0===r&&(r="NORMAL"),this.eventHandlers[e]||(this.eventHandlers[e]=[]);var o=e+"."+f.default(),n={key:o,priority:r,fn:t};return this.eventHandlers[e].push(n),o},e.prototype.removeEventHandler=function(e){var t=e.split(".")[0],r=this.eventHandlers[t].reduce((function(t,r,o){return r.key===e?o:t}),-1);-1!==r&&(this.eventHandlers[t]=b(this.eventHandlers[t].slice(0,r),this.eventHandlers[t].slice(r+1)))},e.prototype.addInteraction=function(e){this.map.addInteraction(e)},e.prototype.removeInteraction=function(e){this.map.removeInteraction(e)},e.prototype.addControl=function(e){this.map.addControl(e)},e.prototype.removeControl=function(e){this.map.removeControl(e)},e.prototype.drawFeatures=function(e,t){var r=this;if(!this.highlightSource)throw new Error("No highlight source available");e.forEach((function(e){e.setStyle(t),r.highlightSource.addFeature(e)}))},e.prototype.clearFeatures=function(e){var t=this;if(!this.highlightSource)throw new Error("No highlight source available");e?this.highlightSource.getFeatures().filter((function(t){return t.getId().toString().startsWith(e)})).forEach((function(e){return t.highlightSource.removeFeature(e)})):this.highlightSource.clear()},e.prototype.getViewExtent=function(){return this.map.getView().calculateExtent(this.map.getSize())},e.prototype.getViewResolution=function(){return this.map.getView().getResolution()},e.prototype.moveTo=function(e,t){void 0===t&&(t=!0),this.map.getView().fit(e,{duration:t?500:0})},e.prototype.getZoom=function(){return this.map.getView().getZoom()},e.prototype.setZoom=function(e,t){void 0===t&&(t=!0),t?this.map.getView().animate({zoom:e,duration:500}):this.map.getView().setZoom(e)},e.prototype.getCenter=function(){return this.map.getView().getCenter()},e.prototype.setCenter=function(e,t){void 0===t&&(t=!0),t?this.map.getView().animate({center:e,duration:500}):this.map.getView().setCenter(e)},e.prototype.detectSizeChange=function(){this.map.updateSize()},e}(),C=function(){function e(){this.mapas=new Map}return e.prototype.createMap=function(e,t,r,o){void 0===t&&(t=[0,0]),void 0===r&&(r="EPSG:4326");var n=new i.View({center:t,zoom:15,projection:r}),a=new i.Map({target:e,view:n,layers:[]}),p=T.initMap(a,{id:o});return this.mapas.set(p.Id,p),this.default||(this.default=p.Id),p},e.prototype.setDefaultMapa=function(e){this.default=this.mapas.has(e)?e:this.default},e.prototype.getMapById=function(e){return this.getMapa(e)},e.prototype.setBaseLayer=function(e,t){return this.getMapa(t).setBaseLayer(e)},e.prototype.clearBaseLayer=function(e){this.getMapa(e).clearBaseLayer()},e.prototype.addLayer=function(e,t){return this.getMapa(t).addLayer(e)},e.prototype.removeLayer=function(e,t){this.getMapa(t).removeLayer(e)},e.prototype.addEventHandler=function(e,t,r,o){return this.getMapa(o).addEventHandler(e,t,r)},e.prototype.removeEventHandler=function(e,t){this.getMapa(t).removeEventHandler(e)},e.prototype.addOverlay=function(e,t){this.getMapa(t).addOverlay(e)},e.prototype.removeOverlay=function(e,t){this.getMapa(t).removeOverlay(e)},e.prototype.addInteraction=function(e,t){this.getMapa(t).addInteraction(e)},e.prototype.removeInteraction=function(e,t){this.getMapa(t).removeInteraction(e)},e.prototype.addControl=function(e,t){this.getMapa(t).addControl(e)},e.prototype.removeControl=function(e,t){this.getMapa(t).removeControl(e)},e.prototype.drawFeature=function(e,t,r){this.getMapa(r).drawFeatures([e],t)},e.prototype.clearDrawings=function(e,t){this.getMapa(t).clearFeatures(e)},e.prototype.getMapa=function(e){if(e||(e=this.default),!this.mapas.has(e))throw new Error("No existe SICMap con el id proporcionado");var t=this.mapas.get(e);if(!t)throw new Error("No se pudo recuperar el SICMap");return t},e}();C.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new C},token:C,providedIn:"root"}),C.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],C.ctorParameters=function(){return[]};var R=function(){function e(e){this.mapService=e,this.mapId="MapContainer."+f.default(),this.center=[-103.34331,20.673386],this.projection="EPSG:4326",this.zoom=10}return e.prototype.ngAfterViewInit=function(){this.map=this.mapService.createMap(this.mapId,this.center,this.projection,this.mapId),this.map.setZoom(this.zoom)},e.prototype.ngOnInit=function(){},e.prototype.ngOnChanges=function(e){e.mapId.isFirstChange()},e.prototype.getMapId=function(){return this.mapId},e}();R.decorators=[{type:t.Component,args:[{selector:"sic-map-viewer",template:'<div [id]="mapId" class="map-container"></div>\n',styles:[":host{bottom:0;left:0;position:absolute;right:0;top:0}.map-container{height:100%;width:100%}"]}]}],R.ctorParameters=function(){return[{type:C}]},R.propDecorators={mapId:[{type:t.Input,args:["mapId"]}],center:[{type:t.Input}],projection:[{type:t.Input}],zoom:[{type:t.Input}]};var A=function(){};A.decorators=[{type:t.NgModule,args:[{declarations:[R],imports:[],exports:[R]}]}];var V,H,_=function(){},G=function(){function e(e,t,r){this.title=e,this.layer=t,this.legend=r}return Object.defineProperty(e.prototype,"Id",{get:function(){return this.id},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"Title",{get:function(){return this.title},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"Layer",{get:function(){return this.layer},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"Legend",{get:function(){return this.legend},enumerable:!1,configurable:!0}),e.prototype.setId=function(e){this.id=e},e.prototype.setVisibility=function(e){this.layer.setVisible(e)},e.prototype.isVisible=function(){return this.layer.getVisible()},e.prototype.toggleVisibility=function(){var e=!this.isVisible();return this.setVisibility(e),e},e.prototype.setOpacity=function(e){if(e<0||e>1)throw new Error("Opacity must be a number between 0 and 1");this.layer.setOpacity(e)},e.prototype.getOpacity=function(){return this.layer.getOpacity()},e}(),P=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return L(t,e),t}(G),j=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return L(t,e),t}(G),W=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return L(t,e),t}(G);(V=e.LayerType||(e.LayerType={}))[V.WMS_LAYER=0]="WMS_LAYER",V[V.VECTOR_LAYER=1]="VECTOR_LAYER",V[V.ARGIS_REST_LAYER=2]="ARGIS_REST_LAYER",(H=e.WmsType||(e.WmsType={}))[H.IMAGE=0]="IMAGE",H[H.TILE=1]="TILE";var N=function(){function t(){}return t.createLayer=function(r,o,n){if(r===e.LayerType.VECTOR_LAYER)return t.createVectorLayer(o);if(r===e.LayerType.WMS_LAYER)return t.createWmsLayer(o,n.wmsType,n.serverType,n.serverUrl,n.serviceName,n.legend);if(r===e.LayerType.ARGIS_REST_LAYER)return t.createArgisLayer(o,n.serverUrl,n.legend,n.attribution);throw new Error("LayerType no soportado")},t.createVectorLayer=function(e){var t=new y.default({wrapX:!0}),r=new h.default({source:t});return new P(e,r)},t.createWmsLayer=function(t,r,o,n,i,a,p){var s,u;if(r===e.WmsType.IMAGE)s=I.default,u=v.default;else{if(r!==e.WmsType.TILE)throw new Error("WmsType no soportado");s=g.default,u=d.default}var c=new u({source:new s({url:n,serverType:o,attributions:p,params:{LAYERS:i,tiled:"geoserver"===o&&r===e.WmsType.TILE}})});return new j(t,c,a)},t.createArgisLayer=function(e,t,r,o){var n=new m.default({url:t,attributions:o}),i=new d.default({source:n});return new W(e,i,r)},t}(),F=function(){};e.FeatureFactory=_,e.LayerFactory=N,e.MapService=C,e.MapViewerComponent=R,e.SICLayer=G,e.SICMap=T,e.SicMappingToolkitModule=A,e.StyleFactory=F,Object.defineProperty(e,"__esModule",{value:!0})})); //# sourceMappingURL=sic-mapping-toolkit.umd.min.js.map