【问题标题】:How to display google maps in Android (which takes to current location and show the distance to destination)如何在 Android 中显示谷歌地图(获取当前位置并显示到目的地的距离)
【发布时间】:2018-03-29 13:33:06
【问题描述】:
switch (Device.RuntimePlatform)
            {
                case Device.iOS:
                    url = String.Format("https://maps.apple.com/maps?daddr={0}", Uri.EscapeDataString(Shop.Address.StreetZipCityString));
                    break;
                case Device.Android:

                    url = String.Format("geo:0,0?q={0}", Uri.EscapeDataString(Shop.Address.StreetZipCityString));

                    break;
                default:
                    url = String.Format("https://www.google.com/maps/dir/?api=1&query={0}", Uri.EscapeDataString(Shop.Address.StreetZipCityString));
                    break;

            }

在 IOS 中,此 URL 将我带到当前位置并显示目的地。 在 android 中,仅显示目的地,而不是当前位置或从当前到目的地的距离。

【问题讨论】:

    标签: android xamarin development-environment


    【解决方案1】:

    我认为您需要使用 HttpUtility.UrlEncode 对目标地址进行编码 你可以试试url = String.Format("geo:0,0?q={0}", Uri.EscapeDataString(HttpUtility.UrlEncode(Shop.Address.StreetZipCityString)));

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-08-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-08-14
      相关资源
      最近更新 更多