Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

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