Skip to content

Conversation

@rsharus
Copy link

@rsharus rsharus commented May 15, 2016

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

@juristr
Copy link
Collaborator

juristr commented May 20, 2016

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

@rsharus
Copy link
Author

rsharus commented May 22, 2016

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