【问题标题】:How to show the path and distance on Google Map - Xamarin如何在谷歌地图上显示路径和距离 - Xamarin
【发布时间】:2016-11-15 21:13:20
【问题描述】:

我有一个页面(片段)显示谷歌地图和 1 个标记图标。所以现在我想将源坐标和目的地坐标传递给这张地图,以便它可以显示最短路线以及以公里为单位的距离。例如,我希望地图在下图中显示蓝色路径:

这是我的代码:

private void SetUpMap()
 {
       if (GMap == null)
       {
           ChildFragmentManager.FindFragmentById<MapFragment>(Resource.Id.googlemap).GetMapAsync(this);
        }
 }

public void OnMapReady(GoogleMap googleMap)
{

                this.GMap = googleMap;
                GMap.UiSettings.ZoomControlsEnabled = true;

                LatLng latlng = new LatLng(Convert.ToDouble(gpsLatitude), Convert.ToDouble(gpsLongitude));
                CameraUpdate camera = CameraUpdateFactory.NewLatLngZoom(latlng, 15);
                GMap.MoveCamera(camera);

                MarkerOptions options = new MarkerOptions()
                           .SetPosition(latlng)
                           .SetTitle("Chennai");

                GMap.AddMarker(options);
}

【问题讨论】:

标签: google-maps xamarin


【解决方案1】:

我从这篇文章中得到了答案:

Adding polyline between two locations google maps api v2

我将 java 代码转换为 C#,它运行良好。

【讨论】:

  • 您与我们分享您尝试做的纺纱过程吗?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-12-22
  • 2016-02-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多