+ Reply to Thread
Results 1 to 4 of 4

Thread: Abstraction for index numbers to select specific feature layers in a mapservice

  1. #1
    Brian Pangtay
    Join Date
    Apr 2010
    Posts
    27
    Points
    0
    Answers Provided
    0


    0

    Default Abstraction for index numbers to select specific feature layers in a mapservice

    If an MXD is modified, the index number for a layer in a mapservice may change since it just a relative number derived from the order in which the layers were added to an MXD. When that happens, the developer needs to track down all relevant code that specifies that index number and correct the index number to new modified index number.

    Is there a different method that does not use index numbers to specify the layer desired from a mapservice?

  2. #2
    Rene Rubalcava
    Join Date
    Apr 2010
    Posts
    464
    Points
    239
    Answers Provided
    39


    0

    Default Re: Abstraction for index numbers to select specific feature layers in a mapservice

    This is currently listed as "under consideration" on the ideas site.
    http://ideas.arcgis.com/ideaView?id=08730000000brPPAAY

    If you need to make a lot of updates when map services change, you can try creating a dictionary of layers to indexes.

    You'd basically do a request for the map service data
    http://gisserver:6080/arcgis/rest/se...pServer?f=json

    Iterate over the results like so,

    Code:
    var indexLayers = {},
        layers = result.layers;
    for (var i = 0, len = layers.length;, i < len, i++) {
      var layer = layers[i];
      indexLayers[layer.name] = layer.id;  
    }
    // now you can use indexLayers in your app to do the correct referencing
    // when needed
    
    layer.setVisibleLayers([indexLayers.Parcels, indexLayers['Building Footprints']]);

  3. #3
    Brian Pangtay
    Join Date
    Apr 2010
    Posts
    27
    Points
    0
    Answers Provided
    0


    0

    Default Re: Abstraction for index numbers to select specific feature layers in a mapservice

    That is what I was looking for. Is there an example online with source code that implements that method?

    Thanks for the info.
    Last edited by bpangtay; 08-28-2013 at 03:31 AM.

  4. #4
    Tim Collyer
    Join Date
    Jun 2012
    Posts
    53
    Points
    15
    Answers Provided
    4


    0

    Default Re: Abstraction for index numbers to select specific feature layers in a mapservice

    I've have worked around this by having my server-side code supply the layer id to my client-side code.

    In my situation I'm using java/spring on the server, so I have a "layer" object (a bean) which contains some properties such as the map service layer id and this object is configured via xml.

    It's not perfect in that if the map service layer id does change I need to change the property in the xml configuration, but other than that it doesn't require any code changes.

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts