Select to view content in your preferred language

Replace Legend data from ArcGIS Server with simplemarker symbol

4108
11
11-24-2015 07:25 AM
MosesAsuquo
Deactivated User

Hello,

I want to replace the symbol of some feature layer legend symbology that comes from the ArcGIS server legend url with simplemarker symbol defined in json in my app.config  in javascript code. I am able to get the legend symbol using ajax call to the legend on the REST endpoint EST endpoint (.../MapServer/legend?f=pjson) to obtain the necessary info including the symbol img src and content in base 64 encrypted data. However, i want to replace the symbol with a custom simplemarker symbol that i have defined in my appconfig for some specific feature layers. However when i assign the simplemarker symbol to the legend.legenddata the symbol does not show on the legend table of content as expected. I am not sure what is missing.

{

"type": "esriSMS",

"style": "esriSMSSquare",

"color": [76,115,0,255],

"size": 8,

"angle": 0,

"xoffset": 0,

"yoffset": 0

}

Any useful advice will be greatly appreciate. Thank you in advance.

Tags (2)
0 Kudos
11 Replies
RobertScheitlin__GISP
MVP Emeritus

Moses,

   Since you are not specifying an outline you should not have a comma following the "yoffset" parameter.

MosesAsuquo
Deactivated User

The original definition had an outline specified. I took out the outline. i have also taken out the preceding comma. Do you have any idea how to resolve this issue and if it's even possible to replace the legend symbol with a custom simple marker symbol? Thanks for the noticing the preceding comma.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Moses,

   I have never attempted to do what you are doing. How exactly are you planning on getting your modified version of the legend json to the legend dijit?

0 Kudos
MosesAsuquo
Deactivated User

I am able to get the legend symbol using ajax call to the legend on the REST endpoint (.../MapServer/legend?f=pjson) to obtain the necessary info including the symbol img src and content in base 64 encrypted data.

Inside of the Ajax success function i assign the legend data with the symbol (which is an img src and content in base 64 encrypted data) retrieved from the sever legend REST end point.

This works find and i can see the symbology represented on the legend and on the feature layers on the map. However, for some feature layers i will like to use a custom simple marker symbol instead of the symbol from the server legend REST end point.

The reason i am doing this is because i have some feature layers that share the SAME service URL and therefore all have the same symbol coming from the server legend endpoint so my legend have feature layers with the same symbologies. For this layers with same service URL or FeatureClass table I will like to defined simplemarker symbols with different styles to replace the server legend symbology so as to differentiate the layers.

No. I cannot change the symbol in ArcMap for the different layers with the same service URL because these layers all have the same FeatureClass (one symbol) in ArcMap. The layers with same service URL are results of queries on same column of the feature class but different parameters.

I hope i have not confused you... Please if you have any suggestion that will be great. Thanks in advance.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Moses,

  So if you are using ArcGIS Server 10.1 or greater than you can use this sample to change the renderer of layers in a dynamic map service.

Dynamic layers provide the ability to change the renderer(s) for layers in a dynamic map service

Class breaks renderer with dynamic layer | ArcGIS API for JavaScript

0 Kudos
MosesAsuquo
Deactivated User

I know that. The above suggeson will change the feature layer symbology when provided a renderder. I intend to change the legend symbology. I know ultimately that the legend symbologies must match the feature layers symbologies on the map.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Moses,

   using the above will change both the legend and the layer symbology in the map. Is that not what you are after?

0 Kudos
MosesAsuquo
Deactivated User

The Feature Layers with the same service URL are not as a result of class breaks on the layer. I don't intend to use class break render. What i am trying to do is to simply change the symbology for all the layers with the same service url so that they can be differentiated but not as with class break renderer. Basically the featurelayers are created using setDefinitionExpression so we could end up with featurelayers with the same URL but different query expression. Theses feature layers with the same URL end up having the same symbologies  both on the legend and on the map.

0 Kudos
MosesAsuquo
Deactivated User

By the way the query expressions for each feature layer is complex and not base on one column of a Feature Class but several columns and parameters. Class Breaks works on one column with different range of values. This is another difference,

0 Kudos