raabram

LayerList/jimu.js Bug?

Discussion created by raabram on Jul 20, 2016
Latest reply on Sep 2, 2016 by LWu-esristaff

Not sure if this is the appropriate place to post this but here goes...

Using WAB 2.0 and 2.1 when I add a layer that is was published on my local ArcGIS server in a folder other than the root folder, the service name displayed in the LayerList is the folder name not the map service name.  I was able to track ti issue to jimu.js/LayerInfos/LayerInfos.js  In the code it assumes the service name to be the next part of the url after "rest/services".

To get the code to work for me I changed the following code  (line 598 in V2.1)

existing code...

serviceName = layer.url.substring(index2).split('/')[0];

New code...

serviceName = layer.url.replace(/\d+$/, '').replace(/\/$/, "").split('/').slice(-2)[0];

 

The new code strips any trailing layer numbers and slashes then takes the next to last value in the new url as the map service name.  This assumes that the map service name would always be in that position.  At least it has been for anything I have published but I'm not sure of all of the possible url formats.  But this does fix my issue and is a quick fix for anyone that might have the same issue.

Outcomes