geoext / geoext2

GeoExt 2 — JavaScript Toolkit for Rich Web Mapping Applications
http://geoext.github.io/geoext2/
Other
142 stars 106 forks source link

LayerModel getLayer() in ExtJS5 #390

Open KaiVolland opened 7 years ago

KaiVolland commented 7 years ago

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;
 }
bentrm commented 7 years ago

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.

chrismayer commented 7 years ago

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

KaiVolland commented 7 years ago

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 ...

bentrm commented 7 years ago

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.