Select to view content in your preferred language

LayerList/jimu.js Bug?

2985
4
07-20-2016 09:59 AM
RichardAbram
Occasional Contributor

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.

4 Replies
RobertScheitlin__GISP
MVP Emeritus

Richard,

Thanks for post your code fix.

Lemao Wu

0 Kudos
LemaoWu
Esri Contributor

Thanks Richard and Robert.

0 Kudos
RebeccaStrauch__GISP
MVP Emeritus

Richard...I added it to the Web AppBuilder Developer Edition - Customization Resource List​  but you may want to rename the post to say "Tip" or "workaround" since it is a solution/discussion rather than a question.

0 Kudos
LemaoWu
Esri Contributor

The fix has been checked in and will be available in  Online update (mid-September) and the Dev Edition after the Online update. Thanks Richard. 

0 Kudos