Hoppa till huvudinnehållet

Add a map service to a map dynamically as a user?

Kommentarer

1 kommentar

  • Matthew Poirier

    Hi Marc, 

    A workflow could do this, using an activity from the ArcGIS Maps SDK for JavaScript workflow activity pack and and a VertiGIS Studio Web command in a workflow.

    Below is the JSON for a very barebones proof of concept workflow that adds an AGS layer from a URL entered in a display form to a VSW app. You can save the JSON to a file and upload it to your Workflow designer.

    {
    "_properties":
        {
        },
    "components":
        [
            {
            "id": 1,
            "steps":
                [
                    {
                    "id": 2,
                    "inputs":
                        {
                        },
                    "position": "0,0",
                    "purpose": "start",
                    "title": "Start",
                    "transitions":
                        [
                            {
                            "id": 7,
                            "position": "90,60 90,130",
                            "target":
                                {
                                "id": 5
                                }
                            }
                        ]
                    },
                    {
                    "action": "gcx:wf:forms:form:DisplayForm",
                    "id": 5,
                    "inputs":
                        {
                        "form":
                            {
                            "accessors":
                                [
                                ],
                            "code": "resources.forms[values.id]",
                            "values":
                                {
                                "id": 6
                                }
                            }
                        },
                    "name": "form1",
                    "position": "-30,130",
                    "title": "Display Form",
                    "transitions":
                        [
                            {
                            "id": 13,
                            "position": "90,250 90,320",
                            "sourceConnector": "bottom",
                            "target":
                                {
                                "id": 12
                                },
                            "targetConnector": "top"
                            }
                        ]
                    },
                    {
                    "action": "gcx:wf:core::CreateValue",
                    "id": 12,
                    "inputs":
                        {
                        "expression":
                            {
                            "accessors":
                                [
                                "$form1"
                                ],
                            "annotations":
                                [
                                    {
                                    "count": 6,
                                    "index": 0,
                                    "kind": "idref"
                                    }
                                ],
                            "code": "$form1.state.textBox1.value",
                            "source": "$form1.state.textBox1.value"
                            }
                        },
                    "name": "value1",
                    "position": "-30,320",
                    "title": "Create Value",
                    "transitions":
                        [
                            {
                            "id": 17,
                            "position": "90,390 90,450",
                            "sourceConnector": "bottom",
                            "target":
                                {
                                "id": 16
                                },
                            "targetConnector": "top"
                            }
                        ]
                    },
                    {
                    "action": "gcx:wf:app::RunCommand",
                    "description": "This uses an app command - see reference here: https://developers.vertigisstudio.com/docs/web/api-commands-operations-events",
                    "id": 14,
                    "inputs":
                        {
                        "commandName": "map.add-layers",
                        "commandParameter":
                            {
                            "accessors":
                                [
                                "$layer1"
                                ],
                            "annotations":
                                [
                                    {
                                    "count": 7,
                                    "index": 10,
                                    "kind": "idref"
                                    }
                                ],
                            "code": "{ \"layers\": $layer1.result }",
                            "source": "{\"layers\":$layer1.result}"
                            }
                        },
                    "position": "-30,640",
                    "title": "Run Command"
                    },
                    {
                    "action": "uuid:22c49a54-bac0-49d7-8ec2-4269a4fee5c8::CreateLayerFromArcGisServerUrl",
                    "description": "This activity is from the ArcGIS Maps SDK for JavaScript workflow activity pack.",
                    "id": 16,
                    "inputs":
                        {
                        "url":
                            {
                            "accessors":
                                [
                                "$value1"
                                ],
                            "annotations":
                                [
                                    {
                                    "count": 7,
                                    "index": 0,
                                    "kind": "idref"
                                    }
                                ],
                            "code": "$value1.result",
                            "source": "$value1.result"
                            }
                        },
                    "name": "layer1",
                    "position": "-30,450",
                    "title": "Create Layer From ArcGIS Server URL",
                    "transitions":
                        [
                            {
                            "id": 18,
                            "position": "90,580 90,640",
                            "target":
                                {
                                "id": 14
                                }
                            }
                        ]
                    }
                ]
            }
        ],
    "deploymentConfig":
        {
        "supportedApps":
            {
            "VSW": true
            }
        },
    "designerVersion": "5.38.1+5",
    "forms":
        [
            {
            "defaults":
                {
                },
            "elements":
                {
                "footer":
                    {
                    "enabled": true,
                    "items":
                        {
                        "0":
                            {
                            "default": true,
                            "index": 0,
                            "label":
                                {
                                "markdown": "Submit"
                                },
                            "validates": true,
                            "value": "submit"
                            },
                        "1":
                            {
                            "index": 1,
                            "label":
                                {
                                "markdown": "Cancel"
                                },
                            "validates": false,
                            "value": "cancel"
                            }
                        },
                    "section": "footer",
                    "type": "ButtonBar"
                    },
                "header":
                    {
                    "section": "header",
                    "title":
                        {
                        "markdown": "Add AGS Layer to App"
                        },
                    "type": "Header"
                    },
                "textBox1":
                    {
                    "description":
                        {
                        "markdown": "Note the display form has no validation for inputs. This is a basic example."
                        },
                    "enabled": true,
                    "index": 0,
                    "rowIndex": 0,
                    "rowNumber": 0,
                    "title":
                        {
                        "markdown": "ArcGIS Server URL"
                        },
                    "tooltip": "Add a valid AGS URL in this Box",
                    "type": "TextBox",
                    "value": "https://sampleserver6.arcgisonline.com/arcgis/rest/services/Energy/Geology/FeatureServer"
                    }
                },
            "id": 6
            }
        ],
    "licenseInfo":
        {
        "licenseeId": "88cb61d6-af47-9b3e-5181-ed674c4c0815"
        },
    "references":
        [
            {
            "id": 21,
            "path": "https://unpkg.com/@vertigis/workflow-activities-arcgis-core@1.10.0",
            "suite": "uuid:22c49a54-bac0-49d7-8ec2-4269a4fee5c8"
            }
        ],
    "start":
        {
        "id": 2
        }
    }
    1

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