Interface class for Flex Layers

Idea created by odoe on Apr 16, 2011
    New
    Score60
    • kevincovert
    • BrianO
    • TomLUX
    • ruprict
    • odoe
    • rscheitlin
     It would be very useful to have an IServiceLayer of some sort for all Service Layers in the Flex API such as ArcGISDynamicMapServiceLayer, ArcGISTileMapServiceLayer, etc. Even FeatureLayer, basically so that developers can easily check if a Layer has a url.

    It's small, I know, but as of right now there are a couple of ways to get the URL of a Layer class.
    One can do
    if (layer is ArcGISDynamicMapServiceLayer)
        url = ArcGISDynamicMapServiceLayer(layer).url;
    else if (layer is ArcGISTileMapServiceLayer)
        url = ArcGISTileMapServiceLayer(layer).url;
    ...

    Or we can wrap a try/catch
    try
    {
        if (layer["url"])
            url = layer["url"];
    }
    catch(e:Error)
    {
        trace("nope");
    }

    All of which just give off a bad smell.

    It would be great if we could just do
    if (layer is IServiceLayer)
        // do my thing

    I know it's not exactly a critical request, but I'm sure would be an incredibly useful tool for developers, and would be a great addition to the Flex API 3.0 release.

    Thanks.