dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #14905
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 5186: (GIS) File overlay labels implemented (looking for a property called 'name' in the geojson file).
Merge authors:
Jan Henrik Øverland (janhenrik-overland)
------------------------------------------------------------
revno: 5186 [merge]
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2011-11-21 15:00:18 +0100
message:
(GIS) File overlay labels implemented (looking for a property called 'name' in the geojson file).
modified:
dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/javascript/global.js
dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/javascript/index.js
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/javascript/global.js'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/javascript/global.js 2011-10-24 15:22:51 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/javascript/global.js 2011-11-21 13:58:44 +0000
@@ -221,65 +221,122 @@
},
labels: {
- getActivatedOpenLayersStyleMap: function(fsize, fweight, fstyle, fcolor) {
- return new OpenLayers.StyleMap({
- 'default' : new OpenLayers.Style(
- OpenLayers.Util.applyDefaults({
- 'fillOpacity': 1,
- 'strokeWidth': 1,
- 'strokeColor': '#fff',
- 'label': '${labelString}',
- 'fontFamily': 'arial,lucida sans unicode',
- 'fontSize': fsize ? fsize : 13,
- 'fontWeight': fweight ? 'bold' : 'normal',
- 'fontStyle': fstyle ? 'italic' : 'normal',
- 'fontColor': fcolor ? fcolor : '#000000'
- },
- OpenLayers.Feature.Vector.style['default'])
- ),
- 'select': new OpenLayers.Style({
- 'strokeColor': '#000000',
- 'strokeWidth': 2,
- 'cursor': 'pointer'
- })
- });
- },
- getDeactivatedOpenLayersStyleMap: function() {
- return new OpenLayers.StyleMap({
- 'default': new OpenLayers.Style(
- OpenLayers.Util.applyDefaults({
- 'fillOpacity': 1,
- 'strokeColor': '#fff',
- 'strokeWidth': 1
- },
- OpenLayers.Feature.Vector.style['default'])
- ),
- 'select': new OpenLayers.Style({
- 'strokeColor': '#000000',
- 'strokeWidth': 2,
- 'cursor': 'pointer'
- })
- });
- },
- toggleFeatureLabels: function(widget, fsize, fweight, fstyle, fcolor) {
- function activateLabels() {
- widget.layer.styleMap = this.getActivatedOpenLayersStyleMap(fsize, fweight, fstyle, fcolor);
- widget.labels = true;
- }
- function deactivateLabels(scope) {
- widget.layer.styleMap = this.getDeactivatedOpenLayersStyleMap();
- widget.labels = false;
- }
+ vector: {
+ getActivatedOpenLayersStyleMap: function(fsize, fweight, fstyle, fcolor) {
+ return new OpenLayers.StyleMap({
+ 'default' : new OpenLayers.Style(
+ OpenLayers.Util.applyDefaults({
+ 'fillOpacity': 1,
+ 'strokeWidth': 1,
+ 'strokeColor': '#fff',
+ 'label': '${labelString}',
+ 'fontFamily': 'arial,lucida sans unicode',
+ 'fontSize': fsize ? fsize : 13,
+ 'fontWeight': fweight ? 'bold' : 'normal',
+ 'fontStyle': fstyle ? 'italic' : 'normal',
+ 'fontColor': fcolor ? fcolor : '#000000'
+ },
+ OpenLayers.Feature.Vector.style['default'])
+ ),
+ 'select': new OpenLayers.Style({
+ 'strokeColor': '#000000',
+ 'strokeWidth': 2,
+ 'cursor': 'pointer'
+ })
+ });
+ },
+ getDeactivatedOpenLayersStyleMap: function() {
+ return new OpenLayers.StyleMap({
+ 'default': new OpenLayers.Style(
+ OpenLayers.Util.applyDefaults({
+ 'fillOpacity': 1,
+ 'strokeColor': '#fff',
+ 'strokeWidth': 1
+ },
+ OpenLayers.Feature.Vector.style['default'])
+ ),
+ 'select': new OpenLayers.Style({
+ 'strokeColor': '#000000',
+ 'strokeWidth': 2,
+ 'cursor': 'pointer'
+ })
+ });
+ },
+ toggleFeatureLabels: function(widget, fsize, fweight, fstyle, fcolor) {
+ function activateLabels() {
+ widget.layer.styleMap = this.getActivatedOpenLayersStyleMap(fsize, fweight, fstyle, fcolor);
+ widget.labels = true;
+ }
+ function deactivateLabels(scope) {
+ widget.layer.styleMap = this.getDeactivatedOpenLayersStyleMap();
+ widget.labels = false;
+ }
+
+ if (widget.labels) {
+ deactivateLabels.call(this);
+ }
+ else {
+ activateLabels.call(this);
+ }
- if (widget.labels) {
- deactivateLabels.call(this);
- }
- else {
- activateLabels.call(this);
- }
-
- widget.applyValues();
- }
+ widget.applyValues();
+ }
+ },
+ fileOverlay: {
+ getActivatedOpenLayersStyleMap: function(layer) {
+ var style = layer.styleMap.styles.default.defaultStyle;
+ return new OpenLayers.StyleMap({
+ 'default' : new OpenLayers.Style(
+ OpenLayers.Util.applyDefaults({
+ 'fillOpacity': style.fillOpacity,
+ 'fillColor': style.fillColor,
+ 'strokeWidth': style.strokeWidth,
+ 'strokeColor': style.strokeWidth,
+ 'label': '${name}',
+ 'fontFamily': 'arial,lucida sans unicode',
+ 'fontSize': 13,
+ 'fontWeight': 'normal',
+ 'fontStyle': 'normal',
+ 'fontColor': '#000000'
+ },
+ OpenLayers.Feature.Vector.style['default'])
+ )
+ });
+ },
+ getDeactivatedOpenLayersStyleMap: function(layer) {
+ var style = layer.styleMap.styles.default.defaultStyle;
+ return new OpenLayers.StyleMap({
+ 'default' : new OpenLayers.Style(
+ OpenLayers.Util.applyDefaults({
+ 'fillOpacity': style.fillOpacity,
+ 'fillColor': style.fillColor,
+ 'strokeWidth': style.strokeWidth,
+ 'strokeColor': style.strokeWidth
+ },
+ OpenLayers.Feature.Vector.style['default'])
+ )
+ });
+ },
+ toggleFeatureLabels: function(layer) {
+ function activateLabels() {
+ layer.styleMap = this.getActivatedOpenLayersStyleMap(layer);
+ layer.labels = true;
+ layer.refresh();
+ }
+ function deactivateLabels(scope) {
+ layer.styleMap = this.getDeactivatedOpenLayersStyleMap(layer);
+ layer.labels = false;
+ layer.refresh();
+ }
+
+ if (layer.labels) {
+ deactivateLabels.call(this);
+ }
+ else {
+ activateLabels.call(this);
+ }
+ }
+ }
},
measureDistance: {
@@ -900,7 +957,7 @@
if (this.widget.labels) {
this.widget.labels = false;
- G.util.labels.toggleFeatureLabels(this.widget, nf.getValue(), item.cmp.strong.getValue(),
+ G.util.labels.vector.toggleFeatureLabels(this.widget, nf.getValue(), item.cmp.strong.getValue(),
item.cmp.italic.getValue(), item.cmp.color.getValue());
}
}
@@ -918,7 +975,7 @@
if (this.widget.labels) {
this.widget.labels = false;
- G.util.labels.toggleFeatureLabels(this.widget, item.cmp.fontSize.getValue(),
+ G.util.labels.vector.toggleFeatureLabels(this.widget, item.cmp.fontSize.getValue(),
checked, item.cmp.italic.getValue(), item.cmp.color.getValue());
}
}
@@ -936,7 +993,7 @@
if (this.widget.labels) {
this.widget.labels = false;
- G.util.labels.toggleFeatureLabels(this.widget, item.cmp.fontSize.getValue(),
+ G.util.labels.vector.toggleFeatureLabels(this.widget, item.cmp.fontSize.getValue(),
item.cmp.strong.getValue(), checked, item.cmp.color.getValue());
}
}
@@ -957,7 +1014,7 @@
if (this.widget.labels) {
this.widget.labels = false;
- G.util.labels.toggleFeatureLabels(this.widget, item.cmp.fontSize.getValue(),
+ G.util.labels.vector.toggleFeatureLabels(this.widget, item.cmp.fontSize.getValue(),
item.cmp.strong.getValue(), item.cmp.italic.getValue(), cf.getValue());
}
}
@@ -1002,7 +1059,7 @@
scope: this,
handler: function() {
if (layer.features.length) {
- G.util.labels.toggleFeatureLabels(layer.widget, this.cmp.fontSize.getValue(),
+ G.util.labels.vector.toggleFeatureLabels(layer.widget, this.cmp.fontSize.getValue(),
this.cmp.strong.getValue(), this.cmp.italic.getValue(), this.cmp.color.getValue());
}
else {
=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/javascript/index.js'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/javascript/index.js 2011-11-15 19:22:58 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/javascript/index.js 2011-11-21 13:58:44 +0000
@@ -2215,6 +2215,14 @@
contextMenuOverlayFile: new Ext.menu.Menu({
items: [
{
+ text: 'Labels',
+ iconCls: 'menu-layeroptions-labels',
+ handler: function(item) {
+ var layer = item.parentMenu.contextNode.layer;
+ G.util.labels.fileOverlay.toggleFeatureLabels(layer);
+ }
+ },
+ {
text: 'Opacity',
iconCls: 'menu-layeroptions-opacity',
menu: {