angular-openlayers-directive
angular-openlayers-directive copied to clipboard
feat: Enable providing custom source object to layer through source.type
Added a way to use custom layer source out of ol directive.
@rsharus Hi, can you provide an example of how this can be used? Advantages? Thx :+1:
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;