ThinkGeo.com    |     Documentation    |     Premium Support

Exporting map as image

Hello,
we are trying to export the shapefile into an image .In which we are drawing an rectangle shape on the trackshapelayer.we want to display the shapefile which lies inside the rectangle shape into an image .we are using the following code for it :

            WpfGeoCanvas canvas = new WpfGeoCanvas();
            Collection<SimpleCandidate> labelsInAllLayers = new Collection<SimpleCandidate>();
            System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(600,400);
            canvas.BeginDrawing(bitmap, orderMap.CurrentExtent, GeographyUnit.DecimalDegree);
              orderMap.TrackOverlay.TrackShapeLayer.Draw(canvas, labelsInAllLayers);

        
            canvas.EndDrawing();
            bitmap.Save("\Images_Test\Test.jpg");

but this code is not working. can you please provide us with any sample code for it.
Thanks And Regards,
Hrishikesh Konde.

Hi,

What’s the value of your orderMap.CurrentExtent, does it the rectangle shape in track shape layer?

And you don’t want to call orderMap.TrackOverlay.TrackShapeLayer.Draw(canvas, labelsInAllLayers), it means only the rectangle shape will be drawn on image.

You need to call the layer which contains your map to draw on the canvas.

Please modify your logic see whether it works.

Regards,

Ethan

Hello Ethan,
We are done with this querry for now the shape file is being displayed.but we face issue for displaying the shapefile on date line. (we have wrapped the shape file overlay) but when we are taking the image it comes up unwrapped as we are taking shapefile layer for drawing. here is the image for the same.
can we get this image wrapped?
Thanks And Regards,
Hrishikesh Konde.

Hi,

Here is a sample about how to implement it:

9323.zip (101.5 KB)

Regards,

Ethan