AnsweredAssumed Answered

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

Question asked by epaitz-esristaff Employee on Sep 23, 2014
Latest reply on Oct 15, 2014 by JNery-esristaff

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?