Custom Layer with Runtime SDK

2345
8
01-26-2016 11:13 AM
AndreaWeeg
New Contributor

how can I write my own custom layer? I was able to get this working before using the dynamic layer in the wpf sdk but it doesn't seem to be supported anymore with the new runtime engine.

Thank you!

Andrea

0 Kudos
8 Replies
AnttiKajanus1
Regular Contributor II

Hi,

Could you provide more details what you would like to achieve and I'll have a look on the options. Especially if the targeted functionality is tile or graphic based.

cheers,

Antti

0 Kudos
AndreaWeeg
New Contributor

I have data from other sources that i need to display, i am drawing it out as a bitmap image that i was able to return to the map using the dynamiclayer abstract class but now the same code doesn't work with this new runtime engine. I think its supported in the java runtime, ios runtime and javascript but not in .net.

0 Kudos
AaronHigh
New Contributor III

I'm also interested in this. Previously I could overlay a WPF object as a map layer to display some dynamic (local) raster information. This functionality as it exists in the .NET runtime isn't completely adequate because it requires that I use a MapOverlay which exists above the rest of the map layers. It would be great to be able to place such a layer inside the z-ordering stack of the other layers rather than forcing it to the top above more important situational layers.

dotMorten_esri
Esri Frequent Contributor

You can inherit from DynamnicMapServiceLayer to create a custom layer.

   
    public class CustomLayer : Esri.ArcGISRuntime.Layers.DynamicMapServiceLayer
    {
        public CustomLayer() : base() { } 
        protected override Task<DynamicLayerInitializationInfo> OnInitializeDynamicLayerRequestedAsync()
        {
            DynamicLayerInitializationInfo info = new DynamicLayerInitializationInfo(SpatialReferences.Wgs84)
            {
                SupportsRotation = false,
                SupportsWrapAround = false,
                Extent = new Envelope(-180, -90, 180, 90, SpatialReferences.Wgs84),
            };
            return Task.FromResult(info);
        }
        protected override Task<Uri> GetImageUriAsync(ImageParameters properties, System.Threading.CancellationToken token)
        {
            string url = string.Format(CultureInfo.InvariantCulture, 
                "http://www.domain.com/MyMapService?bbox={0},{1},{2},{3}&width={4}&height={5}",
                properties.Extent.XMin, properties.Extent.YMin, properties.Extent.XMax, properties.Extent.XMax,
                properties.Width, properties.Height);
            return Task.FromResult(new Uri(url));
        }
    }
0 Kudos
AndreaWeeg
New Contributor

yeah but that returns a url, I need to return the image itself. There is a GetImageAsync method that can be overwritten in the dynamiclayer that I was using to do that, but that doesn't work anymore since in this version the constructor is internal so I can't inherit the abstract class anymore.

0 Kudos
dotMorten_esri
Esri Frequent Contributor

Correct - returning the raw image data isn't supported in the current runtime. You could spin up a simple local http service using 'HttpListener' to route the requests through on localhost. That also gives you some nice thread isolation. There's quite a few samples online showing how to make a simple little localhost server that starts up with your app.

0 Kudos
AndreaWeeg
New Contributor

that's the path I started going down this morning . Do you think they'll be support for this in a future release?

0 Kudos
dotMorten_esri
Esri Frequent Contributor

There are no plans for extending this in the 10.2.x releases.

This might be added to a future Quartz release, but custom dynamic layers aren't currently supported in Quartz at all. I'll take it as feedback for future enhancements

0 Kudos