ThinkGeo.com    |     Documentation    |     Premium Support

GoogleLayer in Background - WmsRasterLayer in Foreground

In 3.0.2 Beta I could playe the google layer in background and an WmsImageLayer in foreground.


In new 3.0.313 Beta I can not place the layers on top of each other. My WmsLayer has the projections:



 EPSG:4326

 EPSG:25832

 EPSG:25833

 EPSG:325833

 EPSG:3034

 EPSG:3035

 EPSG:3044

 EPSG:3045

 EPSG:31468

 EPSG:31469



I tryed WmsOverlay and WmsRasterLayer. But I can not see my Wms layer - just the google layer. Here is some code for testing with WmsOverlay:



this.map.MapBackground.BackgroundBrush = new GeoSolidBrush(GeoColor.StandardColors.Transparent);

this.map.MapUnit = GeographyUnit.Meter;

this.map.MapTools.Logo.Enabled = false;

this.map.MapTools.MouseCoordinate.Enabled = true;

this.map.StaticOverlay.TileType = TileType.SingleTile;

this.map.DynamicOverlay.TileType = TileType.SingleTile;

this.map.MapTools.OverlaySwitcher.Enabled = true;

this.map.CurrentExtent = ExtentHelper.GetDrawingExtent(

                new RectangleShape

                (

                1057888.47132, 

                7198533.57776,

                1907868.22573,

                6589483.33345

                ),

                (float)this.map.Width.Value,

                (float)this.map.Height.Value

                );


GoogleOverlay google = new GoogleOverlay("Google Map");

google.JavaScriptLibraryUri = new Uri(GlobalSettings.WmsLayerUrls.WmsUrlGoogleMaps);

google.GoogleMapType = GoogleMapType.Physical;

           

this.map.CustomOverlays.Add(google);


WmsOverlay wms = new WmsOverlay("LGB Overlay as WmsOverlay");

wms.Parameters.Add("layers", "bg");

wms.ServerUris.Add(new Uri("myUri"));

wms.TileType = TileType.SingleTile;


// Add wms layer

this.map.CustomOverlays.Add(wms);



Sorry, but the url of the wms layer i can not post public. I hope you can help me even so, because you habe the projections of the wms layer.


Anke



Anke, 
  
 It will be fine by just setting wms.IsBaseOverlay to false. The code will be like this. 
  
 
// ……
WmsOverlay wms = new WmsOverlay("LGB Overlay as WmsOverlay");
wms.Parameters.Add("layers", "bg");
wms.ServerUris.Add(new Uri("myUri"));
wms.TileType = TileType.SingleTile;
wms.IsBaseOverlay = false;

// Add wms layer
this.map.CustomOverlays.Add(wms);
// ……
 
  
 By default, GoogleOverlay, VirtualEarthOverlay, YahooMapOverlay and WMSOverlay are BackgroundOverlays and all the other Overlays (like LayerOverlay, inMemoryMarkerOvelay) are not. If you want to make a WMSOverlay not as background, just set that property to false. 
  
 Hope that helps, let us know for more queries. 
  
 Ben. 
  


Anke,


Just let you know if you are interested, you can have a look at here to see how to make your code looks nicer in post. :)


Ben



Hello Ben,


 if I set the Property "IsBaseOverlay" of the WmsOverlay to false, I get an error which you can see in the image atttachment which says "msWmsLoadGetMapParams(): Invalid SRS given : SRS must be valid for all requestes layers. If I set the property to true and switch to WmsOverly with the OverlaySwitcher, I get now errors.


I think this problem comes because the different projections. Is it possible to change the projection of the google layer?


Anke


P.S.: thanks for the tip with the "code" tag - I know this from other forums, but I have searched for button "Code" or "C#" like I know it from different forums.



Anke, 
  
 Please try this code. 
  
 
WmsOverlay wms = new WmsOverlay(“LGB Overlay as WmsOverlay”);
wms.Parameters.Add(“layers”, “bg”);
wms.Parameters.Add(“SRS”, “EPSG:900913”);
wms.ServerUris.Add(new Uri(“myUri”));
wms.TileType = TileType.SingleTile;
wms.IsBaseOverlay = false;

// Add wms layer
this.map.CustomOverlays.Add(wms);
 
  
 “900913” is google’s projection, looks the same like “google” right?:)  
  
 Ben 


I can not set the projection of my wms layer to "EPSG:900913" because the layer supports only the following projection:


EPSG:4326

EPSG:25832

EPSG:25833

EPSG:325833

EPSG:3034

EPSG:3035

EPSG:3044

EPSG:3045

EPSG:31468

EPSG:31469


Normaly I use the projetion "EPSG:4326" ant I set the bounding box to minx="11.2" miny="51.3" maxx="14.8" maxy="53.5". The MapUnit for the map is DecimalDegree. In the version 3.0.2, I could add google layer to my map and the wms layer too, with just called properties. And I could see bouth layers without problems. In the new version 3.0.313 I should set the projection of google layer to "EPSG:4326" but this is no possible, or?


Here is the code for version 3.0.2 which is fully functional:




this.map.BackgroundFillBrush = new GeoSolidBrush(GeoColor.StandardColors.Transparent);
this.map.MapUnit = GeographyUnit.DecimalDegree;
this.map.CurrentExtent = ExtentHelper.GetDrawingExtent(new RectangleShape(11.05, 53.40, 14.90, 51.20), (float)this.map.Width.Value, (float)this.map.Height.Value);
this.map.ShowLogo = false;
this.map.IsSingleTile = true;
this.map.BackgroundMap.GoogleMap.LibraryUri = new Uri("maps.google.com/maps?file=api&v=2&key=ABQIAAAAoxK_HcqphMsnUQHEwLwHlRSavkNJi0NVTgm4UDidoiIU5dUJpRQW88FufPCp0aTPraxZgZFAIUHn3Q");
this.map.BackgroundMap.GoogleMap.Name = LayerName.WmsGoogleMaps.ToString();
this.map.BackgroundMap.GoogleMap.GoogleMapType = GoogleMapType.Physical;

// create wms layer
WmsImageLayer wmsLayer = new WmsImageLayer("wmsUri");
wmsLayer.Name = "WMS Layer";

if (!wmsLayer.IsOpen)
{
    wmsLayer.Open();
}

// Set Active Layer names
foreach (string name in wmsLayer.GetServerLayerNames())
{
    wmsLayer.ActiveLayerNames.Add(name);
}

wmsLayer.UpperThreshold = Double.MaxValue;
wmsLayer.LowerThreshold = 0;
wmsLayer.IsTransparent = true;
wmsLayer.Crs = "EPSG:4326";
wmsLayer.TimeoutInSecond = 35;

if (wmsLayer.IsOpen)
{
    wmsLayer.Close();
}

this.map.DynamicLayers.Add(wmsLayerDnm.Name, wmsLayerDnm);


Anke



Anke, I see what you want.  
  
 In 3.0.2 in fact, although you can do it, the 2 layers can never be identically matched. In fact allowing layers with different projections be added to one map itself is a bug.  
  
 So in the current version, we improved this and we can not do that complex adding any more. Now if the WMS server doesn’t support the 900913 projection, I’m afraid we cannot add the wms layer to GoogleMap. 
  
 Seems sometime, the right thing hurts. Sorry for the inconvenience.  
  
 Ben