0

In the new version of open layers 'instanceof' is replaced with getZIndex. How is it serving the same purpose as checking whether the style is a style object or not. From online forum, getZIndex tells us about the rendering order of the object. Please see the example below:

ol.asserts.assert(obj instanceof ol.style.Style,41); is replaced with ol.asserts.assert(typeof(obj).getZIndex === 'function',41);

user2856692
  • 125
  • 2
  • 4
  • 8
  • In version 4.6.5 if you try to use a layer object as a style you get an assertion error 41 because it's not a style object. In OpenLayers 5 you don't get an assertion error because like a style object a layer object also has a getZIndex method and it goes on to crash when it tries to render. So the replacement doesn't serve the purpose! – Mike Jun 04 '19 at 17:35
  • I am having a strange issue, when I use ol-debug.js then obj instanceof ol.style.Style returns true but if using ol.js then it returns false. The Style object seems to be instantiated from some other style constructor...so I was thinking of replacing the instance of line of code with typeof(obj).getZIndex. But since they dont serve the same purpuse. Any idea how to proceed. – user2856692 Jun 04 '19 at 19:47
  • You could use something like `typeof(obj).getZIndex === 'function' && typeof(obj).clone === 'function'` as I cannot think of any other object which has both `getZIndex` and `clone` methods. – Mike Jun 04 '19 at 20:19

0 Answers0