【问题标题】:Bind Polyline from MVVM Googlemap Xamarin从 MVVM Googlemap Xamarin 绑定折线
【发布时间】:2021-04-28 15:36:45
【问题描述】:

从谷歌地图 Api 获取位置并希望在两点之间创建折线但问题是折线->GeoPath 是只读的。 如何将位置分配给 GeoPath 或直接将位置绑定到地图?

我正在关注this sample

Map map = new Map
{
// ...
};
// instantiate a polyline
Polyline polyline = new Polyline
{
StrokeColor = Color.Blue,
StrokeWidth = 12,
Geopath =
{
new Position(47.6381401, -122.1317367),
new Position(47.6381473, -122.1350841),
new Position(47.6382847, -122.1353094),
new Position(47.6384582, -122.1354703),
new Position(47.6401136, -122.1360819),
new Position(47.6403883, -122.1364681),
new Position(47.6407426, -122.1377019),
new Position(47.6412558, -122.1404056),
new Position(47.6414148, -122.1418647),
new Position(47.6414654, -122.1432702)
}
};

// add the polyline to the map's MapElements collection
map.MapElements.Add(polyline);

【问题讨论】:

  • 您可以将项目添加到 Geopath 集合中,但不能分配新的 Geopath 实例
  • @Jason 已经有 IList 但如何将它与 Map 绑定?请解释

标签: c# .net xamarin xamarin.forms xamarin.android


【解决方案1】:

折线 -> 地理路径 -> 添加将解决问题

Polyline polyline = new Polyline
{
StrokeColor = Color.Blue,
StrokeWidth = 12
}
polyline.GeoPath.Add(new Position)

【讨论】:

  • 感谢分享。不要忘记接受答案。
猜你喜欢
  • 2018-03-29
  • 2021-06-27
  • 1970-01-01
  • 2021-10-16
  • 2018-08-14
  • 1970-01-01
  • 1970-01-01
  • 2018-07-14
  • 1970-01-01
相关资源
最近更新 更多