Google maps 对类型GoogleMap.IOnCameraMoveListener的引用声称它是在Xamarin.GooglePlayServices中定义的

Google maps 对类型GoogleMap.IOnCameraMoveListener的引用声称它是在Xamarin.GooglePlayServices中定义的,google-maps,xamarin,xamarin.forms,xamarin.ios,xamarin.android,Google Maps,Xamarin,Xamarin.forms,Xamarin.ios,Xamarin.android,我正面临一个与参考资料相关的问题,正如标题所示,我得到: 对类型“GoogleMap.IOnCameraMoveListener”的引用声称它是 在“Xamarin.GooglePlayServices.Maps”中定义,但不能 找到C:\Users\App.Xamarin\App.Android\CustomMapRenderer.cs 我一直在尝试在三星Galaxy S8+Android API 27上使用live player,但没有成功 using Android.Gms.Maps.Mo

我正面临一个与参考资料相关的问题,正如标题所示,我得到:

对类型“GoogleMap.IOnCameraMoveListener”的引用声称它是 在“Xamarin.GooglePlayServices.Maps”中定义,但不能 找到C:\Users\App.Xamarin\App.Android\CustomMapRenderer.cs

我一直在尝试在三星Galaxy S8+Android API 27上使用live player,但没有成功

using Android.Gms.Maps.Model;
using App.Android;
using App.Portable.Vista.ControlesUsuario.Mapas;
using System.Collections.Generic;
using Xamarin.Forms;
using Xamarin.Forms.Maps;
using Xamarin.Forms.Maps.Android;

[assembly: ExportRenderer(typeof(MapaGoogle), typeof(CustomMapRenderer))]
namespace App.Android
{
    public class CustomMapRenderer : MapRenderer
    {
        List<Position> routeCoordinates;
        bool isDrawn;

        protected override void OnElementChanged(Xamarin.Forms.Platform.Android.ElementChangedEventArgs<Map> e)
        {
            base.OnElementChanged(e);

            if (e.OldElement != null)
            {
                // Unsubscribe
            }

            if (e.NewElement != null)
            {
                var formsMap = (MapaGoogle)e.NewElement;
                routeCoordinates = formsMap.RouteCoordinates;
                Control.GetMapAsync(this);
            }
        }

        protected override void OnElementPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            base.OnElementPropertyChanged(sender, e);

            if (e.PropertyName.Equals("VisibleRegion") && !isDrawn)
            {
                var polylineOptions = new PolylineOptions();
                polylineOptions.InvokeColor(0x66FF0000);

                foreach (var position in routeCoordinates)
                {
                    polylineOptions.Add(new LatLng(position.Latitude, position.Longitude));
                }

                NativeMap.AddPolyline(polylineOptions);
                isDrawn = true;
            }
        }
    }
}
使用Android.Gms.Maps.Model;
使用App.Android;
使用App.Portable.Vista.ControlesUsuario.Mapas;
使用System.Collections.Generic;
使用Xamarin.Forms;
使用Xamarin.Forms.Maps;
使用Xamarin.Forms.Maps.Android;
[程序集:ExportRenderer(typeof(MapaGoogle)、typeof(CustomMapRenderer))]
名称空间App.Android
{
公共类CustomMapRenderer:MapRenderer
{
列出路线坐标;
布尔是拉文;
受保护的覆盖无效OnElementChanged(Xamarin.Forms.Platform.Android.ElementChangedEventArgs e)
{
基础。一个要素发生变化(e);
if(e.OldElement!=null)
{
//退订
}
if(例如NewElement!=null)
{
var formsMap=(mapagogle)e.NewElement;
路线坐标=formsMap.路线坐标;
GetMapAsync(this);
}
}
受保护的覆盖无效OneElementPropertyChanged(对象发送方,System.ComponentModel.PropertyChangedEventArgs e)
{
base.OnElementPropertyChanged(发送方,e);
if(e.PropertyName.Equals(“VisibleRegion”)&&&!isDrawn)
{
var polylineOptions=新的polylineOptions();
polylineOptions.InvokeColor(0x66FF0000);
foreach(路线坐标中的var位置)
{
添加(新板条(位置.纬度,位置.经度));
}
添加多段线(多段线选项);
isDrawn=true;
}
}
}
}
我已经花了2天的时间试图弄清楚到底发生了什么,但很难找到解决方案,因为如果我没有弄错的话,错误太具体了

我只找到了相关信息

另外,我不知道它是否与需要更新Google Play服务、表单等的NuGet软件包有关。然而,每当我更新它们时,整个解决方案中都会遗漏引用

任何帮助都将不胜感激

干杯


Eric R.

你能添加MapaGoogle代码吗?使用模拟器或真实设备进行测试。Live player不能与自定义渲染器一起使用。请参阅更多限制: