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 legendWe did this on an old layer that was pure annotation that corrupted the legendSo1. Put a json file with the legend on a webserver2. Put the path in the _getLegendInfo methodso
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"
}]
}
]}