geoext2 icon indicating copy to clipboard operation
geoext2 copied to clipboard

LayerModel getLayer() in ExtJS5

Open KaiVolland opened this issue 8 years ago • 4 comments

The current function getLayers() function of the LayerModel does not work with ExtJS 5 as raw of Ext.data.Model is gone. My recommendation would be to replace it with data but im not sure if this fits for all current scenarios...

/**
 * Returns the {OpenLayers.Layer} layer object used in this model instance.
 *
 * @return {OpenLayers.Layer}
 */
 getLayer: function() {
     return this.raw;
 }

KaiVolland avatar Oct 14 '16 09:10 KaiVolland

My recommendation would be to replace it with data but im not sure if this fits for all current scenarios...

It's probably the safest bet. Just had a look at getData(options) which seems to return a shallow copy and has other options that may render the layer object invalid.

bentrm avatar Oct 14 '16 11:10 bentrm

I also agree that this might be the best way to achieve the former behaviour.

@KaiVolland be sure to implement a check for ExtJS v5 before returning this.raw. Otherwise it will break in ExtJS 4

chrismayer avatar Oct 14 '16 11:10 chrismayer

For me this.getData() didn't return the same as this.data ... this.getData() didn't return an OpenLayers.Layer. I have to have a look at it again...

I'm testing it in an complex environment so i can't say if there is some project magic changes the conditions ...

KaiVolland avatar Oct 14 '16 11:10 KaiVolland

For me this.getData() didn't return the same as this.data ... this.getData() didn't return an OpenLayers.Layer. I have to have a look at it again...

Yes, that's what I meant. It's a shallow copy of the properties of data. this.raw || this.data or the like may be fine.

bentrm avatar Oct 14 '16 11:10 bentrm