Remove Feature Layer Name in front of Layers in ArcGIS Online TOC

1964
12
Jump to solution
02-01-2017 09:29 AM
AmberTobin
New Contributor III

Hi,

Each week I use python to upload a mxd to AGOL. The mxd contains 30 layers or so that get uploaded into 1 hosted feature service layer. When I look at in a map on AGOL the hosted Feature Layer name appears in front of every layer in the map (in the legend and layer list). Is there way to hide the feature layer name without manually going into each layer to rename it?

My hosted feature layer is called AllPDS, notice in the image below it shows up in front of every layer.

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Esteemed Contributor

Amber,

   Sure the code that need to be changed is in the jimu.js/LayerInfos.js _getLayerTitle function:

notice lines 8 -27 are commented out to prevent the adding of the service name to the layer title.

    _getLayerTitle: function(layer) {

      if(layer.title) {
        return layer.title;
      }

      var title = layer.label || layer.name || "";
      // if (layer.url) {
      //   var serviceName;
      //   var index = layer.url.indexOf("/FeatureServer");
      //   if (index === -1) {
      //     index = layer.url.indexOf("/MapServer");
      //   }
      //   if (index === -1) {
      //     index = layer.url.indexOf("/service");
      //   }
      //   if(index > -1) {
      //     serviceName = layer.url.substring(0, index);
      //     serviceName = serviceName.substring(serviceName.lastIndexOf("/") + 1, serviceName.length);
      //     if (title) {
      //       title = serviceName + " - " + title;
      //     } else {
      //       title = serviceName;
      //     }
      //   }
      //
      // }
      return title || layer.id;
    },

View solution in original post

12 Replies
RobertScheitlin__GISP
MVP Esteemed Contributor

Amber,

   If this is the AGOL version of WAB then the answer is no there is no way to make changes like that would using WAB Developer edition and make code changes.

0 Kudos
AmberTobin
New Contributor III

Hi Robert,

I am using the feature layer in WAB but I assume, if possible, hiding the feature service name would occur prior to using it in WAB.

My process steps are:

  1. Create and symbolize layers using python and save as a mxd.
  2. Use python to upload the mxd as a hosted feature service to my AGOL subscription account.
  3. Bring the hosted feature service into a web map.
  4. Use WAB to display web map as a mapping application.

I would think hiding the feature service name would occur in steps 2 or 3 if possible. I couldn't find anything in the item details section either.

0 Kudos
RobertScheitlin__GISP
MVP Esteemed Contributor

Amber,

   It is the WAB LayerList widget that is adding the service name so no. This is a know feature and I have posted code fixes for this in the past but you would have to be using WAB Dev Edition to apply those changes.

0 Kudos
AmberTobin
New Contributor III

Thanks Robert. I decided to dive into WAB Developer. I was watching some ESRI videos and you seem you be the widget guru. Would you mind sharing the link to your code fixes? I tried looking on the Widget page but didn't see it.

Thanks!

-Amber

RobertScheitlin__GISP
MVP Esteemed Contributor

Amber,

   Sure the code that need to be changed is in the jimu.js/LayerInfos.js _getLayerTitle function:

notice lines 8 -27 are commented out to prevent the adding of the service name to the layer title.

    _getLayerTitle: function(layer) {

      if(layer.title) {
        return layer.title;
      }

      var title = layer.label || layer.name || "";
      // if (layer.url) {
      //   var serviceName;
      //   var index = layer.url.indexOf("/FeatureServer");
      //   if (index === -1) {
      //     index = layer.url.indexOf("/MapServer");
      //   }
      //   if (index === -1) {
      //     index = layer.url.indexOf("/service");
      //   }
      //   if(index > -1) {
      //     serviceName = layer.url.substring(0, index);
      //     serviceName = serviceName.substring(serviceName.lastIndexOf("/") + 1, serviceName.length);
      //     if (title) {
      //       title = serviceName + " - " + title;
      //     } else {
      //       title = serviceName;
      //     }
      //   }
      //
      // }
      return title || layer.id;
    },

View solution in original post

AmberTobin
New Contributor III

Thanks Robert,

I'll need to look into it more. I changed the code with that file name in the WAB Client folder but haven't seen the changes. When I tested out adding a widget that's where I needed to modify the code to get it to show-up in the WAB online developer. I'll play around with the jimu.js/LayerInfos.js file in other folders.

Thank you,

Amber

0 Kudos
RobertScheitlin__GISP
MVP Esteemed Contributor

Amber,

   You need to make the change in the [install dir]\server\apps\[app#]\jimu.js\LayerInfos.js

AmberTobin
New Contributor III

Thanks!

0 Kudos
RobertScheitlin__GISP
MVP Esteemed Contributor

Don't forget to mark the thread as answered by clicking on the "Correct Answer" link.

0 Kudos