ThinkGeo.com    |     Documentation    |     Premium Support

How to print a WmsOverlay

Hi,

i’m in the process of printing my map. Most layers work, but how do i print a WmsOverlay, as there seems to be no layer which i can use to print.

Any help is appreciated.

Regards,
Andreas

Hi Andreas,

I think this topic should be helpful for your question: Printing WmsOverlay

And our developer build a sample for you, it works based on WmsRasterLayer, please view it:

PrintWmsDemo.zip (10.3 KB)

Regards,

Don

Hi Don,

thanks for your effort in helping me. I’m using Version 10 of WPF Desktop Edition and it tells me that there is no WmsRasterLayer. Is there any additional package i have to include?

Update: I just found out myself. The nuget-package was already installed, only the Project reference was missing.

Regards,
Andreas

Hi Don,

i’m sory to bother you again, but i don’t get this working.

I currently use a WmsOverlay with the following code

  var wmsOverlay = new WmsOverlay( );
  wmsOverlay.ServerUris.Add( new Uri( "url" ) );
  wmsOverlay.SendingWebRequest += wmsOverlay_SendingWebRequest;
  wmsOverlay.Parameters.Add( "LAYERS", "FEATURE" );
  wmsOverlay.Parameters.Add( "STYLES", "default" );
  wmsOverlay.Parameters.Add( "FORMAT", "image/png" );
  wmsOverlay.Parameters.Add( "CRS", "EPSG:31466" );
  wmsOverlay.Parameters.Add( "SRS", "EPSG:31466" );
  wmsOverlay.Parameters.Add( "TRANSPARENT", "true" );
  wpfMap1.Overlays.Add( wmsOverlay );

This renders my Feature perfectly. I now replace this code with

  var wmsRasterLayer = new WmsRasterLayer( new Uri( "url" ) );

  wmsRasterLayer.SendingWebRequest += wmsRasterLayer_SendingWebRequest;

  wmsRasterLayer.Parameters.Add( "LAYERS", "FEATURE" );
  wmsRasterLayer.Parameters.Add( "STYLES", "default" );
  wmsRasterLayer.Parameters.Add( "FORMAT", "image/png" );
  wmsRasterLayer.Crs = "EPSG:31466";
  wmsRasterLayer.Parameters.Add( "CRS", "EPSG:31466" );
  wmsRasterLayer.Parameters.Add( "SRS", "EPSG:31466" );
  wmsRasterLayer.Parameters.Add( "TRANSPARENT", "true" );
  wmsRasterLayer.UpperThreshold = double.MaxValue;
  wmsRasterLayer.LowerThreshold = 0;


  wmsRasterLayer.Open( );
  foreach( string layerName in wmsRasterLayer.GetServerLayerNames( ).Where( x => x == "FEATURE" ) )
  {
    wmsRasterLayer.ActiveLayerNames.Add( layerName );
    wmsRasterLayer.ActiveStyleNames.Add( "default" );
  }

  var rasterOverlay = new LayerOverlay( );
  rasterOverlay.Layers.Add( wmsRasterLayer );
  wpfMap1.Overlays.Add( rasterOverlay );

This doesn’t render anything. I hooked into the Event SendingWebRequest, this gets fired several times with the Overlay (as expected), but it doesn’t get fired at all using the WmsRasterLayer.

Any idea?

Regards,
Andreas

Hi Andreas,

We reviewed your code for WmsRasterLayer, that is inaccurate. Please try the below code with your Wms server url:

        var wmsRasterLayer = new WmsRasterLayer(new Uri("url"));
        wmsRasterLayer.ActiveLayerNames.Add("FEATURE");
        wmsRasterLayer.ActiveStyleNames.Add("default");
        wmsRasterLayer.IsTransparent = true;
        wmsRasterLayer.OutputFormat = "image/png";
        wmsRasterLayer.Crs = "EPSG:31466";
        wmsRasterLayer.UpperThreshold = double.MaxValue;
        wmsRasterLayer.LowerThreshold = 0;
        wmsRasterLayer.SendingWebRequest += WmsRasterLayer_SendingWebRequest;

We don’t have your wms server url, so we can’t test the above code. If it still doesn’t work, could you give us your wms server url?

Thanks,

Hi Don,

sorry for the late reply.

I tested your code, but still no success. the callback WmsRasterLayer_SendingWebRequest is called once with the URL to rerieve the getCapabilities, and that request returns the correct result when tested in a browser.

But nothing more. There are no more calls to the callback when i show the map or zoom into the map. Any ideas what could go wrong?

The WMS-Url points to an internal WMS, so i can’t share it with you.

Regards,
Andreas

Hi Andreas,

If you only capture the getCapabilities request but not getTile request, that maybe because your current extent is not in the valid extent of the setting in capability, or the MapUnit is incorrect. So please open the Capability and check whether the MapUnit and MapExtent is valid.

And our developer will create a sample to print WMS layer, the link is: http://community.thinkgeo.com/uploads/default/original/3X/1/f/1fd035c58eb1165a20ddf06c0ffcbb66fa53db78.zip

Please double check the sample I mentioned before, which should be helpful.

Wish that’s helpful.

Regards,

Don