【发布时间】:2019-05-23 12:23:18
【问题描述】:
我正在尝试在我的 xamarin 表单应用程序中对 Google 地图上的标记进行聚类。 这是我的模型:
public class MapModel
{
public Field[] Fields { get; set; }
}
public class Field
{
public int Id { get; set; }
public string Name { get; set; }
public Node[] Nodes { get; set; }
public string Icon { get; set; }
}
public class Node
{
public float Long { get; set; }
public float Lat { get; set; }
}
这是我用来获取经度和纬度值的服务
class MapService
{
public static async Task<MapModel> GetMapData(string token, string lngCode)
{
try
{
MapModel mapModels = new MapModel();
string url = DataURL.BASE_URL + "agronetmobile/mapdata?lngCode=" + lngCode;
using (HttpClient client = new HttpClient())
{
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
using (HttpResponseMessage message = await client.GetAsync(url))
{
if (message.StatusCode == System.Net.HttpStatusCode.OK)
{
string rawResponse = await message.Content.ReadAsStringAsync();
mapModels = JsonConvert.DeserializeObject<MapModel>(rawResponse);
}
}
}
return mapModels;
}
catch (Exception)
{
throw;
}
}
}
服务返回正确的值,但我什至不知道如何使用它们。 我安装了 Xamarin.Forms.GoogleMaps.Clustering 并试图找到一些好的分步教程,但没有找到任何有用的东西。许多教程都是关于 Xamarin.Android 的。 我正在使用 MVVM 模式。
【问题讨论】:
-
您查看过该软件包的示例应用程序吗?它似乎所做的只是调用 Map.Cluster();添加引脚后
-
@Jason 这个:link ?我什至想弄清楚如何在地图上设置大头针。我现在第一次使用集群...关于链接我应该关注什么?
标签: google-maps xamarin.forms markerclusterer