[Commits] r1757 - in sandbox/redlining/ux/FeatureEditing/ux/widgets: . form
commits at geoext.org
commits at geoext.org
Fri Jan 15 15:51:15 CET 2010
Author: adube
Date: 2010-01-15 15:51:15 +0100 (Fri, 15 Jan 2010)
New Revision: 1757
Modified:
sandbox/redlining/ux/FeatureEditing/ux/widgets/FeatureEditingControler.js
sandbox/redlining/ux/FeatureEditing/ux/widgets/form/FeatureEditingPanel.js
sandbox/redlining/ux/FeatureEditing/ux/widgets/form/FeaturePanel.js
sandbox/redlining/ux/FeatureEditing/ux/widgets/form/RedLiningPanel.js
Log:
labels added, current style is hardcoded to default values
Modified: sandbox/redlining/ux/FeatureEditing/ux/widgets/FeatureEditingControler.js
===================================================================
--- sandbox/redlining/ux/FeatureEditing/ux/widgets/FeatureEditingControler.js 2010-01-15 13:11:18 UTC (rev 1756)
+++ sandbox/redlining/ux/FeatureEditing/ux/widgets/FeatureEditingControler.js 2010-01-15 14:51:15 UTC (rev 1757)
@@ -227,6 +227,13 @@
this.drawControls.push(control);
this.map.addControl(control);
+ if(geometryType == "Label") {
+ control.events.on({
+ "featureadded": this.onLabelAdded,
+ scope: this
+ });
+ }
+
control.events.on({
"featureadded": this.onFeatureAdded,
scope: this
@@ -325,6 +332,16 @@
return control;
},
+ /** private: method[onLabelAdded]
+ * :param event: ``event``
+ * Called when a new label feature is added to the activeLayer. Set a flag
+ * to let the controler know it's a label.
+ */
+ onLabelAdded: function(event) {
+ var feature = event.feature;
+ feature.isLabel = true;
+ },
+
/** private: method[onFeatureAdded]
* :param event: ``event``
* Called when a new feature is added to the activeLayer. Change the state
@@ -378,14 +395,13 @@
feature: feature,
title: OpenLayers.i18n('EditFeature'),
controler: this,
- layout: 'fit',
+ layout: 'fit',
items: [this.featurePanel]
});
feature.popup = popup;
popup.on({
close: function() {
- if(OpenLayers.Util.indexOf(this.controler.activeLayer.selectedFeatures,
- this.feature) > -1) {
+ if(OpenLayers.Util.indexOf(this.controler.activeLayer.selectedFeatures, this.feature) > -1) {
this.controler.getSelectControl().unselect(this.feature);
}
}
Modified: sandbox/redlining/ux/FeatureEditing/ux/widgets/form/FeatureEditingPanel.js
===================================================================
--- sandbox/redlining/ux/FeatureEditing/ux/widgets/form/FeatureEditingPanel.js 2010-01-15 13:11:18 UTC (rev 1756)
+++ sandbox/redlining/ux/FeatureEditing/ux/widgets/form/FeatureEditingPanel.js 2010-01-15 14:51:15 UTC (rev 1757)
@@ -85,6 +85,7 @@
this.initMap();
this.initControler();
this.initLayers(this.layers);
+ this.initActions();
this.initToolbar();
this.initForm();
@@ -132,15 +133,19 @@
this.controler.setActiveLayer(this.layers[0]);
},
- /** private: method[initToolbar]
- * Initialize the controls of the controler and create a toolbar from the
- * actions created.
+ /** private: method[initActions]
+ * Initialize the controls of the controler resulting in creating actions.
*/
- initToolbar: function() {
+ initActions: function() {
this.controler.initDrawControls();
this.controler.initFeatureControl();
this.controler.initDeleteAllAction();
+ },
+ /** private: method[initToolbar]
+ *
+ */
+ initToolbar: function() {
// Add buttons and toolbar
Ext.apply(this, {tbar: new Ext.Toolbar(this.controler.actions)});
},
Modified: sandbox/redlining/ux/FeatureEditing/ux/widgets/form/FeaturePanel.js
===================================================================
--- sandbox/redlining/ux/FeatureEditing/ux/widgets/form/FeaturePanel.js 2010-01-15 13:11:18 UTC (rev 1756)
+++ sandbox/redlining/ux/FeatureEditing/ux/widgets/form/FeaturePanel.js 2010-01-15 14:51:15 UTC (rev 1757)
@@ -98,6 +98,12 @@
*/
attributeFieldSetId: "gx_featurepanel_attributefieldset_id",
+ /** api: config[labelAttribute]
+ * ``String``
+ * The attribute name to use as a label
+ */
+ labelAttribute: "name",
+
/** private: method[initComponent]
*/
initComponent: function() {
@@ -230,6 +236,13 @@
}
this.parseFormFieldsToFeatureAttributes(feature);
+ if(feature.isLabel === true) {
+ if(feature.attributes[this.labelAttribute] != "") {
+ feature.layer.drawFeature(feature);
+ } else {
+ feature.layer.destroyFeatures([feature]);
+ }
+ }
},
/** private: method[parseFeatureAttributesToFormFields]
Modified: sandbox/redlining/ux/FeatureEditing/ux/widgets/form/RedLiningPanel.js
===================================================================
--- sandbox/redlining/ux/FeatureEditing/ux/widgets/form/RedLiningPanel.js 2010-01-15 13:11:18 UTC (rev 1756)
+++ sandbox/redlining/ux/FeatureEditing/ux/widgets/form/RedLiningPanel.js 2010-01-15 14:51:15 UTC (rev 1757)
@@ -55,7 +55,40 @@
*/
initLayer: function(layer) {
if(!layer){
- layer = new OpenLayers.Layer.Vector("Cosmetic");
+ var labelStyle = {
+ label: "${name}",
+ labelSelect: true,
+ pointRadius: "${radius}"
+ };
+ var styleOptions = {
+ context: {
+ 'name': function(feature) {
+ var szValue;
+ if (feature.attributes['name'] && feature.isLabel === true) {
+ szValue = feature.attributes['name'];
+ } else {
+ szValue = "";
+ }
+ return szValue;
+ },
+ 'radius': function(feature) {
+ return (feature.isLabel === true) ? 0 : 6;
+ }
+ }
+ };
+
+ var style = new OpenLayers.Style(
+ OpenLayers.Util.applyDefaults(
+ labelStyle,OpenLayers.Feature.Vector.style["default"]),
+ styleOptions
+ );
+
+ var styleMap = new OpenLayers.StyleMap({
+ "default": style
+ });
+
+ layer = new OpenLayers.Layer.Vector(
+ "Cosmetic", {'styleMap': styleMap});
}
this.layers = [layer];
More information about the Commits
mailing list