AnsweredAssumed Answered

Add layer via URL (JS API)

Question asked by sch7712 on Jun 9, 2017
Latest reply on Jul 26, 2018 by sch7712

Hello all!


I am attempting to add a layer via a URL that the user provides via a text box in the UI. 


I can capture the layer URL and work with it in JS, but when I attempt to use it to create a layer, I get the following error in the console "Uncaught TypeError: a.hasChildNodes is not a function"


Here is the JS code that attempts to use the entered URL to create a new Dynamic Map Service Layer:

NOTE: The URL I have been working with is: nowcoast/mapoverlays_political (MapServer) 


        var layerURLbox = registry.byId("LayerURLbox");
        on(dom.byId("layerSubmit"), "click", getValue);

        function getValue() {
            layerValue = layerURLbox.get("value")

        function getLayerType(layerURLValue) {

            if (layerURLValue.indexOf("MapServer")) {
                console.log("Map Service");
                var layer = new ArcGISDynamicMapServiceLayer(layerURLValue, {
                    id: "Test"


The console error I mentioned occurs on line 14, where I attempt to create the new ArcGISDynamicMapServiceLayer.

It does not make it to map.addLayer.


If anyone has any pointers or has tried this before, please let me know!


Thank you!