Layers menu not showing in  NLiu's TOC widget

466
11
06-13-2014 12:56 PM
banumsbanums
New Contributor
Hi, I am trying to add the layers at http://gis.fema.gov/REST/services/FEMA/Surge/MapServer to  NLiu's TOC, but the layers are not visible in the TOC widget menu. Any suggestions please

Thanks
Reply
0 Kudos
11 Replies
KenBuja
MVP Honored Contributor
The map service doesn't have a Legend page that the TOC needs to create the symbology. Compare its REST page with one of Esri's

[ATTACH=CONFIG]34607[/ATTACH][ATTACH=CONFIG]34608[/ATTACH]
Reply
0 Kudos
JeffPace
MVP Regular Contributor
The map service doesn't have a Legend page that the TOC needs to create the symbology. Compare its REST page with one of Esri's

[ATTACH=CONFIG]34607[/ATTACH][ATTACH=CONFIG]34608[/ATTACH]


It's 10.0, I think they need to upgrade 🙂
Reply
0 Kudos
JeffPace
MVP Regular Contributor
Nliu's widget supports 10 through arcgis's legend service, but I think you need the proxy set up
Reply
0 Kudos
MichaelVolz
Esteemed Contributor
How do you control whether a mapservice supports a Legend?  I have that option available in both v10.0 and v10.2 mapservices.  In the creation of the mapservice, I do not see an option for enabling/disabling a legend in the mapservice.
Reply
0 Kudos
banumsbanums
New Contributor
Thanks Ken.
Are there any alternate solutions to use TOC, using webservices without legend.

Thanks
Reply
0 Kudos
JeffPace
MVP Regular Contributor
there is a way. From _getLegendInfo method.

if (this.rootLayer.version >= 10.01) {
    url = this.rootLayer.url.replace('MapServer','MapServer/legend');
      } else {
        url = location.protocol+'//www.arcgis.com/sharing/tools/legend';
        var i = this.rootLayer.url.toLowerCase().indexOf('/rest/');
        var soap = this.rootLayer.url.substring(0, i) + this.rootLayer.url.substring(i + 5);
        url = url + '?soapUrl=' + escape(soap);
      }


you use an else if to hardcode a json file with your own custom legend

We did this on an old layer that was pure annotation that corrupted the legend

So
1. Put a json file with the legend on a webserver
2. Put the path in the _getLegendInfo method

so


else if(url===' http://gis.fema.gov/REST/services/FEMA/Surge/MapServer'){
url = <mywebserver>/customFEMAlegend.json
}


and customFEMAlegend.json as (sample from one of our traffic layers).


{"layers": [
{
  "layerId": 0,
  "layerName": "Traffic Signs",
  "legend": [
   {
    "label": "STOP",
    "url": "js/org/mymanatee/legend/images/trans-sign-stop.png"
   },
   {
    "label": "SPEED LIMIT",
    "url": "js/org/mymanatee/letragend/images/trans-sign-speed.png"
   },
   {
    "label": "PARKING CONTROL",
    "url": "js/org/mymanatee/legend/images/trans-sign-park.png"
   },
   {
    "label": "OTHER",
    "url": "js/org/mymanatee/legend/images/trans-sign-other.png"
   }
  ]
},
{
  "layerId": 1,
  "layerName": "Sidewalks",
  "legend": [{
   "label": "",
   "url": "js/org/mymanatee/legend/images/trans-sidewalk.png"
  }]
},
{
  "layerId": 2,
  "layerName": "School Zones",
  "legend": [{
   "label": "",
   "url": "js/org/mymanatee/legend/images/trans-school-zone.png"
  }]
},
{
  "layerId": 3,
  "layerName": "Speed Zones",
  "legend": [{
   "label": "",
   "url": "js/org/mymanatee/legend/images/trans-speed-zone.png"
  }]
},
{
  "layerId": 4,
  "layerName": "Crosswalks",
  "legend": [{
   "label": "",
   "url": "js/org/mymanatee/legend/images/trans-crosswalk.png"
  }]
},
{
  "layerId": 5,
  "layerName": "Number of Lanes LEFT/RIGHT/CENTER/THRU/BIKE",
  "legend": [{
   "label": "",
   "url": "js/org/mymanatee/legend/images/trans-lanes.png"
  }]
},
{
  "layerId": 6,
  "layerName": "Roadway Width",
  "legend": [{
   "label": "",
   "url": "js/org/mymanatee/legend/images/trans-.png"
  }]
},
{
  "layerId": 7,
  "layerName": "Roadway Surface",
  "legend": [{
   "label": "ASPHALT",
   "url": "js/org/mymanatee/legend/images/trans-roadsur-asphalt.png"
  }]
},
{
  "layerId": 8,
  "layerName": "Guardrails",
  "legend": [{
   "label": "",
   "url": "js/org/mymanatee/legend/images/trans-guardrail.png"
  }]
},
{
  "layerId": 9,
  "layerName": "Medians",
  "legend": [{
   "label": "",
   "url": "js/org/mymanatee/legend/images/trans-median.png"
  }]
},
{
  "layerId": 10,
  "layerName": "Pavement Legend Locations",
  "legend": [{
   "label": "",
   "url": "js/org/mymanatee/legend/images/trans-pavement-legend.png"
  }]
},
{
  "layerId": 11,
  "layerName": "Pavement Marking/Striping",
  "legend": [{
   "label": "",
   "url": "js/org/mymanatee/legend/images/trans-pavement-mark.png"
  }]
},
{
  "layerId": 12,
  "layerName": "Poles",
  "legend": [{
   "label": "",
   "url": "js/org/mymanatee/legend/images/traff-poles.png"
  }]
},
{
  "layerId": 13,
  "layerName": "Curbs",
  "legend": [{
   "label": "",
   "url": "js/org/mymanatee/legend/images/trans-curb.png"
  }]
},
{
  "layerId": 14,
  "layerName": "Shoulders",
  "legend": [{
   "label": "",
   "url": "js/org/mymanatee/legend/images/traff-shoulder.png"
  }]
}
]}
Reply
0 Kudos
JeffPace
MVP Regular Contributor
I used hardcoded thumbnail urls because we support ie7.  If you do not, you can use base64 img tags
Reply
0 Kudos
JeffPace
MVP Regular Contributor
How do you control whether a mapservice supports a Legend?  I have that option available in both v10.0 and v10.2 mapservices.  In the creation of the mapservice, I do not see an option for enabling/disabling a legend in the mapservice.


its service pack 1 that enabled it i think (10.01).
Reply
0 Kudos
NianweiLiu
Occasional Contributor II
http://gis.fema.gov/REST/services/FEMA/Surge/MapServer


That site has a custom installation, no "arcgis" application and SOAP end point seems deployed separately. If upgrading to 10.01+ is not option, you need play with http://utility.arcgis.com/sharing/tools/legend with that site until you can figure out how to get a legend JSON file. It would helpful if you have access to admin.
Reply
0 Kudos