[Commits] r1191 - apps/opengeo/geoexplorer/trunk/src/script/app
commits at geoext.org
commits at geoext.org
Wed Jul 1 05:18:18 CEST 2009
Author: tschaub
Date: 2009-07-01 05:18:18 +0200 (Wed, 01 Jul 2009)
New Revision: 1191
Modified:
apps/opengeo/geoexplorer/trunk/src/script/app/GeoExplorer.js
Log:
When a view is configured to display the same layer twice, we need to take care with the record id, make a clone of the layer, and do the unset/set trick. This could all be improved with a clone method on the layer record.
Modified: apps/opengeo/geoexplorer/trunk/src/script/app/GeoExplorer.js
===================================================================
--- apps/opengeo/geoexplorer/trunk/src/script/app/GeoExplorer.js 2009-07-01 03:16:29 UTC (rev 1190)
+++ apps/opengeo/geoexplorer/trunk/src/script/app/GeoExplorer.js 2009-07-01 03:18:18 UTC (rev 1191)
@@ -647,9 +647,21 @@
var record;
var base;
if (id >= 0) {
- record = store.getAt(id).copy();
-
- layer = record.get("layer");
+ /**
+ * If the same layer is added twice, it will get replaced
+ * unless we give each record a unique id. In addition, we
+ * need to clone the layer so that the map doesn't assume
+ * the layer has already been added. Finally, we can't
+ * simply set the record layer to the cloned layer because
+ * record.set compares String(value) to determine equality.
+ *
+ * TODO: suggest record.clone
+ */
+ Ext.data.Record.AUTO_ID++;
+ record = store.getAt(id).copy(Ext.data.Record.AUTO_ID);
+ layer = record.get("layer").clone();
+ record.set("layer", null);
+ record.set("layer", layer);
// set layer max extent from capabilities
// TODO: make this SRS independent
@@ -661,9 +673,6 @@
layer.maxExtent = layer.restrictedExtent;
}
- layer = layer.clone();
- record.set("layer", null); //need to do this because record.set compares String(value) to determine equality (dumb)
- record.set("layer", layer);
// set layer visibility from config
layer.visibility = ("visibility" in conf) ? conf.visibility : true;
More information about the Commits
mailing list