Skip to content
Snippets Groups Projects
LayerBaseVectorGeoJson.js.map 6.99 KiB
Newer Older
glennvorhes's avatar
glennvorhes committed
{"version":3,"file":"LayerBaseVectorGeoJson.js","sourceRoot":"","sources":["../../src/layers/LayerBaseVectorGeoJson.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;;;;AAEH,qDAA0E;AAC1E,2CAAsC;AACtC,0BAA6B;AAE7B,+CAAiD;AACjD,wDAAkD;AAElD,6CAAuC;AAEvC,IAAI,EAAE,GAAG,iBAAO,CAAC,QAAQ,CAAC,CAAC;AAa3B;;;GAGG;AACH;IAA4C,0CAAe;IAIvD;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IACH,gCAAY,GAAY,EAAE,OAA2C;QAA3C,wBAAA,EAAA,YAA2C;QAArE,iBAaC;QAZG,GAAG,GAAG,OAAO,GAAG,IAAI,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;QACxC,QAAA,kBAAM,GAAG,EAAE,OAAO,CAAC,SAAC;QAEpB,KAAI,CAAC,cAAc,GAAG,IAAI,iBAAO,EAAE,CAAC;QAEpC,KAAI,CAAC,UAAU,GAAG,OAAO,CAAC,SAAS,IAAI,EAAE,CAAC;QAC1C,KAAI,CAAC,UAAU,CAAC,cAAc,GAAG,KAAI,CAAC,UAAU,CAAC,cAAc,IAAI,IAAI,CAAC,QAAQ,CAAC;QACjF,KAAI,CAAC,UAAU,CAAC,iBAAiB,GAAG,KAAI,CAAC,UAAU,CAAC,iBAAiB,IAAI,sBAAQ,CAAC;QAElF,IAAI,KAAI,CAAC,QAAQ,IAAI,KAAI,CAAC,OAAO,EAAE;YAC/B,KAAI,CAAC,KAAK,EAAE,CAAC;SAChB;;IACL,CAAC;IAED;;;OAGG;IACH,4CAAW,GAAX,UAAY,iBAAsB;QAC9B,IAAI,CAAC,MAAM,CAAC,WAAW,CACnB,IAAI,CAAC,cAAc,CAAC,YAAY,CAAC,iBAAiB,EAC9C,EAAC,cAAc,EAAE,IAAI,CAAC,UAAU,CAAC,cAAc;YAC3C,iBAAiB,EAAE,IAAI,CAAC,UAAU,CAAC,iBAAiB,EAAC,CACxD,CACR,CAAC;IACN,CAAC;IAGD;;;;OAIG;IACH,sCAAK,GAAL;QAAA,iBAkBC;QAhBG,IAAI,iBAAM,KAAK,WAAE,EAAE;YACf,OAAO,IAAI,CAAC;SACf;QAED,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EACX,IAAI,CAAC,OAAO,EACZ,UAAC,CAAC;YACE,KAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;YACpB,KAAI,CAAC,YAAY,CAAC,KAAI,CAAC,CAAC;QAC5B,CAAC,EAAE,MAAM,CAAC,CAAC,IAAI,CACf;YACI,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;QACzB,CAAC,CACJ,CAAC;QAEF,OAAO,KAAK,CAAC;IACjB,CAAC;IAED;;;;OAIG;IACH,gDAAe,GAAf,UAAgB,CAAS;QACrB,iBAAM,eAAe,YAAC,CAAC,CAAC,CAAC;QACzB,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,cAAc,CAAC,YAAY,CAAC,CAAC,EACvD,EAAC,iBAAiB,EAAE,IAAI,CAAC,UAAU,CAAC,iBAAiB,EAAE,cAAc,EAAE,IAAI,CAAC,UAAU,CAAC,cAAc,EAAC,CAAC,CAAC,CAAC;IACjH,CAAC;IACL,6BAAC;AAAD,CAAC,AA/FD,CAA4C,iCAAe,GA+F1D;AA/FY,wDAAsB;AAiGnC,EAAE,CAAC,sBAAsB,GAAG,sBAAsB,CAAC;AACnD,kBAAe,sBAAsB,CAAC","sourcesContent":["/**\r\n * Created by gavorhes on 11/2/2015.\r\n */\r\n\r\nimport {LayerBaseVector, LayerBaseVectorOptions} from './LayerBaseVector';\r\nimport provide from '../util/provide';\r\nimport $ = require('jquery');\r\nimport {MapMoveCls} from \"../olHelpers/mapMoveCls\";\r\nimport * as proj from '../olHelpers/projections';\r\nimport {proj3857} from \"../olHelpers/projections\";\r\nimport Projection from 'ol/proj/Projection';\r\nimport GeoJSON from 'ol/format/GeoJSON'\r\n\r\nlet nm = provide('layers');\r\n\r\nexport interface crsTransform {\r\n    dataProjection?: Projection;\r\n    featureProjection?: Projection;\r\n}\r\n\r\n\r\nexport interface LayerBaseVectorGeoJsonOptions extends LayerBaseVectorOptions {\r\n    transform?: crsTransform;\r\n    mapMoveObj?: MapMoveCls;\r\n}\r\n\r\n/**\r\n * The Vector GeoJson Layer\r\n * @augments LayerBaseVector\r\n */\r\nexport class LayerBaseVectorGeoJson extends LayerBaseVector {\r\n    _geoJsonFormat: GeoJSON;\r\n    _transform: crsTransform;\r\n\r\n    /**\r\n     * @param {string|null} url - resource url, set to '' to make blank layer\r\n     * @param {object} options - config\r\n     * @param {string} [options.id] - layer id\r\n     * @param {string} [options.name=Unnamed Layer] - layer name\r\n     * @param {number} [options.opacity=1] - opacity\r\n     * @param {boolean} [options.visible=true] - default visible\r\n     * @param {number} [options.minZoom=undefined] - min zoom level, 0 - 28\r\n     * @param {number} [options.maxZoom=undefined] - max zoom level, 0 - 28\r\n     * @param {object} [options.params={}] the get parameters to include to retrieve the layer\r\n     * @param {number} [options.zIndex=0] the z index for the layer\r\n     * @param {function} [options.loadCallback] function to call on load, context this is the layer object\r\n     * @param {boolean} [options.legendCollapse=false] if the legend item should be initially collapsed\r\n     * @param {boolean} [options.legendCheckbox=true] if the legend item should have a checkbox for visibility\r\n     * @param {boolean} [options.legendContent] additional content to add to the legend\r\n     *\r\n     * @param {boolean} [options.autoLoad=false] if the layer should auto load if not visible\r\n     * @param {object} [options.style=undefined] the layer style, use openlayers default style if not defined\r\n     * @param {boolean} [options.onDemand=false] if the layer should be loaded by extent on map move\r\n     * @param {number} [options.onDemandDelay=300] delay before the map move callback should be called\r\n     *\r\n     * @param {object} [options.transform={}] SR transform, set as false for no transform\r\n     * @param {string} options.transform.dataProjection=EPSG:4326 the data CRS\r\n     * @param {string} options.transform.featureProjection=EPSG:3857 the feature/map CRS\r\n     * @param {mapMoveMakeGetParams} [options.mapMoveMakeGetParams=function(lyr, extent, zoomLevel){}] function to create additional map move params\r\n     * @param {MapMoveCls} [options.mapMoveObj=mapMove] alternate map move object for use with multi map pages\r\n     */\r\n    constructor(url?: string, options: LayerBaseVectorGeoJsonOptions = {}) {\r\n        url = typeof url == 'string' ? url : '';\r\n        super(url, options);\r\n\r\n        this._geoJsonFormat = new GeoJSON();\r\n\r\n        this._transform = options.transform || {};\r\n        this._transform.dataProjection = this._transform.dataProjection || proj.proj4326;\r\n        this._transform.featureProjection = this._transform.featureProjection || proj3857;\r\n\r\n        if (this.autoLoad || this.visible) {\r\n            this._load();\r\n        }\r\n    }\r\n\r\n    /**\r\n     * add feature collection\r\n     * @param {object} featureCollection - as geojson object\r\n     */\r\n    addFeatures(featureCollection: any) {\r\n        this.source.addFeatures(\r\n            this._geoJsonFormat.readFeatures(featureCollection,\r\n                {dataProjection: this._transform.dataProjection,\r\n                    featureProjection: this._transform.featureProjection}\r\n                )\r\n        );\r\n    }\r\n\r\n\r\n    /**\r\n     * trigger load features\r\n     * @protected\r\n     * @returns {boolean} if already loaded\r\n     */\r\n    _load() {\r\n\r\n        if (super._load()) {\r\n            return true;\r\n        }\r\n\r\n        $.get(this._url,\r\n            this._params,\r\n            (d) => {\r\n                this.addFeatures(d);\r\n                this.loadCallback(this);\r\n            }, 'json').fail(\r\n            function () {\r\n                this._loaded = false;\r\n            }\r\n        );\r\n\r\n        return false;\r\n    }\r\n\r\n    /**\r\n     * callback function on map move\r\n     * @param {object} d the json response\r\n     * @override\r\n     */\r\n    mapMoveCallback(d: Object) {\r\n        super.mapMoveCallback(d);\r\n        this._source.addFeatures(this._geoJsonFormat.readFeatures(d,\r\n            {featureProjection: this._transform.featureProjection, dataProjection: this._transform.dataProjection}));\r\n    }\r\n}\r\n\r\nnm.LayerBaseVectorGeoJson = LayerBaseVectorGeoJson;\r\nexport default LayerBaseVectorGeoJson;\r\n"]}