Allow styles to configure a custom renderer
Two new examples show how custom renderers can be used to render text along paths, and to declutter labels using 3rd party libraries.
This commit is contained in:
@@ -50,6 +50,12 @@ ol.style.Style = function(opt_options) {
|
||||
*/
|
||||
this.image_ = options.image !== undefined ? options.image : null;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {ol.StyleRenderFunction|null}
|
||||
*/
|
||||
this.renderer_ = options.renderer !== undefined ? options.renderer : null;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {ol.style.Stroke}
|
||||
@@ -92,6 +98,28 @@ ol.style.Style.prototype.clone = function() {
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Get the custom renderer function that was configured with
|
||||
* {@link #setRenderer} or the `renderer` constructor option.
|
||||
* @return {ol.StyleRenderFunction|null} Custom renderer function.
|
||||
* @api
|
||||
*/
|
||||
ol.style.Style.prototype.getRenderer = function() {
|
||||
return this.renderer_;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Sets a custom renderer function for this style. When set, `fill`, `stroke`
|
||||
* and `image` optins of the style will be ignored.
|
||||
* @param {ol.StyleRenderFunction|null} renderer Custom renderer function.
|
||||
* @api
|
||||
*/
|
||||
ol.style.Style.prototype.setRenderer = function(renderer) {
|
||||
this.renderer_ = renderer;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Get the geometry to be rendered.
|
||||
* @return {string|ol.geom.Geometry|ol.StyleGeometryFunction}
|
||||
|
||||
Reference in New Issue
Block a user