Select to view content in your preferred language

ESRI map as overlay

814
3
08-28-2012 12:32 AM
konradenzensberger
Emerging Contributor
Hello,

our GIS application works with online maps like Openstreetmap, Google, ...
as basemap.
For this we do not use any ArcObjects stuff (own framework).
Now we like to display ESRI maps as overlay.

What would be the best way to load an ESRI mxd file an display the content
over our  basemap ?

I tried to develope a windowless ArcObjects class, loading an mxd file
and use IMapServer interface to export the map as png image.
Then i use the png image as overlay.
This works but i think, it is not the best way, also performance is not good enough.

Is there a way to load an mxd file and request an image depending on scale and envelope values?

We do not have ArcServer, i am searching a pure ArcObjects solution !

any suggestions welcome,

thanks, enze
0 Kudos
3 Replies
ThomasEmge
Esri Contributor
Enze,

there can be any number of reasons why performance is "not good". Without knowing any further details about your rendering solution it will be hard to pinpoint the bottleneck.

Here is some code in C# to export the map to png:

    IMapDocument mapDocument = new MapDocumentClass();
    mapDocument.Open("path to my document");

    // at this point you might want to navigate to a desired location and scale
    ESRI.ArcGIS.Carto.IActiveView activeView = mapDocument.ActiveView;
    ESRI.ArcGIS.Geometry.IEnvelope zoomExtent = new ESRI.ArcGIS.Geometry.EnvelopeClass();
    //possiblities are for example
    //zoomExtent.CenterAt();
    //zoomExtent.Expand();
    //zoomExtent.PutCoords();
    activeView.Extent = zoomExtent;

    ESRI.ArcGIS.Output.IExport export = new ESRI.ArcGIS.Output.ExportPNGClass();
    System.String pathFileName = "name of export png file";
    export.ExportFileName = pathFileName;

    // Because we are exporting to a resolution that differs from screen 
    // resolution, we should assign the two values to variables for use 
    // in our sizing calculations
    System.Int32 screenResolution = 96;
    System.Int32 outputResolution = 300;

    export.Resolution = outputResolution;

    ESRI.ArcGIS.Display.tagRECT exportRECT; // This is a structure
    exportRECT.left = 0;
    exportRECT.top = 0;
    exportRECT.right = activeView.ExportFrame.right * (outputResolution / screenResolution);
    exportRECT.bottom = activeView.ExportFrame.bottom * (outputResolution / screenResolution);

    // Set up the PixelBounds envelope to match the exportRECT
    ESRI.ArcGIS.Geometry.IEnvelope envelope = new ESRI.ArcGIS.Geometry.EnvelopeClass();
    envelope.PutCoords(exportRECT.left, exportRECT.top, exportRECT.right, exportRECT.bottom);
    export.PixelBounds = envelope;

    System.Int32 hDC = export.StartExporting();

    activeView.Output(hDC, (System.Int16)export.Resolution, ref exportRECT, null, null); // Explicit Cast and 'ref' keyword needed 
    export.FinishExporting();
    export.Cleanup();

    mapDocument.Close();


- Thomas
0 Kudos
konradenzensberger
Emerging Contributor
Hi Thomas,

thanks for reply and you code snip - i do nearly the same.
Performance is not good means, this solution would not be the
way with good performant .

<Export the map as raster file, import the raster file and display as overlay>

I am looking for an solution like:

<Load an Mxd file, send a request to MapDocument or MapServer or MapControl or what ever,
and depending on scale and coordinates receiving an image. >

Is there a way to do this with MapObjects ?

any suggestion welcome,
enze
0 Kudos
ThomasEmge
Esri Contributor
Enze,

there are ways to "increase" performance. For example you can lower the resolution of the output from 300 to something else. 300 dpi doesn't make a lot of sense if you are only using the export for display. The lower the resolution the faster the export. The Output method on the IActiveView currently has two null arguments -- essentially forcing a complete rendering cycle. If you can narrow it down then again you will save some time. Depending on the platform you are coding you might not want to do an export but maybe use the map document's offscreen bitmap directly. Then we might get down to a couple of milliseconds. I am saying we might get down that timing but it depends on a number of things and the order in which they happen.

However, it sounds like you are trying to create your own miniature server architecture and the Esri solution here would be to just use the server that we have. Since you do not have a server at hand you might want to consider using our hosted solution of ArcGIS Online where you (or your users) can essentially "rent" a server without having to maintain it. It is just an idea.

The MapObjects solution would have been MOIMS but it got replaced by ArcIMS and then replaced by ArcGIS Server.

Good luck,
- Thomas
0 Kudos