简体   繁体   English

在Xamarin.Forms for Android上使用Google地图

[英]Using Google Maps on Xamarin.Forms for Android

So we need to create an app that renders a map and we are currently using Xamarin.Forms to integrate it. 所以我们需要创建一个呈现地图的应用程序,我们目前正在使用Xamarin.Forms来集成它。 However, we will not use Xamarin.Forms.Maps since we have to use the Google Maps API for iOS and not its native map which is MapKit. 但是,我们不会使用Xamarin.Forms.Maps,因为我们必须使用适用于iOS的Google Maps API而不是使用MapKit的原生地图。

My question is, how do I integrate this component https://components.xamarin.com/view/googleplayservices-maps in Xamarin.Forms? 我的问题是,如何在Xamarin.Forms中集成此组件https://components.xamarin.com/view/googleplayservices-maps

Read this guide https://docs.xamarin.com/guides/xamarin-forms/user-interface/map/ 阅读本指南https://docs.xamarin.com/guides/xamarin-forms/user-interface/map/

Control Map uses your map for each platform 控制图使用每个平台的地图

Android - Google Maps Android - 谷歌地图

iOS - Apple Maps iOS - Apple Maps

Windows Phone - Bing Maps Windows Phone - Bing Maps

To map must be worked for each platform to add key map, all of writing, good luck! 要映射必须为每个平台工作添加关键地图,全部写作,祝你好运!

You can inject Google Map (for Android or iOS) to Xamarin.Forms's view. 您可以将Google Map(适用于Android或iOS)注入Xamarin.Forms的视图。

Example in Android: Android中的示例:

public class AndroidMapRenderer : ViewRenderer
{
    protected override void OnElementChanged(ElementChangedEventArgs<View> e)
    {
        base.OnElementChanged(e);

        var mapView = new Android.Gms.Maps.MapView(Context);
        SetNativeControl(mapView);
    }
}

This way is "custom renderer". 这种方式是“自定义渲染器”。

Please read these: 请阅读以下内容:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM