PictureMarkerSymbol not deserialized properly

593
0
09-03-2014 10:07 AM
EddieJesinsky
New Contributor

I thought I would report this issue. It appears that the PictureMarkerSymbol is not deserialized properly when calling Symbol.FromJson() or Renderer.FromJson() where a PictureMarkerSymbol is used in the renderer. I always have to deserialize the Source separately and reset it.

Not Working:

PictureMarkerSymbol beforeSymbol = ...

string symbolJson = beforeSymbol.ToJson();

PictureMarkerSymbol afterSymbol = Symbol.FromJson(symbolJson); //image source corrupted, have to recreate, will not show up on map or esriPrimitives:SymbolDisplay properly

Working:

PictureMarkerSymbol beforeSymbol = ...

string symbolJson = beforeSymbol.ToJson();

PictureMarkerSymbolJson symbolSerialized = JsonConvert.DeserializeObject<PictureMarkerSymbolJson>(symbolJson);

string imageData = symbolSerialized.imageData;

PictureMarkerSymbol afterSymbol = Symbol.FromJson(symbolJson);

imageData = imageData.Replace(" ", "+");

byte[] contentInBytes = Convert.FromBase64String(imageData);

BitmapImage bmi = new BitmapImage();

bmi.SetSource(new MemoryStream(contentInBytes));

afterSymbol.Source = bmi;

public class PictureMarkerSymbolJson

        {

            public string type { get; set; }

            public string __type { get; set; }

            public string imageData { get; set; }

            public int width { get; set; }

            public double xoffset { get; set; }

            public int height { get; set; }

            public double yoffset { get; set; }

        }

0 Kudos
0 Replies