Select to view content in your preferred language

Legend Question?

1295
3
03-02-2011 08:01 AM
IgressT
Emerging Contributor
When I add a GPResultImageLayer from GP task to the map, the legend displays the layer however it does not show any legend for it (GPResultImageLayer  doesnot have legendinfo). Is there a way to extend GPResultImageLayer so that when I add the GPResultImageLayer to the map I can also add legend information thorough code.

Thanks
0 Kudos
3 Replies
BKuiper
Frequent Contributor
Hi,

you can get the legend if you are using a result map service. It's not ideal, but it will give you at least some information. Currently the REST API doesn't support Legend information on the GPResultImageLayer.

I'm accessing the original MapServer service to get the legend from there.

I will demonstrate this at the Esri Dev Summit:

http://events.esri.com/bpc/2011/dev_agenda/index.cfm?fa=Session_Detail_Form&SessionId=200&ScheduleId...

I'm basically temporary adding the result of the Tool layer to the map; retrieve the legend; Store it; and remove the layer again.

You can then add this information to your newly created layers.

The downside of this solution is that the legend doesn't actual represent your newly created layer. The legend you downloaded can have more symbols then are actual used in your result (GPResultImageLayer).

I hope this make sense.
0 Kudos
IgressT
Emerging Contributor
Hi,

you can get the legend if you are using a result map service. It's not ideal, but it will give you at least some information. Currently the REST API doesn't support Legend information on the GPResultImageLayer.

I'm accessing the original MapServer service to get the legend from there.

I will demonstrate this at the Esri Dev Summit:

http://events.esri.com/bpc/2011/dev_agenda/index.cfm?fa=Session_Detail_Form&SessionId=200&ScheduleId...

I'm basically temporary adding the result of the Tool layer to the map; retrieve the legend; Store it; and remove the layer again.

You can then add this information to your newly created layers.

The downside of this solution is that the legend doesn't actual represent your newly created layer. The legend you downloaded can have more symbols then are actual used in your result (GPResultImageLayer).

I hope this make sense.


AFAIK you cannot extend GPResultImageLayer so I think there is no clear solution for it. The above solution seems a good approach however your map legend and GPResultImageLayer are seperated.
0 Kudos
BKuiper
Frequent Contributor
I agree.

The best solution would be that the GPResultImageLayer would have Legend information (on the REST endpoint).

A workaround is templating your Legend control to lookup the symbols in a collection based on the name of the layer when the layer is a GPResultImageLayer.
0 Kudos