Select to view content in your preferred language

Exporting MapView to BMPFormat with full Envelope

341
2
Jump to solution
10-03-2024 10:27 AM
DarinMalcom
New Contributor

I am creating an Envelope with specific latitude and longitude bounds, zooming the MapView  to that envelope, then exporting a BMPFormat image of the MapView.  I am setting the BMPFormat to a specific height and width.  What I am expecting, is an image with the full bounds of the Envelope, and only the envelope in the resulting bmp file.  It seems like the resulting image is not the full bounds of the envelope, but just a portion of it.  Is it possible to achieve what I want, and if so, what am I missing?

BMPFormat BMP = new BMPFormat()
{
    Height = info.getResolutionHeight(),
    Width = info.getResolutionWidth(),
    HasWorldFile = true,
    OutputFileName = MapImagePath
};
MapView mapView = MapView.Active;
  Envelope envelope = EnvelopeBuilderEx.CreateEnvelope(info.getLongitude(), info.getLatitude(),
      info.getLongitude() + info.getLongitudeSpan(), info.getLatitude() + info.getLatitudeSpan(), ArcGIS.Core.Geometry.SpatialReferenceBuilder.CreateSpatialReference(4326));// wm:3857 , pc": 4326
  mapView.ZoomTo(envelope);
 
  // Write the bmp file to disk
  if (mapView != null)
  {
      //Export on the worker thread
      await QueuedTask.Run(() =>
      {
          //Check to see if the path is valid and export
          if (BMP.ValidateOutputFilePath())
          {
              mapView.Export(BMPmapView.Camera);  //Export to BMP
          }
      });
  }

 

0 Kudos
1 Solution

Accepted Solutions
GKmieliauskas
Esri Regular Contributor

Hi,

You can call another overload of Export method with envelope parameter:

mapView.Export(BMP, envelope);  //Export to BMP

View solution in original post

0 Kudos
2 Replies
GKmieliauskas
Esri Regular Contributor

Hi,

You can call another overload of Export method with envelope parameter:

mapView.Export(BMP, envelope);  //Export to BMP
0 Kudos
DarinMalcom
New Contributor

I am still seeing an issue with this.  It seems like the exported image contains portions of the map outside the bounds of the envelope.  I am looking at the exported world file (.bpw) and although I have not found any documentation  on the world file itself it looks like the last 2 lines are a longitude and latitude that is outside of the bounds of the Lat/Lon used to create the envelope, and the resulting image seems to reflect this as well.  Is it possible to only export the bounds of the envelope?

0 Kudos