Xamarin Google Maps StreetView - 没有强制室外定位的选项

Xamarin Google Maps StreetView - no option to force outdoor location


我在 Xamarin.Android 上的 Google Maps v2(Android.Gms.Maps) 和 Xamarin.iOS 上的 Xamarin.Google.iOS.Maps 中发现缺少功能。
该问题与创建街景有关。根据文档(原生 Android SDK),有 4 种方法可以使用 SetPosition 方法设置街景的位置。其中两个接受参数 StreetViewSource,您可以通过该参数强制 StreetView 仅使用室外图像。这是文档中的片段:

private static final LatLng SAN_FRAN = new LatLng(37.765927, -122.449972);
// Set position with LatLng only.
mStreetViewPanorama.setPosition(SAN_FRAN);
// Set position with LatLng and radius.
mStreetViewPanorama.setPosition(SAN_FRAN, 20);
// Set position with LatLng and source.
mStreetViewPanorama.setPosition(SAN_FRAN, StreetViewSource.OUTDOOR);
// Set position with LaLng, radius and source.
mStreetViewPanorama.setPosition(SAN_FRAN, 20, StreetViewSource.OUTDOOR);

不幸的是,在 Xamarin 上没有接受 StreetViewSource 参数的方法重载(甚至 class StreetViewSource 也没有)。
有什么办法可以克服这个问题吗?或者这是缺少功能,迟早会添加(最好更早)?

在您的 IOnStreetViewPanoramaReadyCallback 实现中,您可以将 StreetViewPanorama 的位置设置为包括 StreetViewSource.Outdoor:

public void OnStreetViewPanoramaReady(StreetViewPanorama panorama)
{
    panorama.SetPosition(new LatLng(-33.87365, 151.20689), StreetViewSource.Outdoor);
    ~~~
}

更新:

您至少需要安装70.1501.0-preview...

<package id="Xamarin.GooglePlayServices.Maps" version="70.1501.0-preview2" targetFramework="monoandroid90" />