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() {
console.log(layerURLbox.get("value"));
layerValue = layerURLbox.get("value")
getLayerType(layerValue);
}
function getLayerType(layerURLValue) {
if (layerURLValue.indexOf("MapServer")) {
console.log("Map Service");
var layer = new ArcGISDynamicMapServiceLayer(layerURLValue, {
id: "Test"
})
map.addLayer(layer);
}
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!
Chris