Skip to content

feat: Enable providing custom source object to layer through source.type#269

Open
rsharus wants to merge 3 commits into
tombatossals:masterfrom
rsharus:master
Open

feat: Enable providing custom source object to layer through source.type#269
rsharus wants to merge 3 commits into
tombatossals:masterfrom
rsharus:master

Conversation

@rsharus

@rsharus rsharus commented May 15, 2016

Copy link
Copy Markdown

Added a way to use custom layer source out of ol directive.

@juristr

juristr commented May 20, 2016

Copy link
Copy Markdown
Collaborator

@rsharus Hi, can you provide an example of how this can be used? Advantages? Thx 👍

@rsharus

rsharus commented May 22, 2016

Copy link
Copy Markdown
Author

Hi juristr ,
We have our own implementation of TileWMS that passes additional parameters so they could be used by geoserver (that we're also using) to create special SQL based queries.

In example, in our code of loLayoutService.js I'm creating object of TileWithViewParamsWMS (our implementation) and pass it through type:

        loLayersService.prototype.createLayerObj = function (layer, layer_extent, is_visible, is_label_layer) {
            var format_options = is_label_layer ? 'antialias:text' : 'antialias:none'
            var obj = {
                name: layer.Title,
                type: 'Tile',
                source: {
                    title: layer.Title,
                    type: 'TileWMS',
                    url: this.url,
                    crossOrigin: 'use-credentials',
                    params: {
                        'FORMAT': 'image/png8',
                        'VERSION': '1.1.1',

                        tiled: !is_label_layer,
                        LAYERS: layer.Name,
                        STYLES: '',
                        'FORMAT_OPTIONS': format_options
                    }
                },
                extent: layer_extent,
                visible: is_visible
            };

            var wmsConfiguration = {
                        crossOrigin: 'use-credentials',
                        params: obj.source.params,
                        attributions: [],
                        url:this.url
                    };

            obj.source.type = new ol.source.TileWithViewParamsWMS(wmsConfiguration);
            return obj;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants