Select to view content in your preferred language

Inheriting from ArcGISDynamicMapServiceLayer

661
3
Jump to solution
05-21-2012 06:55 PM
LanceCrumbliss
Frequent Contributor
Hello,

This is a relatively long post, so I hope it isn't for nothing. 

I've written a class based on ArcGISDynamicMapServiceLayer that uses SOAP methods on the client.  I chose that class mostly for the Interfaces it implements (Specifically ILegendSupport and ISublayerVisibilitySupport).  The short version of why is twofold: label toggling and max image size exported by the server.

My class works fine for the most part.  Using the SOAP method to export a map image as a url (esriImageReturnUrl) that points to an image on the ArcGIS Server, it successfully generates the link.  It is then handled by the  OnUrlComplete event handler passed into the Overrided Method GetUrl where it is downloaded and displayed on the map.  The occasional issue I'm having is depending on the configuration of the ArcGIS Server hosting the generated image, the url points to a virtual directory on the remote server that may not actually exist, or it exists but points to an internal server name for example:

http://<internalservername>/argcisoutput/imagegenerated.png.

If I return bytes that make up the image (esriReturnMimeData) instead of a remote URL pointing to that remote image then I don't have to worry about the path above; it get the bytes directly.  However, having inherited from ArcGISDynamicMapServiceLayer, I'm having trouble figuring out how to handle the bytes once they're received.

As it is now, here is some code for generating a url, edited for brevity...

Public Overrides Sub GetUrl(extent As ESRI.ArcGIS.Client.Geometry.Envelope, width As Integer, height As Integer, onComplete As ESRI.ArcGIS.Client.DynamicMapServiceLayer.OnUrlComplete)      'Omitted Code preparing the MapDescription (mapsesc)       Dim imgdisp As New SoapExporter.ImageDisplay With {.ImageHeight = CInt(Me.Map.ActualHeight), .ImageWidth = CInt(Me.Map.ActualWidth), .ImageDPI = Me.DPI}      Dim imgtype As New SoapExporter.ImageType With {.ImageFormat = Me.SoapImageFormat, .ImageReturnType = SoapExporter.esriImageReturnType.esriImageReturnURL}      Dim imgdesc As New SoapExporter.ImageDescription With {.ImageDisplay = imgdisp, .ImageType = imgtype}      Dim package As New List(Of Object) From {onComplete, width, height, extent}      ' ms is the MapServerPortClient      ms.ExportMapImageAsync(mapdesc, imgdesc, package) End Sub  Private Sub ExportMapImage_Completed(sender As Object, e As SoapExporter.ExportMapImageCompletedEventArgs)      Dim imageUrl As String = e.Result.ImageURL      Dim package As List(Of Object) = CType(e.UserState, List(Of Object))      Dim onComplete As ESRI.ArcGIS.Client.DynamicMapServiceLayer.OnUrlComplete = TryCast(package(0), ESRI.ArcGIS.Client.DynamicMapServiceLayer.OnUrlComplete)      onComplete(imageUrl, CInt(package(1)), CInt(package(2)), CType(package(3), ESRI.ArcGIS.Client.Geometry.Envelope)) End Sub            


If i use esriReturnMimeData instead of esriImageReturnURL, the ExportMapImage_Completed handler can still handle the result, as the bytes are also property of ExportMapImageCompletedEventArgs.  The question I have is what do I do from there to get them on the map?

Lance
0 Kudos
1 Solution

Accepted Solutions
DominiqueBroux
Esri Frequent Contributor
Unfortunately, AFAIK, you can't use an image stream by subclassing ArcGISDynamicMapServiceLayer.
You have to subclass DynamicMapServiceLayer and override GetSource .

But as you noticed you'll have to implement a few other interfaces by yourself:(

View solution in original post

0 Kudos
3 Replies
DominiqueBroux
Esri Frequent Contributor
Unfortunately, AFAIK, you can't use an image stream by subclassing ArcGISDynamicMapServiceLayer.
You have to subclass DynamicMapServiceLayer and override GetSource .

But as you noticed you'll have to implement a few other interfaces by yourself:(
0 Kudos
LanceCrumbliss
Frequent Contributor
grrr, that's what I was afraid of.  I had originally subclassed DynamicMapServicLayer but implementing the ILegendSupport and ISublayerVisibilitySupport was difficult.  Thanks for the bad news!

Quick unrelated question....what determines whether or not GetUrl or GetSource is called by the base class?

Lance
0 Kudos
dotMorten_esri
Esri Notable Contributor
Actually you should inherit from DynamicLayer, not DynamicMapServiceLayer (the latter is if you return a url instead of the image itself - it basically just adds the logic to download the image from the url).

The implemented interfaces you are missing out on won't help you anyway - these are specific to ArcGIS Server REST. Since you use it for a different service, you would need to implement all these yourself - there's no way for these to magically work on a custom service endpoint.

To answer your unrelated question: DynamicLayer has GetSource, and therefore the subclass 'DynamicMapServiceLayer' also has this. DynamicMapServiceLayer defines the helper method 'GetUrl' (which internally is called by GetSource). This is why you should be inheriting from DynamicLayer and return a BitmapImage instead of a Uri.
0 Kudos