簡體   English   中英

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

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

所以我們需要創建一個呈現地圖的應用程序,我們目前正在使用Xamarin.Forms來集成它。 但是,我們不會使用Xamarin.Forms.Maps,因為我們必須使用適用於iOS的Google Maps API而不是使用MapKit的原生地圖。

我的問題是,如何在Xamarin.Forms中集成此組件https://components.xamarin.com/view/googleplayservices-maps

閱讀本指南https://docs.xamarin.com/guides/xamarin-forms/user-interface/map/

控制圖使用每個平台的地圖

Android - 谷歌地圖

iOS - Apple Maps

Windows Phone - Bing Maps

要映射必須為每個平台工作添加關鍵地圖,全部寫作,祝你好運!

您可以將Google Map(適用於Android或iOS)注入Xamarin.Forms的視圖。

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);
    }
}

這種方式是“自定義渲染器”。

請閱讀以下內容:

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM