Skip to content
Snippets Groups Projects
LayerEsriTile.js.map 5.08 KiB
Newer Older
Glenn Vorhes's avatar
Glenn Vorhes committed
{"version":3,"file":"LayerEsriTile.js","sourceRoot":"","sources":["../../src/layers/LayerEsriTile.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;GAEG;AACH,2CAAsC;AACtC,uDAAoD;AAEpD,qDAAuD;AAGvD,IAAM,EAAE,GAAG,iBAAO,CAAC,QAAQ,CAAC,CAAC;AAM7B;;;GAGG;AACH;IAAmC,iCAAgB;IAG/C;;;;;;;;;;;;;;;;;OAiBG;IACH,uBAAY,GAAW,EAAE,OAAkC;QAAlC,wBAAA,EAAA,YAAkC;QAA3D,iBAaC;QAZG,EAAE,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;YAC1B,GAAG,IAAI,GAAG,CAAC;QACf,CAAC;QACD,GAAG,IAAI,kBAAkB,CAAC;QAE1B,QAAA,kBAAM,GAAG,EAAE,OAAO,CAAC,SAAC;QAEpB,KAAI,CAAC,aAAa,GAAG,OAAO,OAAO,CAAC,YAAY,IAAI,SAAS,GAAG,OAAO,CAAC,YAAY,GAAG,KAAK,CAAC;QAE7F,EAAE,CAAC,CAAC,KAAI,CAAC,aAAa,CAAC,CAAC,CAAC;YACrB,KAAI,CAAC,gBAAgB,EAAE,CAAC;QAC5B,CAAC;;IACL,CAAC;IAGD;;;OAGG;IACH,wCAAgB,GAAhB,UAAiB,iBAAsB;QAAvC,iBA0BC;QA1BgB,kCAAA,EAAA,sBAAsB;QACnC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC;YACtB,iBAAM,gBAAgB,YAAC,iBAAiB,CAAC,CAAC;QAC9C,CAAC;QAAC,IAAI,CAAC,CAAC;YACJ,IAAI,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC;YAEvB,IAAI,cAAc,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;YAChE,EAAE,CAAC,CAAC,cAAc,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;gBACtB,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,cAAc,GAAG,CAAC,CAAC,CAAC;YACnD,CAAC;YAAC,IAAI,CAAC,CAAC;gBACJ,MAAM,CAAC;YACX,CAAC;YAED,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;gBACtC,OAAO,IAAI,GAAG,CAAC;YACnB,CAAC;YAED,OAAO,IAAI,2BAA2B,CAAC;YAEvC,IAAI,gBAAc,GAAG,iBAAM,gBAAgB,CAAC;YAE5C,CAAC,CAAC,GAAG,CAAC,OAAO,EAAE,EAAE,EAAE,UAAC,CAAC;gBACjB,IAAI,OAAO,GAAG,QAAQ,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC;gBAC/C,gBAAc,CAAC,IAAI,CAAC,KAAI,EAAE,OAAO,CAAC,CAAC;YACvC,CAAC,EAAE,MAAM,CAAC,CAAC;QACf,CAAC;IACL,CAAC;IAGL,oBAAC;AAAD,CAAC,AAtED,CAAmC,mCAAgB,GAsElD;AAtEY,sCAAa;AAwE1B,EAAE,CAAC,gBAAgB,GAAG,aAAa,CAAC;AACpC,kBAAe,aAAa,CAAC","sourcesContent":["/**\r\n * Created by gavorhes on 12/4/2015.\r\n */\r\nimport provide from '../util/provide';\r\nimport {LayerBaseXyzTile} from './LayerBaseXyzTile';\r\nimport {LayerBaseOptions} from './LayerBase'\r\nimport * as esriToOl from '../olHelpers/esriToOlStyle';\r\n\r\n\r\nconst nm = provide('layers');\r\n\r\nexport interface LayerEsriTileOptions extends LayerBaseOptions{\r\n    useEsriStyle?: boolean\r\n}\r\n\r\n/**\r\n * Esri tile\r\n * @augments LayerBaseXyzTile\r\n */\r\nexport class LayerEsriTile extends LayerBaseXyzTile {\r\n    _useEsriStyle: boolean;\r\n\r\n    /**\r\n     * The Esri tile layer\r\n     * @param {string} url - url for source\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     * @param {boolean} [options.useEsriStyle=false] if the map service style should be used\r\n     */\r\n    constructor(url: string, options: LayerEsriTileOptions = {}) {\r\n        if (url.search(/\\/$/) == -1) {\r\n            url += '/';\r\n        }\r\n        url += 'tile/{z}/{y}/{x}';\r\n\r\n        super(url, options);\r\n\r\n        this._useEsriStyle = typeof options.useEsriStyle == 'boolean' ? options.useEsriStyle : false;\r\n\r\n        if (this._useEsriStyle) {\r\n            this.addLegendContent();\r\n        }\r\n    }\r\n\r\n\r\n    /**\r\n     * add additional content to the legend\r\n     * @param {string} [additionalContent=''] additional content for legend\r\n     */\r\n    addLegendContent(additionalContent = ''): void {\r\n        if (!this._useEsriStyle) {\r\n            super.addLegendContent(additionalContent);\r\n        } else {\r\n            let urlCopy = this.url;\r\n\r\n            let mapServerIndex = urlCopy.toLowerCase().indexOf('mapserver');\r\n            if (mapServerIndex > -1) {\r\n                urlCopy = urlCopy.slice(0, mapServerIndex + 9);\r\n            } else {\r\n                return;\r\n            }\r\n\r\n            if (urlCopy[urlCopy.length - 1] !== '/') {\r\n                urlCopy += '/';\r\n            }\r\n\r\n            urlCopy += 'legend?f=pjson&callback=?';\r\n\r\n            let superAddLegend = super.addLegendContent;\r\n\r\n            $.get(urlCopy, {}, (d) => {\r\n                let newHtml = esriToOl.makeMapServiceLegend(d);\r\n                superAddLegend.call(this, newHtml);\r\n            }, 'json');\r\n        }\r\n    }\r\n\r\n\r\n}\r\n\r\nnm.LayerBaseXyzTile = LayerEsriTile;\r\nexport default LayerEsriTile;\r\n\r\n"]}