← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4999: (GIS) WMS legend now available + WMS layers now include a time/period specification (ISO8601).

 

Merge authors:
  Jan Henrik Øverland (janhenrik-overland)
------------------------------------------------------------
revno: 4999 [merge]
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2011-10-21 19:30:42 +0200
message:
  (GIS) WMS legend now available + WMS layers now include a time/period specification (ISO8601).
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MapLayer.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MappingService.java
  dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/DefaultMappingService.java
  dhis-2/dhis-services/dhis-service-mapping/src/main/resources/org/hisp/dhis/mapping/hibernate/MapLayer.hbm.xml
  dhis-2/dhis-services/dhis-service-mapping/src/test/java/org/hisp/dhis/mapping/MappingServiceTest.java
  dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/AddOrUpdateMapLayerAction.java
  dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/css/style.css
  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-api/src/main/java/org/hisp/dhis/mapping/MapLayer.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MapLayer.java	2011-08-04 12:28:58 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MapLayer.java	2011-10-20 20:54:17 +0000
@@ -40,9 +40,11 @@
     private String type;
 
     private String url;
-    
+
     private String layers;
 
+    private String time;
+
     private String fillColor;
 
     private double fillOpacity;
@@ -55,13 +57,14 @@
     {
     }
 
-    public MapLayer( String name, String type, String url, String layers, String fillColor,
+    public MapLayer( String name, String type, String url, String layers, String time, String fillColor,
         double fillOpacity, String strokeColor, int strokeWidth )
     {
         this.name = name;
         this.type = type;
         this.url = url;
         this.layers = layers;
+        this.time = time;
         this.fillColor = fillColor;
         this.fillOpacity = fillOpacity;
         this.strokeColor = strokeColor;
@@ -155,6 +158,16 @@
         this.layers = layers;
     }
 
+    public String getTime()
+    {
+        return time;
+    }
+
+    public void setTime( String time )
+    {
+        this.time = time;
+    }
+
     public String getFillColor()
     {
         return fillColor;

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MappingService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MappingService.java	2011-08-04 12:28:58 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MappingService.java	2011-10-20 20:54:17 +0000
@@ -47,9 +47,9 @@
     final String MAP_VALUE_TYPE_INDICATOR = "indicator";
 
     final String MAP_VALUE_TYPE_DATAELEMENT = "dataelement";
-    
+
     final String MAP_LEGEND_SYMBOLIZER_COLOR = "color";
-    
+
     final String MAP_LEGEND_SYMBOLIZER_IMAGE = "image";
 
     final String MAPLEGENDSET_TYPE_AUTOMATIC = "automatic";
@@ -65,25 +65,25 @@
     final String ORGANISATION_UNIT_SELECTION_TYPE_PARENT = "parent";
 
     final String ORGANISATION_UNIT_SELECTION_TYPE_LEVEL = "level";
-    
+
     final String MAP_LAYER_TYPE_BASELAYER = "baselayer";
-    
+
     final String MAP_LAYER_TYPE_OVERLAY = "overlay";
 
     // -------------------------------------------------------------------------
     // IndicatorMapValue
     // -------------------------------------------------------------------------
 
-    Collection<AggregatedMapValue> getIndicatorMapValues( Integer indicatorId, Period period, Date startDate, Date endDate, 
-        Integer parentOrganisationUnitId, Integer level );
+    Collection<AggregatedMapValue> getIndicatorMapValues( Integer indicatorId, Period period, Date startDate,
+        Date endDate, Integer parentOrganisationUnitId, Integer level );
 
     // -------------------------------------------------------------------------
     // DataMapValue
     // -------------------------------------------------------------------------
 
-    Collection<AggregatedMapValue> getDataElementMapValues( Integer dataElementId, Period period, Date startDate, Date endDate, 
-        Integer parentOrganisationUnitId, Integer level );
-    
+    Collection<AggregatedMapValue> getDataElementMapValues( Integer dataElementId, Period period, Date startDate,
+        Date endDate, Integer parentOrganisationUnitId, Integer level );
+
     Collection<AggregatedMapValue> getInfrastructuralDataElementMapValues( Integer periodId, Integer organisationUnitId );
 
     // -------------------------------------------------------------------------
@@ -131,13 +131,12 @@
     // -------------------------------------------------------------------------
 
     int addMapView( MapView mapView );
-    
-    void addMapView( String name, boolean system, String mapValueType, Integer indicatorGroupId,
-        Integer indicatorId, Integer dataElementGroupId, Integer dataElementId, String periodTypeName,
-        Integer periodId, String startDate, String endDate, Integer parentOrganisationUnitId,
-        Integer organisationUnitLevel, String mapLegendType, Integer method, Integer classes, String bounds,
-        String colorLow, String colorHigh, Integer mapLegendSetId, Integer radiusLow, Integer radiusHigh,
-        String longitude, String latitude, int zoom );
+
+    void addMapView( String name, boolean system, String mapValueType, Integer indicatorGroupId, Integer indicatorId,
+        Integer dataElementGroupId, Integer dataElementId, String periodTypeName, Integer periodId, String startDate,
+        String endDate, Integer parentOrganisationUnitId, Integer organisationUnitLevel, String mapLegendType,
+        Integer method, Integer classes, String bounds, String colorLow, String colorHigh, Integer mapLegendSetId,
+        Integer radiusLow, Integer radiusHigh, String longitude, String latitude, int zoom );
 
     void updateMapView( MapView mapView );
 
@@ -159,7 +158,7 @@
 
     void updateMapLayer( MapLayer mapLayer );
 
-    void addOrUpdateMapLayer( String name, String type, String url, String layers, String fillColor,
+    void addOrUpdateMapLayer( String name, String type, String url, String layers, String time, String fillColor,
         double fillOpacity, String strokeColor, int strokeWidth );
 
     void deleteMapLayer( MapLayer mapLayer );

=== modified file 'dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/DefaultMappingService.java'
--- dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/DefaultMappingService.java	2011-08-04 12:28:58 +0000
+++ dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/DefaultMappingService.java	2011-10-20 20:54:17 +0000
@@ -308,17 +308,18 @@
         return values;
     }
 
-    public Collection<AggregatedMapValue> getInfrastructuralDataElementMapValues( Integer periodId, Integer organisationUnitId )
+    public Collection<AggregatedMapValue> getInfrastructuralDataElementMapValues( Integer periodId,
+        Integer organisationUnitId )
     {
         String aggregationStrategy = (String) systemSettingManager.getSystemSetting( KEY_AGGREGATION_STRATEGY,
             DEFAULT_AGGREGATION_STRATEGY );
-        
+
         DataElementGroup group = configurationService.getConfiguration().getInfrastructuralDataElements();
-        
+
         if ( group == null )
         {
             group = dataElementService.getAllDataElementGroups().iterator().next();
-        }        
+        }
 
         Period period = periodService.getPeriod( periodId );
 
@@ -333,7 +334,7 @@
         OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit( organisationUnitId );
 
         Collection<AggregatedMapValue> values = new HashSet<AggregatedMapValue>();
-        
+
         if ( group != null )
         {
             for ( DataElement dataElement : group.getMembers() )
@@ -341,13 +342,13 @@
                 Double value = aggregationStrategy.equals( AGGREGATION_STRATEGY_REAL_TIME ) ? aggregationService
                     .getAggregatedDataValue( dataElement, null, startDate, endDate, organisationUnit )
                     : aggregatedDataValueService.getAggregatedValue( dataElement, period, organisationUnit );
-    
+
                 value = value != null ? value : 0; // TODO improve
-    
+
                 AggregatedMapValue mapValue = new AggregatedMapValue();
                 mapValue.setDataElementName( dataElement.getShortName() );
                 mapValue.setValue( value );
-    
+
                 values.add( mapValue );
             }
         }
@@ -647,8 +648,8 @@
         mappingStore.updateMapLayer( mapLayer );
     }
 
-    public void addOrUpdateMapLayer( String name, String type, String url, String layers, String fillColor,
-        double fillOpacity, String strokeColor, int strokeWidth )
+    public void addOrUpdateMapLayer( String name, String type, String url, String layers, String time,
+        String fillColor, double fillOpacity, String strokeColor, int strokeWidth )
     {
         MapLayer mapLayer = mappingStore.getMapLayerByName( name );
 
@@ -658,6 +659,7 @@
             mapLayer.setType( type );
             mapLayer.setUrl( url );
             mapLayer.setLayers( layers );
+            mapLayer.setTime( time );
             mapLayer.setFillColor( fillColor );
             mapLayer.setFillOpacity( fillOpacity );
             mapLayer.setStrokeColor( strokeColor );
@@ -667,7 +669,7 @@
         }
         else
         {
-            addMapLayer( new MapLayer( name, type, url, layers, fillColor, fillOpacity, strokeColor, strokeWidth ) );
+            addMapLayer( new MapLayer( name, type, url, layers, time, fillColor, fillOpacity, strokeColor, strokeWidth ) );
         }
     }
 

=== modified file 'dhis-2/dhis-services/dhis-service-mapping/src/main/resources/org/hisp/dhis/mapping/hibernate/MapLayer.hbm.xml'
--- dhis-2/dhis-services/dhis-service-mapping/src/main/resources/org/hisp/dhis/mapping/hibernate/MapLayer.hbm.xml	2011-08-04 12:28:58 +0000
+++ dhis-2/dhis-services/dhis-service-mapping/src/main/resources/org/hisp/dhis/mapping/hibernate/MapLayer.hbm.xml	2011-10-20 20:54:17 +0000
@@ -18,6 +18,8 @@
 
     <property name="layers" column="layers" type="text" />
 
+    <property name="time" column="time" type="text" />
+
     <property name="fillColor" column="fillcolor" />
 
     <property name="fillOpacity" column="fillopacity" not-null="true" />

=== modified file 'dhis-2/dhis-services/dhis-service-mapping/src/test/java/org/hisp/dhis/mapping/MappingServiceTest.java'
--- dhis-2/dhis-services/dhis-service-mapping/src/test/java/org/hisp/dhis/mapping/MappingServiceTest.java	2011-08-21 10:33:32 +0000
+++ dhis-2/dhis-services/dhis-service-mapping/src/test/java/org/hisp/dhis/mapping/MappingServiceTest.java	2011-10-20 20:54:17 +0000
@@ -384,7 +384,8 @@
     }
 
     @Test
-    @Ignore //TODO
+    @Ignore
+    // TODO
     public void testGetMapViewsByFeatureType()
     {
         MapView mapView1 = new MapView( "MapViewA", null, MappingService.MAP_VALUE_TYPE_INDICATOR, indicatorGroup,
@@ -417,8 +418,8 @@
     @Test
     public void testAddGetMapLayer()
     {
-        MapLayer mapLayer = new MapLayer( "MapLayerA", MappingService.MAP_LAYER_TYPE_BASELAYER, "", "", "A", 0.1, "B",
-            1 );
+        MapLayer mapLayer = new MapLayer( "MapLayerA", MappingService.MAP_LAYER_TYPE_BASELAYER, "", "", "", "A", 0.1,
+            "B", 1 );
 
         int id = mappingService.addMapLayer( mapLayer );
 
@@ -433,8 +434,8 @@
     @Test
     public void testGetUpdateDeleteMapLayerByName()
     {
-        MapLayer mapLayer = new MapLayer( "MapLayerA", MappingService.MAP_LAYER_TYPE_BASELAYER, "", "", "A", 0.1, "B",
-            1 );
+        MapLayer mapLayer = new MapLayer( "MapLayerA", MappingService.MAP_LAYER_TYPE_BASELAYER, "", "", "", "A", 0.1,
+            "B", 1 );
 
         int id = mappingService.addMapLayer( mapLayer );
 
@@ -454,13 +455,14 @@
     @Test
     public void testGetAllMapLayers()
     {
-        MapLayer mapLayer1 = new MapLayer( "MapLayerA", MappingService.MAP_LAYER_TYPE_BASELAYER, "mapSourceA",
-            "layerA", "A", 0.1, "B", 1 );
-        MapLayer mapLayer2 = new MapLayer( "MapLayerB", MappingService.MAP_LAYER_TYPE_OVERLAY, "", "", "A", 0.1, "B", 1 );
-        MapLayer mapLayer3 = new MapLayer( "MapLayerC", MappingService.MAP_LAYER_TYPE_OVERLAY, "mapSourceC", "layerC",
-            "C", 0.1, "D", 2 );
-        MapLayer mapLayer4 = new MapLayer( "MapLayerD", MappingService.MAP_LAYER_TYPE_BASELAYER, "mapSourceD",
-            "layerA", "C", 0.1, "D", 2 );
+        MapLayer mapLayer1 = new MapLayer( "MapLayerA", MappingService.MAP_LAYER_TYPE_BASELAYER, "", "", "", "A", 0.1,
+            "B", 1 );
+        MapLayer mapLayer2 = new MapLayer( "MapLayerA", MappingService.MAP_LAYER_TYPE_BASELAYER, "", "", "", "C", 0.2,
+            "D", 2 );
+        MapLayer mapLayer3 = new MapLayer( "MapLayerA", MappingService.MAP_LAYER_TYPE_BASELAYER, "", "", "", "E", 0.3,
+            "F", 3 );
+        MapLayer mapLayer4 = new MapLayer( "MapLayerA", MappingService.MAP_LAYER_TYPE_BASELAYER, "", "", "", "G", 0.4,
+            "H", 4 );
 
         int idA = mappingService.addMapLayer( mapLayer1 );
         int idB = mappingService.addMapLayer( mapLayer2 );
@@ -479,14 +481,14 @@
         List<MapLayer> baseLayers = new ArrayList<MapLayer>();
         List<MapLayer> overlayLayers = new ArrayList<MapLayer>();
 
-        MapLayer mapLayer1 = new MapLayer( "MapLayerA", MappingService.MAP_LAYER_TYPE_BASELAYER, "mapSourceA",
-            "layerA", "A", 0.1, "B", 1 );
-        MapLayer mapLayer2 = new MapLayer( "MapLayerB", MappingService.MAP_LAYER_TYPE_OVERLAY, "mapSourceB", "", "A",
-            0.1, "B", 1 );
-        MapLayer mapLayer3 = new MapLayer( "MapLayerC", MappingService.MAP_LAYER_TYPE_OVERLAY, "mapSourceC", "layerC",
-            "C", 0.1, "D", 2 );
-        MapLayer mapLayer4 = new MapLayer( "MapLayerD", MappingService.MAP_LAYER_TYPE_BASELAYER, "mapSourceD",
-            "layerA", "C", 0.1, "D", 2 );
+        MapLayer mapLayer1 = new MapLayer( "MapLayerA", MappingService.MAP_LAYER_TYPE_BASELAYER, "", "", "", "A", 0.1,
+            "B", 1 );
+        MapLayer mapLayer2 = new MapLayer( "MapLayerA", MappingService.MAP_LAYER_TYPE_BASELAYER, "", "", "", "C", 0.2,
+            "D", 2 );
+        MapLayer mapLayer3 = new MapLayer( "MapLayerA", MappingService.MAP_LAYER_TYPE_BASELAYER, "", "", "", "E", 0.3,
+            "F", 3 );
+        MapLayer mapLayer4 = new MapLayer( "MapLayerA", MappingService.MAP_LAYER_TYPE_BASELAYER, "", "", "", "G", 0.4,
+            "H", 4 );
 
         baseLayers.add( mapLayer1 );
         baseLayers.add( mapLayer4 );

=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/AddOrUpdateMapLayerAction.java'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/AddOrUpdateMapLayerAction.java	2011-08-04 12:28:58 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/AddOrUpdateMapLayerAction.java	2011-10-20 20:54:17 +0000
@@ -81,6 +81,13 @@
         this.layers = layers;
     }
     
+    private String time;
+    
+    public void setTime( String time )
+    {
+        this.time = time;
+    }
+
     private String fillColor;
 
     public void setFillColor( String fillColor )
@@ -115,7 +122,7 @@
 
     public String execute()
     {
-        mappingService.addOrUpdateMapLayer( name, type, url, layers, fillColor, fillOpacity, strokeColor, strokeWidth );
+        mappingService.addOrUpdateMapLayer( name, type, url, layers, time, fillColor, fillOpacity, strokeColor, strokeWidth );
         
         return SUCCESS;
     }

=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/css/style.css'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/css/style.css	2011-10-20 09:53:26 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/css/style.css	2011-10-20 20:54:17 +0000
@@ -154,6 +154,9 @@
 .menu-layeroptions-labels {
     background-image:url('../../../images/labels.png');
 }
+.menu-layeroptions-legend {
+    background-image:url('../../../images/legendset.png');
+}
 .menu-featureoptions-info {
     background-image:url('../../../images/information2.png');
 }

=== 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-08-31 10:08:28 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/javascript/global.js	2011-10-21 17:27:13 +0000
@@ -69,6 +69,8 @@
     map_layer_type_baselayer: 'baselayer',
     map_layer_type_overlay: 'overlay',
     map_layer_type_thematic: 'thematic',
+    map_overlay_type_wms: 'wms',
+    map_overlay_type_file: 'file',
 	map_value_type_indicator: 'indicator',
 	map_value_type_dataelement: 'dataelement',
     map_date_type_fixed: 'fixed',
@@ -364,19 +366,26 @@
         return p.transform(new OpenLayers.Projection("EPSG:4326"), new OpenLayers.Projection("EPSG:900913"));
     },
     
-    createWMSLayer: function(name, url, layer) {
-        return new OpenLayers.Layer.WMS(name, url, 
-            {
-                layers: layer,
-                transparent: true,
-                format: 'image/png'
-            },
-            {
-                isBaseLayer: false,
-                buffer: 0,
-                ratio: 1
-            }
-        );
+    createWMSLayer: function(name, url, layers, time) {
+        var options = {
+            layers: layers,
+            transparent: true,
+            format: 'image/png'
+        };
+        if (time) {
+            options.time = time;
+        }
+        var layer = new OpenLayers.Layer.WMS(name, url, options, {
+            isBaseLayer: false,
+            buffer: 0,
+            ratio: 1
+        });
+        layer.baseUrl = url;
+        return layer;
+    },
+    
+    convertWMSUrlToLegendString: function(url) {
+        return url.replace('.xml','figmap?REQUEST=GetLegendGraphic');
     },
     
     createOverlay: function(name, fillColor, fillOpacity, strokeColor, strokeWidth, url) {

=== 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-08-31 10:08:28 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/javascript/index.js	2011-10-21 17:27:13 +0000
@@ -1,4 +1,4 @@
-Ext.onReady( function() {
+Ext.onReady( function() {
     Ext.BLANK_IMAGE_URL = '../resources/ext-ux/theme/gray-extend/gray-extend/s.gif';
 	Ext.layout.FormLayout.prototype.trackLabels = true;
     Ext.QuickTips.init();
@@ -411,6 +411,7 @@
                 for (var i = 0; i < r.length; i++) {
                     var baseLayer = G.util.createWMSLayer(r[i].data.name, r[i].data.url, r[i].data.layers);                    
                     baseLayer.layerType = G.conf.map_layer_type_baselayer;
+                    baseLayer.overlayType = G.conf.map_overlay_type_wms;
                     baseLayer.setVisibility(false);                    
                     G.vars.map.addLayer(baseLayer);
                 }
@@ -1689,6 +1690,14 @@
                         fieldLabel: G.i18n.layer,
                         width: G.conf.combo_width_fieldset
                     },
+                    {
+                        xtype: 'textfield',
+                        id: 'baselayertime_tf',
+                        emptytext: 'Optional',
+                        labelSeparator: G.conf.labelseparator,
+                        fieldLabel: 'Time',
+                        width: G.conf.combo_width_fieldset
+                    },
                     {html: '<div class="window-p"></div>'},
                     {html: '<div class="window-info">' + G.i18n.delete_ + ' WMS ' + G.i18n.overlay + '</div>'},
                     {
@@ -1720,16 +1729,25 @@
                     var bln = Ext.getCmp('baselayername_tf').getRawValue();
                     var blu = Ext.getCmp('baselayerurl_tf').getRawValue();
                     var bll = Ext.getCmp('baselayerlayer_tf').getRawValue();
+                    var blt = Ext.getCmp('baselayertime_tf').getRawValue();
                     
                     if (!bln || !blu || !bll) {
                         Ext.message.msg(false, G.i18n.form_is_not_complete);
                         return;
                     }
                     
+                    var params = {};
+                    params.name = bln;
+                    params.type = G.conf.map_layer_type_baselayer;
+                    params.url = blu;
+                    params.layers = bll;
+                    if (blt) {
+                        params.time = blt;
+                    }
+                    
                     Ext.Ajax.request({
                         url: G.conf.path_mapping + 'addOrUpdateMapLayer' + G.conf.type,
-                        method: 'POST',
-                        params: {name: bln, type: G.conf.map_layer_type_baselayer, url: blu, layers: bll},
+                        params: params,
                         success: function(r) {
                             Ext.message.msg(true, 'WMS ' + G.i18n.overlay + ' <span class="x-msg-hl">' + bln + '</span> ' + G.i18n.registered);
                             G.stores.baseLayer.load();
@@ -1738,8 +1756,9 @@
                                 G.vars.map.getLayersByName(bln)[0].destroy();
                             }
                             
-                            var baselayer = G.util.createWMSLayer(bln, blu, bll);  
+                            var baselayer = G.util.createWMSLayer(bln, blu, bll, blt);  
                             baselayer.layerType = G.conf.map_layer_type_baselayer;
+                            baselayer.overlayType = G.conf.map_overlay_type_wms;
                             baselayer.setVisibility(false);                            
                             G.vars.map.addLayer(baselayer);
                             
@@ -2063,8 +2082,7 @@
             }
         }
     });
-    adminWindow.setPagePosition(G.conf.window_x_left,G.conf.window_y_left);
-    
+    adminWindow.setPagePosition(G.conf.window_x_left,G.conf.window_y_left);    
 
     var layerTree = new Ext.tree.TreePanel({
         id: 'layertree_tp',
@@ -2122,7 +2140,41 @@
                 }
             ]
         }),
-        contextMenuOverlay: new Ext.menu.Menu({
+        contextMenuOverlayWMS: new Ext.menu.Menu({
+            items: [
+                {
+                    text: 'Show legend',
+                    iconCls: 'menu-layeroptions-legend',
+                    handler: function(item) {
+                        var layer = item.parentMenu.contextNode.layer;
+                        var url = G.util.convertWMSUrlToLegendString(layer.baseUrl);
+                        var window = new Ext.Window({
+                            title: '<span id="window-baselayer-title">' + item.parentMenu.contextNode.text + ' legend</span>',
+                            layout: 'fit',
+                            bodyStyle: 'padding:10px 8px 0 0; background:#fff',
+                            items: [
+                                { html: '<img src="' + url + '" />' }
+                            ]
+                        });
+                        window.setPagePosition(Ext.getCmp('east').x - 481, Ext.getCmp('center').y + 25);
+                        window.show();
+                    }
+                },
+                {
+                    text: 'Opacity',
+                    iconCls: 'menu-layeroptions-opacity',
+                    menu: { 
+                        items: G.conf.opacityItems,
+                        listeners: {
+                            'itemclick': function(item) {
+                                item.parentMenu.parentMenu.contextNode.layer.setOpacity(item.text);
+                            }
+                        }
+                    }
+                }
+            ]
+        }),
+        contextMenuOverlayFile: new Ext.menu.Menu({
             items: [
                 {
                     text: 'Opacity',
@@ -2139,17 +2191,18 @@
             ]
         }),
         clickEventFn: function(node, e) {
-            if (node.attributes.text != 'Base layers' && node.attributes.text != 'Overlays') {
+            if (node.attributes.text !== 'Base layers' && node.attributes.text !== 'Overlays') {
                 node.select();
                 
-                if (node.parentNode.attributes.text == 'Base layers') {
+                if (node.parentNode.attributes.text === 'Base layers') {
                     var cmb = node.getOwnerTree().contextMenuBaselayer;
                     cmb.contextNode = node;
                     cmb.showAt(e.getXY());
                 }
                 
-                else if (node.parentNode.attributes.text == 'Overlays') {
-                    var cmo = node.getOwnerTree().contextMenuOverlay;
+                else if (node.parentNode.attributes.text === 'Overlays') {
+                    var cmo = node.layer.overlayType === 'wms' ?
+                        node.getOwnerTree().contextMenuOverlayWMS : node.getOwnerTree().contextMenuOverlayFile;
                     cmo.contextNode = node;
                     cmo.showAt(e.getXY());
                 }
@@ -2167,7 +2220,7 @@
             {
                 xtype: 'button',
                 id: 'baselayers_b',
-                text: 'WMS ' + G.i18n.overlay,
+                text: 'WMS overlays',
                 iconCls: 'icon-baselayer',
                 handler: function() {
                     Ext.getCmp('baselayers_w').setPagePosition(Ext.getCmp('east').x - (Ext.getCmp('overlays_w').width + 15), Ext.getCmp('center').y + 41);
@@ -2177,7 +2230,7 @@
             {
                 xtype: 'button',
                 id: 'overlays_b',
-                text: 'Vector ' + G.i18n.overlay,
+                text: 'File overlays',
                 iconCls: 'icon-overlay',
                 handler: function() {
                     Ext.getCmp('overlays_w').setPagePosition(Ext.getCmp('east').x - (Ext.getCmp('overlays_w').width + 15), Ext.getCmp('center').y + 41);