public string ToJson() { MPWrapper wrapper = new MPWrapper(Markers, Polygons); foreach (int key in wrapper.Markers.Keys) { wrapper.Markers[key].Marker = null; } foreach (int key in wrapper.Polygons.Keys) { wrapper.Polygons[key].Polygon = null; } string json = JsonConvert.SerializeObject(wrapper, Formatting.Indented); return(json); }
public void LoadJson(string json) { Clear(); MPWrapper wrapper = JsonConvert.DeserializeObject <MPWrapper>(json); this.Markers = new Dictionary <int, SymbolInfo>(wrapper.Markers); this.Polygons = new Dictionary <int, AreaInfo>(wrapper.Polygons); foreach (int id in Markers.Keys) { SymbolInfo sinfo = Markers[id]; sinfo.Marker = MarkSymbol(sinfo.ImgID, sinfo.Name, sinfo.Point, sinfo.ID); } foreach (int id in Polygons.Keys) { AreaInfo ainfo = Polygons[id]; ainfo.Polygon = CreatePolygon(ainfo.Name, ainfo.GetPoints(), ainfo.Property); } }