我是Xamarin.forms的新手,需要使用UWP平台的地图。我已经在我的PCL中安装了Xamarin.Forms.Maps nuget包。并调用了UWP部分的App.xaml.cs中的init函数,如下所示:
Xamarin.Forms.Forms.Init(e);Xamarin.FormsMaps.Init("TokenKey");
但是,地图在部署时不可见。我也添加了一些引脚,我看到的是一些带有引脚的蓝屏。我尝试了很多选择,但还没有找到任何机会。下面是调用map的代码片段:
Map map = new Map(MapSpan.FromCenterAndRadius(new Position(51.5074, 0.1278), Distance.FromMiles(10)));
map.MapType = Xamarin.Forms.Maps.MapType.Hybrid;
map.HeightRequest = 700;
map.WidthRequest = 725;
map.IsShowingUser = true;
var position1 = new Position(51.5033, 0.1195);
var pin1 = new Pin { Type = PinType.Place, Position = position1, Label = "label1", Address = "address1" };
map.Pins.Add(pin1);
var position2 = new Position(51.5014, 0.1419);
var pin2 = new Pin { Type = PinType.Place, Position = position2, Label = "label1", Address = "address1" };
map.Pins.Add(pin2);
this.mapGrid.Children.Add(map);我做错什么了吗?或者,是否有任何我应该添加的缺失引用才能使其正常工作?请帮帮我。附注:同样的解决方案在我同事的机器上加载地图,但在其他机器上不起作用。
向您致敬,Swati
请在下面找到我的UWP参考的屏幕截图:UWP reference screenshot
发布于 2017-05-07 00:12:56
您需要使用System.Reflection添加此解决方案才能工作。
对于一些框架和UWP来说,这似乎是一个已知的挑战。在UWP项目的App.Xaml.cs中,在OnLaunched事件中,在以下代码行之后:
rootFrame.NavigationFailed += OnNavigationFailed;添加列表assembliesToInclude = new List();
//Now, add all the assemblies your app uses
assembliesToInclude.Add(typeof(Syncfusion.SfRating.XForms.UWP.SfRatingRenderer).GetTypeInfo().Assembly);
assembliesToInclude.Add(typeof(Xamarin.Forms.Maps.UWP.MapRenderer).GetTypeInfo().Assembly);
Xamarin.Forms.Forms.Init(e, assembliesToInclude);确保这里显示的...Forms.Init行替换了代码中对初始化器的保存现有调用。
发布于 2019-06-02 18:44:05
您需要在google API控制台上启用Google地图API
https://stackoverflow.com/questions/40736370
复制相似问题