Hi,I am trying to get the original symbol information from a feature layer and use that when drawing graphics. It seems however that the data returned by FeatureLayer.renderer.getSymbol() does not work with the setSymbol() function I use to set the symbol for the feature in the client. To solve it I have to create my own JSON structure by taking parts of the data returned by getSymbol(), like this:
// On initializing the page
myFeatureLayer = new esri.layers.FeatureLayer("http://myServer:6080/arcgis/rest/services/IFS/FeatureServer/1");
// Later on
symbolFromFeatureLayer = myFeatureLayer.renderer.getSymbol();
jsonedSymbol = new esri.symbol.PictureMarkerSymbol(symbolFromFeatureLayer.toJson());
finalSymbol = { "type": jsonedSymbol.type,
"url": jsonedSymbol.imageData.substring(jsonedSymbol.imageData.lastIndexOf("/") + 1),
"imageData": jsonedSymbol.url.substring(b3.url.indexOf(",") + 1),
"contentType": jsonedSymbol.contentType,
"xoffset": jsonedSymbol.xoffset,
"yoffset": jsonedSymbol.yoffset,
"height": jsonedSymbol.height,
"width": jsonedSymbol.width };
This is how the resulting object must look:
finalSymbol = {
"type": "picturemarkersymbol", // "esriPMS",
"url": "105e4b8feaf0786d167d356fb3aac76e",
"imageData": "base 64 coded data goes here==",
"contentType": "image/png",
"width": 15,
"height": 15,
"angle": 0,
"xoffset": 0,
"yoffset": 0
};
Btw, if I "browse" my feature layer through the REST url I can see that the "correct" format can be returned by the server, in JSON format. I thought of doing some extra HTTP call against the REST service with the JSON parameter sent in:http://myServer:6080/arcgis/rest/services/IFS/FeatureServer/1?f=pjsonAnd then extracting the information from the renderer section, etc, but it was almost as easy doing the above.So... Am I doing anything wrong since I cannot directly take the symbol from the feature layer and use it for the symbol property in my graphics?Okay, thanks!/Mathias