本文整理匯總了C#中Newtonsoft.Json.JsonWriter.WriteGeoJson方法的典型用法代碼示例。如果您正苦於以下問題:C# JsonWriter.WriteGeoJson方法的具體用法?C# JsonWriter.WriteGeoJson怎麽用?C# JsonWriter.WriteGeoJson使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Newtonsoft.Json.JsonWriter
的用法示例。
在下文中一共展示了JsonWriter.WriteGeoJson方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: WriteJson
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
SortedDictionary<string, int> tagCount = new SortedDictionary<string, int>();
MapLayersResult result = value as MapLayersResult;
int remainingRecords = 0;
writer.WriteStartObject();
// Layers
writer.WritePropertyName("layers");
writer.WriteStartArray();
foreach (PointLayer layer in result.PointLayers)
{
remainingRecords += (layer.TotalResults - layer.Points.Count);
if(layer.Page > 1)
{
remainingRecords -= (layer.PageSize * (layer.Page - 1));
}
writer.WriteStartObject();
writer.WritePropertyName("type");
writer.WriteValue("PointLayer");
writer.WritePropertyName("ds");
writer.WriteValue(layer.DataSource.ToString());
writer.WritePropertyName("cnt");
writer.WriteValue(layer.TotalResults);
writer.WritePropertyName("pg");
writer.WriteValue(layer.Page);
writer.WritePropertyName("pgCnt");
writer.WriteValue(layer.PageCount);
writer.WritePropertyName("data");
writer.WriteGeoJson(layer.Points, ref tagCount);
writer.WriteEndObject();
}
writer.WriteEndArray();
writer.WritePropertyName("remainingRecords");
writer.WriteValue(remainingRecords);
// Tags
writer.WritePropertyName("tags");
writer.WriteStartArray();
foreach (KeyValuePair<string,int> cnt in tagCount)
{
writer.WriteStartObject();
writer.WritePropertyName("tag");
writer.WriteValue(cnt.Key);
writer.WritePropertyName("cnt");
writer.WriteValue(cnt.Value);
writer.WriteEndObject();
}
writer.WriteEndArray();
writer.WriteEndObject();
}