angular-openlayers-directive icon indicating copy to clipboard operation
angular-openlayers-directive copied to clipboard

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

Open rsharus opened this issue 9 years ago • 2 comments

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

rsharus avatar May 15 '16 08:05 rsharus

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

juristr avatar May 20 '16 12:05 juristr

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;

rsharus avatar May 22 '16 08:05 rsharus