var fullUrl = window.location.href; //get the full URL var layerUrl = gup(fullUrl); // send this to the function console.log(layerUrl);// this should be just the layer definition section function gup( name ) { name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]"); var regexS = "[\\?&]"+name+"=([^&#]*)"; var regex = new RegExp( regexS ); var results = regex.exec(name); if( results == null ) return ""; else return results[1]; //return just the Layer definition of the URL }
But how to I pass that string to this variable?var operationalLayer = new esri.layers.ArcGISDynamicMapServiceLayer("string_goes_here");
The value is a clean URL like this:http://129.2.24.163/ArcGIS/rest/services/00_SMC_Environmental_Health/MapServer
var rest_url = "http://129.2.24.163/ArcGIS/rest/services/00_SMC_Environmental_Health/MapServer"; var dynamicMapServiceLayer = new esri.layers.ArcGISDynamicMapServiceLayer(rest_url); map.addLayer(dynamicMapServiceLayer);
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.