Microsoft.maui.ipropertymapper-类型''不能用作类型参数...没有隐式转换
我正在尝试获取地图上的.NET MAUI并找到了这篇博客文章(链接到官方毛伊岛博客)。 https://www.cayas.de/blog/blog/dotnet-maui-blog/dotnet-maui-maui--定制映射处理程序 我已经在博客结束时下载了链接的回购,但我无法运行它。
在博客文章中,Maphandler代码看起来像这样:
public static IPropertyMapper<IMap, MapHandler> MapMapper = new PropertyMapper<IMap, MapHandler>(ViewMapper)
{ };
但是在回购中,它看起来像:
public static IPropertyMapper<MapView, MapHandler> MapMapper = new PropertyMapper<MapView, MapHandler>(ViewMapper)
{ };
哪一个对我不起作用,因为我在下面收到错误(在运行时)。
The type 'MapControlDemo.Handlers.MapHandler' cannot be used as type parameter 'TViewHandler' in the generic type or method 'PropertyMapper<TVirtualView, TViewHandler>'. There is no implicit reference conversion from 'MapControlDemo.Handlers.MapHandler' to 'Microsoft.Maui.IElementHandler'
有什么想法吗?我联系了作者,他建议这可能是我的毛伊岛版本,因为它对他有用,但我最新。
I'm trying to get maps to work on .net MAUI and found this blog post (linked to from the official MAUI blog). https://www.cayas.de/blog/dotnet-maui-custom-map-handler
I've downloaded the repo linked at the end of the blog but I can't get it to run.
In the blog post the MapHandler code looks like this:
public static IPropertyMapper<IMap, MapHandler> MapMapper = new PropertyMapper<IMap, MapHandler>(ViewMapper)
{ };
But in the repo it looks like this:
public static IPropertyMapper<MapView, MapHandler> MapMapper = new PropertyMapper<MapView, MapHandler>(ViewMapper)
{ };
Neither of which work for me, as I get the error (at runtime) below.
The type 'MapControlDemo.Handlers.MapHandler' cannot be used as type parameter 'TViewHandler' in the generic type or method 'PropertyMapper<TVirtualView, TViewHandler>'. There is no implicit reference conversion from 'MapControlDemo.Handlers.MapHandler' to 'Microsoft.Maui.IElementHandler'
Confusingly there are another couple of errors that shouldn't be errors??
Any ideas? I contacted the author and he suggested it could be my maui version as it works for him, but I'm on the latest.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
也许作者正在Mac上建造。
我已经确认,在Windows上构建的尝试导致构建错误。 VS版本17.3.0预览1.1
但是,我得到的错误是
,我能够在Android上运行 - 通过选择Android模拟器作为目标(因此使用
net6.0 android
)并按F5-因此,该错误是误导的。鉴于这仅在iOS和Android上实现,我建议编辑
.csproj
以删除Windows
平台。我还删除了MacCatalyst(也许可以使用,但我要进行最简单的测试):更改:
到:
然后我能够建造。
注意:在不添加Google Maps ID的情况下,当在Android上运行时,结果是一个空的地图。
tl; dr 最简单的测试方法是在Mac上,定位iOS。
Perhaps the author was building on a Mac.
I've confirmed that an attempt to build on Windows results in a build error. VS Version 17.3.0 Preview 1.1
The error I got was
HOWEVER, I was able to RUN on Android - by selected an Android emulator as target (so using
net6.0-android
) and pressing F5 - therefore that error is misleading.Given that this is only implemented on iOS and Android, I recommend editing
.csproj
to REMOVEWindows
platform. I also removed MacCatalyst (maybe that would work but I was going for simplest test):Change:
To:
Then I was able to build.
NOTE: Without adding a Google Maps ID, when ran on Android, the result was an empty map.
tl;dr Easiest way to test is on a Mac, targetting iOS.