RenderMapAsImage

Apr 25, 2012 at 11:59 AM

 

Hi,

I'm trying to get a static image using the RenderMapAsImage method.

Unfortunately I can't get it to work, only blank image is returned (see my stripped down example code below).

I'm using VS2010 with a .Net 3.5 WinForms App.

Could you point out, what's missing?

All the best,
Wilhelm

 

public Image GetThumbTest() {

	Map map = new Map();
	map.Layers.Add( new TileLayer( new OsmTileSource() ) { LayerName = "OSM" } );

	View view = new View();
	view.Center = new SharpMap.Geometries.Point( 0, 0 );
	view.Width = 256;
	view.Height = 256;
	view.Resolution = 156543.033900000;

	return GdiMapRenderer.RenderMapAsImage( view, map );
}

Coordinator
Apr 25, 2012 at 12:54 PM
Edited Apr 25, 2012 at 4:32 PM

Data it fetched asynchronously which complicates this. You should call a map.ViewChanged(true, view.Extent, view.Resolution)  to start fetching data and then you need to wait a while before rendering. 

We want to add an event to indicate whether fetching has started or stopped.

Apr 25, 2012 at 2:30 PM

Thanks a lot for your fast response. Now it works.

I had already tried 'map.ViewChanged', but hadn't thought about the asynchronous fetching.

All the best,

Wilhelm