download image

3741
1
04-20-2016 08:10 AM
AndreaLópez
New Contributor


Hi,

I am new in all about Arcgis. Can you tell me how I can donwload the map?

I have a map with marker I need to take a photo and save in my CRM because I am using this image in my reports!

I am working with google and i used static map for this

0 Kudos
1 Reply
UmaHarano
Esri Regular Contributor

Hi Andre

There are a couple ways by which you can accomplish what you need:

1. Make a new Layout in your project. Add a Map frame to your layout. Define the map you want within that map frame.  You can then use the following code snippet (also available in the API Reference guide here​) to export the map as a PNG file:

//This example demonstrates how to export an individual map frame on a layout to PNG.

//Added references
using ArcGIS.Desktop.Core;  //Project
using ArcGIS.Desktop.Layouts;  //Layout classes
using ArcGIS.Desktop.Framework.Threading.Tasks;  //QueuedTask
using ArcGIS.Desktop.Mapping;  //Export formats

public class ExportMapFrameToPNGExample

{

   public static Task ExportMapFrameToPNGAsync(string LayoutName, string MFName, string Path)

  {

   //Reference a layoutitem in a project by name
  LayoutProjectItem layoutItem = Project.Current.GetItems<LayoutProjectItem>().FirstOrDefault(item => item.Name.Equals(LayoutName));

   if (layoutItem == null)

   return Task.FromResult<Layout>(null);

   //Create PNG format with appropriate settings
  PNGFormat PNG = new PNGFormat();

  PNG.Resolution = 300;

  PNG.OutputFileName = Path;

   return QueuedTask.Run(() =>

  {

        //Export MapFrame
       Layout lyt = layoutItem.GetLayout(); //Loads and returns the layout associated with a LayoutItem
       MapFrame mf = lyt.FindElement(MFName) as MapFrame;

       PNG.OutputFileName = Path;

        if (PNG.ValidateOutputFilePath())

       {

            mf.Export(PNG);

       }

  });

  }

}

2. If you want your add-in to display Pro's "Export Map" dialog, you can use the following code snippet to execute an ICommand using IPlugInWrapper. This snippet can be added to a button's click handler, for example:

internal class Button1 : Button

   {

       protected override void OnClick()

       {

           IPlugInWrapper wrapper = FrameworkApplication.GetPlugInWrapper("esri_sharing_ExportMap"); // Export Map button's ID.

           var command = wrapper as ICommand; // tool and command(Button) supports this

           if ((command != null) && command.CanExecute(null))

               command.Execute(null);

       }

   }

Thanks

Uma Harano

ArcGIS Desktop SDK team

0 Kudos