Hoppa till huvudinnehållet

How can I add a mapservice to a map from a workflow

Kommentarer

14 kommentarer

  • Berend Veldkamp

    Just a minor clarification: What you see as your outer 'grouplayer' is not a layer. It's just that the command expects an object with a 'layers' attribute (and optionally a map), see here. Any other attribute will be ignored, so you can leave out the first four lines (i.e. id...visibility)

    1
  • Ken Lyon

    Hi @Berend Veldkamp? , I see what you mean. The docs don't give much insight into what to put in the string. Based on the error message, I think the string must be a JSON representation of the layer, not a url.

    0
  • Berend Veldkamp

    Yes, it would be nice if there were at least some examples in the docs.

     

    One option to get this working is to look at the types of layer given listed here. In my case it's a mapServiceLayer, for which the layer type is ArcGISMapServiceLayer. The latter page also shows the properties that can be used in the add-layers command.

     

    An example:

    ={ "layers": [ { "layerType": "ArcGISMapServiceLayer", "url": "https://example.com/arcgis/rest/services/MyService/MapServer", "opacity": 0.5, "layers": [ { "id": 0, "defaultVisibility": false } ] } ] }

    This adds a mapservice from the specified URL, half transparent, and with the first layer turned off initially.

     

    I'd still like to know if it's possible to add only certain layers from a mapservice (i.e. have the other layers turned off, and not display in the TOC). This is possible in GVH, but I haven't figured out how to do that in Web.

     

    0
  • Scott Anderson

    Hi @Berend Veldkamp?, as you have discovered the map.add-layers command expects an esri layer object or layer json in webmap spec. Currently adding only a subset of sublayers does not look to be supported in the webmap spec or Web.

    A possible workaround would be to add only the layers you are interested in as a grouplayer.

     

    https://developers.arcgis.com/web-map-specification/objects/groupLayer/

    { "id": "groupLayer", "layerType": "GroupLayer", "opacity": 1, "title": "US Census", "visibility": true, "layers": [ { "id": "Census_6999", "title": "Census - states", "url": "https://sampleserver6.arcgisonline.com/arcgis/rest/services/Census/MapServer/3", "layerType": "ArcGISFeatureLayer" }, { "id": "Census_616", "title": "Census - Detailed Counties", "url": "https://sampleserver6.arcgisonline.com/arcgis/rest/services/Census/MapServer/2", "layerType": "ArcGISFeatureLayer" } ] }

     

    0
  • Berend Veldkamp

    @Scott Anderson? 

     

    Thanks, this works (almost) perfect 😉 . Do you know if it's also possible to add a Raster Layer this way? I tried to use ArcGISImageServiceLayer instead of ArcGISFeaturelayer, but it seems to be for ImageServers only, and gives an error 'fields is null'.

     

    Adding a single RasterLayer to a webmap in ArcGIS Online doesn't seem to be possible either, so I suspect it won't work in Web.

     

    0
  • Scott Anderson

    Hi @Berend Veldkamp?  is should be possible to add a Raster Layer in a group layer without any issue, and my tests show it working for an ImageService layer.

     

    But as you mention if the layer in question cannot be added via ArcGIS Online it would most likely fail in Web.

    0
  • Berend Veldkamp

    @Scott Anderson?  I should have been more specific, I need it for a raster layer inside a mapservice. It looks as if that is not possible.

    0
  • Berend Boersma

    Berend Veldkamp

    I have tried above functionality (adding a layer with activity "run command" but all I get is an error "Unable to load workflow 'undefined'. [WF: activity not implemented] The gcx:wf:app::RunCommand activity has not been implemented." Can help me get this part working?

    I used these settings:

    Run command

    Command Name: "map.add-layer"

    Command parameter:

    ={ "layers": [ { "layerType": "ArcGISMapServiceLayer", "url": "https://geo.rijkswaterstaat.nl/arcgis/rest/services/GDR/dtb/MapServer", "opacity": 0.5, "layers": [ { "id": 0, "defaultVisibility": false } ] } ] }

     

     

    0
  • Ryan Kelley

    Berend Boersma what is your Deployment app? That command will not work if designed to be deployed in WAB, for example. Check here:

    The json we use for this activity to add a layer looks like this, if this helps:

    ={
      "id": "groupLayer",
      "layerType": "GroupLayer",
      "maxScale": 144447,
      "minScale": 0,
      "opacity": 1,
      "title": "BLM Administrative",
      "visibility": true,
      "layers": [
        {
          "id": "123",
          "title": "Wilderness and WSA",
          "url": "https://gis.blm.gov/orarcgis/rest/services/Administrative/BLM_OR_Wilderness_and_WSA/MapServer",
          "layerType": "ArcGISMapServiceLayer"
        },
        {
          "id": "456",
          "title": "District Resource Area Boundaries",
          "url": "https://gis.blm.gov/orarcgis/rest/services/Administrative/BLM_OR_District_Resource_Area_Boundaries/MapServer",
          "layerType": "ArcGISMapServiceLayer"
        },
        {
          "id": "BLM_OR_ROW_DSG_PUB",
          "title": "BLM OR Right of Way",
          "url": "https://gis.blm.gov/orarcgis/rest/services/Administrative/BLM_OR_ROW_DSG_PUB/MapServer",
          "layerType": "ArcGISMapServiceLayer"
        }
      ]
    }

    0
  • Scott Anderson

    Hi Berend Boersma as Ryan Kelley mentioned the run command activity is specific to a VertiGIS Studio Web deployment and will currently not work in the sandbox. It should however work when executed from within a Web application.

    Also please note that the correct command is "map.add-layers", otherwise your  parameters look correct.

    0
  • Berend Boersma

    Thank you both for the information. Deployment is Vertigis Studio Web. I did get this part to work. The next step is something I have not been able to do.

    I have a workflow in which the user can choose a grouplayer to add to the viewer. That much is working. Now I need to get the array into the "map.add-layers" command. Can you help get the layers in the array into the command correctly?

    Steps are:

    "Send web request"

    "Display form"

    "CreateValue" (OperationalLayer)

    Run command 

    Command Name is "map.add-layers"

    Command Parameter is

    ={"id": "groupLayer",
      "layerType": "GroupLayer",
      "maxScale": 144447,
      "minScale": 0,
      "opacity": 1,
      "title": "testlaag",
      "visibility": true,
      "layers":$OperationalLayer.result
     }

    0
  • Berend Boersma

    Ryan Kelley

    I have tried your sample and I did get it to work except that one layer was not accessible so I removed that one. The other thing was that no groupLayer was constructed. The layers were added to the map separately.

    0
  • Wout Peters

    Interesting conversation, but still some loose ends. VertiGIS Studio Support

    Like Berend B points out, the JSON that Ryan shared does not add construct a group layer around all services. Is that just not possible at the moment? Or is there something wrong with the syntax?

    Secondly, Berend V asked about support for adding individual Raster layers from within a map service. I'm able to add the entire map service, but I would like to be able to select just one raster layer and add it to my map. Is that possible?

    0
  • Wout Peters

    To answer my first question above myself. You can add groups, but it seems like you have to nest them because the outer "groupLayer" does not seem to be taken into account...

    Syntax would be something like this:

    {
        "id": "0",
        "layerType": "GroupLayer",
        "title": "OuterGroupLayer",
        "visibility": true,
        "layers": [{
            "id": "1",
            "layerType": "GroupLayer",
            "title": "InnerGroupLayer",
            "visibility": true,
            "layers": [{
                    "id": "2",
                    "title": "Layer1",
                    "url": "https://www.something.com/...",
                    "layerType": "ArcGISFeatureLayer"
                },
                {
                    "id": "3",
                    "title": "Layer2",
                    "url": "https://www.somethingelse.com/...",
                    "layerType": "ArcGISFeatureLayer"
                }
            ]
        }]
    }

    Which results in this:

    0

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