core icon indicating copy to clipboard operation
core copied to clipboard

[Openlayers3] JS error with Circle style

Open VaclavC opened this issue 8 years ago • 1 comments

If I try to use Circle style for Feature display, I get

AssertionError: Assertion failed: obj geometry must be an ol.style.Style instance

in JS console. Perhaps styles should be written to JS code as ol.style.Style instance in all cases, regardless to their true type?

VaclavC avatar Sep 10 '17 09:09 VaclavC

The OpenLayers API is confusing on this point. The ol.style.Style object contains a set of five styles (geometry, fill, image, stroke, etc.) and each one of those is of a specific style type (ol.geom.Geometry, ol.style.Fill, ol.style.Image, etc.)

Looking at the code, I think that this could be modeled better. Right now we Circle extends Style and emits JS to match and that is clearly incorrect; it's more like Fill or Image in that it's a component of an ol.style.Style instance, in is not one itself. In the OL3 API, they use ol.geom.Geometry...

I'll try to think of a solution that makes the most sense. If we have Circle look like an ol.Style.Style instance, we'll be losing other attributes like fill, stroke, etc. and there won't be enough data to draw the style on screen.

cmiles74 avatar Sep 10 '17 14:09 cmiles74