dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #10021
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2730: Improved code.
Merge authors:
Jan Henrik Øverland (janhenrik-overland)
------------------------------------------------------------
revno: 2730 [merge]
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2011-01-24 16:21:42 +0100
message:
Improved code.
modified:
dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/global.js
dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/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/script/global.js'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/global.js 2011-01-24 11:33:18 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/global.js 2011-01-24 15:20:31 +0000
@@ -298,6 +298,25 @@
features[i].geometry.transform(new OpenLayers.Projection("EPSG:4326"), new OpenLayers.Projection("EPSG:900913"));
}
return features;
+ },
+
+ createOverlay: function(name, fillColor, fillOpacity, strokeColor, strokeWidth, url) {
+ return new OpenLayers.Layer.Vector(name, {
+ 'visibility': false,
+ 'styleMap': new OpenLayers.StyleMap({
+ 'default': new OpenLayers.Style(
+ OpenLayers.Util.applyDefaults(
+ {'fillColor': fillColor, 'fillOpacity': fillOpacity, 'strokeColor': strokeColor, 'strokeWidth': strokeWidth},
+ OpenLayers.Feature.Vector.style['default']
+ )
+ )
+ }),
+ 'strategies': [new OpenLayers.Strategy.Fixed()],
+ 'protocol': new OpenLayers.Protocol.HTTP({
+ 'url': url,
+ 'format': new OpenLayers.Format.GeoJSON()
+ })
+ });
}
};
=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/index.js'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/index.js 2011-01-24 11:33:18 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/index.js 2011-01-24 15:20:31 +0000
@@ -380,30 +380,19 @@
};
for (var i = 0; i < r.length; i++) {
- var overlay = new OpenLayers.Layer.Vector(r[i].data.name, {
- 'visibility': false,
- 'styleMap': new OpenLayers.StyleMap({
- 'default': new OpenLayers.Style(
- OpenLayers.Util.applyDefaults({
- 'fillColor': r[i].data.fillColor,
- 'fillOpacity': parseFloat(r[i].data.fillOpacity),
- 'strokeColor': r[i].data.strokeColor,
- 'strokeWidth': parseFloat(r[i].data.strokeWidth)
- },
- OpenLayers.Feature.Vector.style['default']
- )
- )
- }),
- 'strategies': [new OpenLayers.Strategy.Fixed()],
- 'protocol': new OpenLayers.Protocol.HTTP({
- 'url': G.conf.path_mapping + 'getGeoJsonFromFile.action?name=' + r[i].data.mapSource,
- 'format': new OpenLayers.Format.GeoJSON()
- })
- });
-
+ var overlay = G.util.createOverlay(
+ r[i].data.name,
+ r[i].data.fillColor,
+ parseFloat(r[i].data.fillOpacity),
+ r[i].data.strokeColor,
+ parseFloat(r[i].data.strokeWidth),
+ G.conf.path_mapping + 'getGeoJsonFromFile.action?name=' + r[i].data.mapSource
+ );
+
overlay.events.register('loadstart', null, loadStart);
overlay.events.register('loadend', null, loadEnd);
overlay.isOverlay = true;
+
G.vars.map.addLayer(overlay);
G.vars.map.getLayersByName(r[i].data.name)[0].setZIndex(10000);
G.vars.map.overlays.push(r[i].data.name);
@@ -1651,22 +1640,8 @@
Ext.message.msg(true, 'Overlay <span class="x-msg-hl">' + mln + '</span> ' + G.i18n.registered);
G.stores.overlay.load();
- var overlay = new OpenLayers.Layer.Vector(mln, {
- 'visibility': false,
- 'styleMap': new OpenLayers.StyleMap({
- 'default': new OpenLayers.Style(
- OpenLayers.Util.applyDefaults(
- {'fillColor': mlfc, 'fillOpacity': mlfo, 'strokeColor': mlsc, 'strokeWidth': mlsw},
- OpenLayers.Feature.Vector.style['default']
- )
- )
- }),
- 'strategies': [new OpenLayers.Strategy.Fixed()],
- 'protocol': new OpenLayers.Protocol.HTTP({
- 'url': G.conf.path_mapping + 'getGeoJsonFromFile.action?name=' + mlmsf,
- 'format': new OpenLayers.Format.GeoJSON()
- })
- });
+ var overlay = G.util.createOverlay(mln, mlfc, mlfo, mlsc, mlsw,
+ G.conf.path_mapping + 'getGeoJsonFromFile.action?name=' + mlmsf);
if (G.vars.map.getLayersByName(mln).length) {
G.vars.map.getLayersByName(mln)[0].destroy();