[Commits] r2768 - in sandbox/gxm/geoext/gxm/lib/GXM: data data/model widgets
commits at geoext.org
commits at geoext.org
Fri Jul 22 10:38:08 CEST 2011
Author: marcjansen
Date: 2011-07-22 10:38:08 +0200 (Fri, 22 Jul 2011)
New Revision: 2768
Modified:
sandbox/gxm/geoext/gxm/lib/GXM/data/LayerReader.js
sandbox/gxm/geoext/gxm/lib/GXM/data/LayerStore.js
sandbox/gxm/geoext/gxm/lib/GXM/data/model/Layer.js
sandbox/gxm/geoext/gxm/lib/GXM/widgets/LayerList.js
sandbox/gxm/geoext/gxm/lib/GXM/widgets/MapPanel.js
Log:
[gxm]
* add a zindex field to both reader and model
* add a configurable sorter option to Layer Store (defalut is based on zindex)
* add a plugin to have a method "getLayer" on model-instance, but currently keep the non-serializable layer-property that is needed by the LayerList-template to determine visibility (the property is likely to go away soon)
* add listeners to reload the store on layer changes (this isn't) final yet as we currently always need a mappanel and the layers config isn't respected too much
* add code docs to MapPanel.js
Modified: sandbox/gxm/geoext/gxm/lib/GXM/data/LayerReader.js
===================================================================
--- sandbox/gxm/geoext/gxm/lib/GXM/data/LayerReader.js 2011-07-21 12:54:14 UTC (rev 2767)
+++ sandbox/gxm/geoext/gxm/lib/GXM/data/LayerReader.js 2011-07-22 08:38:08 UTC (rev 2768)
@@ -20,6 +20,9 @@
if ( Ext.isDefined(record.data) && Ext.isDefined(record.data.layer)) {
record.data.layer = record.raw;
}
+ if ( Ext.isDefined(record.data) && Ext.isDefined(record.data.zindex)) {
+ record.data.zindex = record.raw.getZIndex();
+ }
});
return recs;
Modified: sandbox/gxm/geoext/gxm/lib/GXM/data/LayerStore.js
===================================================================
--- sandbox/gxm/geoext/gxm/lib/GXM/data/LayerStore.js 2011-07-21 12:54:14 UTC (rev 2767)
+++ sandbox/gxm/geoext/gxm/lib/GXM/data/LayerStore.js 2011-07-22 08:38:08 UTC (rev 2768)
@@ -25,8 +25,14 @@
conf.proxy = conf.proxy || {
type: 'memory',
reader: new GXM.data.LayerReader({})
+ //reader: 'json'
};
-
+
+ conf.sorters = conf.sorters || [{
+ property: conf.sortField || 'zindex',
+ direction: conf.sortDirection || 'DESC'
+ }];
+
return GXM.data.LayerStore.superclass.constructor.call(this, conf);
}
});
Modified: sandbox/gxm/geoext/gxm/lib/GXM/data/model/Layer.js
===================================================================
--- sandbox/gxm/geoext/gxm/lib/GXM/data/model/Layer.js 2011-07-21 12:54:14 UTC (rev 2767)
+++ sandbox/gxm/geoext/gxm/lib/GXM/data/model/Layer.js 2011-07-22 08:38:08 UTC (rev 2768)
@@ -7,14 +7,35 @@
* See http://svn.geoext.org/sandbox/gxm/geoext/gxm/license.txt for the full
* text of the license.
*/
+Ext.ns('GXM.data');
+GXM.data.LayerModelPlugin = Ext.extend(Object, {
+ bootstrap: function(model, config){
+ Ext.override(model, {
+ getLayer: function(){
+ return this.raw;
+ }
+ });
+
+ }
+});
+
+
+Ext.preg("gxm_layermodel", GXM.data.LayerModelPlugin);
+
+
Ext.regModel('gxm_Layer', {
+ plugins:[{ptype:'gxm_layermodel'}],
fields: [
{
// The name given for the layer
name: 'name'
- },
- {
+ }
+ ,{
+ name: 'zindex',
+ type: 'int'
+ }
+ ,{
// The layer instance
name: 'layer'
}
Modified: sandbox/gxm/geoext/gxm/lib/GXM/widgets/LayerList.js
===================================================================
--- sandbox/gxm/geoext/gxm/lib/GXM/widgets/LayerList.js 2011-07-21 12:54:14 UTC (rev 2767)
+++ sandbox/gxm/geoext/gxm/lib/GXM/widgets/LayerList.js 2011-07-22 08:38:08 UTC (rev 2768)
@@ -20,7 +20,7 @@
onItemTap: function(item, index, e){
var record = this.getStore().getAt(index);
- var layer = record.get('layer');
+ var layer = record.getLayer();
if (layer.isBaseLayer) {
this.map.setBaseLayer(layer);
}
@@ -66,6 +66,8 @@
if (this.map) {
this.map.events.on({
"changelayer": this.onChangeLayer,
+ "addlayer": this.onChangeLayer,
+ "removelayer": this.onChangeLayer,
scope: this
});
}
@@ -74,6 +76,7 @@
},
onChangeLayer: function(evt){
+ this.store.load(this.mapPanel.layers);
this.refresh();
}
Modified: sandbox/gxm/geoext/gxm/lib/GXM/widgets/MapPanel.js
===================================================================
--- sandbox/gxm/geoext/gxm/lib/GXM/widgets/MapPanel.js 2011-07-21 12:54:14 UTC (rev 2767)
+++ sandbox/gxm/geoext/gxm/lib/GXM/widgets/MapPanel.js 2011-07-22 08:38:08 UTC (rev 2768)
@@ -8,25 +8,56 @@
* text of the license.
*/
+/**
+ * @requires GXM/data/LayerStore.js
+ */
Ext.ns('GXM');
-/**
- * @requires GXM/data/LayerStore.js
+/** api: (define)
+ * module = GXM
+ * class = MapPanel
+ * base_link = `Ext.Component <http://dev.sencha.com/deploy/touch/docs/?class=Ext.Component>`_
*/
-// mappanel
+/** api: example
+ * Sample code to create a MapPanel that fills the whole screen:
+ *
+ * .. code-block:: javascript
+ *
+ * Ext.setup({
+ * onReady: function(){
+ * var mp = new GXM.MapPanel({
+ * layers: [
+ * // an array of OpenLayers.Layer-objects
+ * ],
+ * // set the center of the map
+ * center: [8, 51],
+ * // control the initial zoomlevel
+ * zoom: 11
+ * });
+ * } // end of the onReady-funcion
+ * });
+ *
+ */
+
+/** api: constructor
+ * .. class:: MapPanel(config)
+ *
+ * The class that is used to build a GXM map.
+ */
//TODO: rename to GXM.Map, since this is not a Panel
GXM.MapPanel = Ext.extend(Ext.Component, {
map: null,
center: null,
+ zoom: null,
bounds: null,
//TODO: do we really wish to have this fullscreen?
//TODO: is this in any case a usefull default?
fullscreen: true,
// set monitorResize to true just as the original Map-component of
// Sencha Touch does (Review BvdE).
- // monitorResize: true,
+ monitorResize: true,
getDefaultControls: function() {
return [
new OpenLayers.Control.TouchNavigation(),
@@ -233,7 +264,6 @@
map.render(me.el.dom);
if (!map.getCenter()) {
-
if (this.center || this.zoom ) {
// center and/or zoom?
map.setCenter(this.center, this.zoom);
More information about the Commits
mailing list