Possible issue with the PictureMarkerSymbol.ToJson() and .FromJson()

2752
1
09-23-2014 01:13 PM
Labels (1)
EricPaitz
Esri Contributor

We are seeing some potential issues with the ToJson() and FromJson() static methods for a PictureMarkerSymbol.

Define the ESRI.ArcGIS.Symbols.PictureMarkerSymbol in XAML like the following.

<sym:PictureMarkerSymbol x:Key=”MySymbol” Source=”SomeFile.png” … />

Now get a reference to this Symbol like the following.

PictureMarkerSymbol pms = (PictureMarkerSymbol)App.FindResource(“MySymbol”);

Now get its JSON.

string json = pms.ToJson();

The JSON does not include the following property.

“contentType”: “image/png”

As a result when using this Symbol, like the following, nothing draws to the map because the PictureMarkerSymbol.Source is null.

Graphic graphic = new Graphic();

Graphic.Symbol = PictureMarkerSymbol.FromJson(json);

Now if we do the same thing, but instead of creating the PictureMarkerSymbol from XAML we create it in code like the following.

PictureMarkerSymbol pms = new PictureMarkerSymbol(); {

  Source = new BitmapImage(new Uri(@”SomeFile.png”)),

  Width = 18,

  Height = 26

}

string json = pms.ToJson();

Now the json does include the contentType and it does work when calling FromJson().

We are assuming that there is some kind of internal property that holds the content type. When a PictureMarkerSymbol is created in code the BitmapImage must be parsed to know if it’s a png, bmp, etc and then this internal content type is set. Then later when ToJson is called it knows what content type to put in the JSON. Now it’s a guess but when the PictureMarkerSymbol is defined in XAML the ValueConverter for the Source is not setting this internal property that holds the content type, and then its not part of the JSON.

This seems like a small bug to us but we are not sure if this was by design or not. Can anyone verify this?

0 Kudos
1 Reply
JenniferNery
Esri Regular Contributor

Thanks for reporting this. I'm able to reproduce the issue. We'll try to get it fixed in future versions of the API.

0 Kudos