I had a look through the ESRI js API (version:3/4) and examples on ESRI's page but I couldn't find something like an "add map layers from ", where the source is any reachable map service, WMS or ESRI Map service or something else.
If I want one I build it myself?
1 Answer 1
You can simply use some JavaScript to take in the URL and create the layer and add it to the map. Something like this:
var addLayer = (url) => {
const layer = new FeatureLayer({
url: url
});
map.layers.add(layer);
}
Of course you'll have to ask the user to specify the layer type, or detect it from the pattern. Here's an example for Feature Layer only to get you started.
-
1Thanks for the example, the answer then is to build one myself rather than there being a "search for/browse and add layers from this predefined/runtimedefined source" widget ready. That's all I wanted to know : ) Also I shall make sure not to write "Friendly regards" anymore.David I– David I2018年08月31日 14:30:00 +00:00Commented Aug 31, 2018 at 14:30