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);
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.