Hoppa till huvudinnehållet

How to get the Map Service ID programmatically?

Kommentarer

3 kommentarer

  • Permanently deleted user

    Hi Andrew, since you mentioned "SelectFeatures" activity rather than "ShowResults", I'm assuming this is for Essentials (xaml) Workflow?

     

    In Essentials Workflow, I don't believe there's a "clean" way to get the site or map information and determine a map service based on a layer name. I know at least one "messy" way to do it by downloading the site's "map" REST endpoint as json with DownloadString, and making careful use of GetJSONValue or other activities for parsing the REST endpoint's JSON. I believe GetJsonValue will get a map service id when using an expression like

    String.Format("$.mapServices[?(@..displayName =='{0}')].id","MyLayerName")

    but I'm not sure if that accounts for the possibility of group layers, and I know it won't handle scenarios where two layers share a name.

     

    Generally the map service ID is a pretty reliable value that won't change unless you remove a map service from a site and then re-add it later. It's pretty safe to either hard-code it, or provide it through an argument. It's layer IDs that tend to be less reliable and frequently change when you add/remove/reorder the layers in a map service.

    0
  • Berend Veldkamp

    We have been using Amanda's approach in many workflows, and we haven't found any downsides to it.

     

    However, if you don't like it, here's an alternative approach: Add a custom property with a unique name to the layer, and use GetLayerInfoByProperty to get the layer. The result will contain the Mapservice ID and the Layer ID.

    0
  • Andrew Kan

    Thanks Amanda and Berend! I will try both and see how if I can get the Mapservice ID. Worse comes to worse I can just hardcode it.

     

    Cheers

    0

Du måste logga in om du vill lämna en kommentar.