Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/183.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用Xamarin在Android应用程序中显示Google地图_Android_Google Maps_Xamarin_Xamarin Studio - Fatal编程技术网

如何使用Xamarin在Android应用程序中显示Google地图

如何使用Xamarin在Android应用程序中显示Google地图,android,google-maps,xamarin,xamarin-studio,Android,Google Maps,Xamarin,Xamarin Studio,我正在用Xamarin设计一个android应用程序,里面会有一个带有谷歌地图的活动,但我很难显示地图。它显示一个没有地图显示的空框。以下是我用于此实践的代码 My Activity namespace teslin { [Activity(Label = "Map")] public class MpActivity : Android.GoogleMaps.MapActivity { protected override void OnCreate(

我正在用Xamarin设计一个android应用程序,里面会有一个带有谷歌地图的活动,但我很难显示地图。它显示一个没有地图显示的空框。以下是我用于此实践的代码

My Activity

namespace teslin
{
    [Activity(Label = "Map")]
    public class MpActivity : Android.GoogleMaps.MapActivity
    {
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
           SetContentView(Resource.Layout.MapView);
           var map = FindViewById<MapView>(Resource.Id.mapv);
           map.Clickable = true;
           map.Controller.SetZoom(16);
          map.Controller.SetCenter(new GeoPoint((int)40.8270449E6, (int)-73.9279148E6));
}}

xml lay out

        <LinearLayout
            android:orientation="horizontal"
            android:minWidth="25px"
            android:minHeight="25px"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/linearLayout3"
            android:layout_weight="9" />
        <com.google.android.maps.MapView
            android:id="@+id/mapv"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:enabled="true"
            android:apiKey="AIzaSyD-UMij5IO6ezjuFCNnF7tRoG3niaPbNEU" />
    </LinearLayout>
我的活动
名称空间特斯林
{
[活动(Label=“Map”)]
公共类MpActivity:Android.GoogleMaps.MapActivity
{
创建时受保护的覆盖无效(捆绑包)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.MapView);
var map=findviewbyd(Resource.Id.mapv);
map.Clickable=true;
map.Controller.SetZoom(16);
地图控制器设置中心(新地质点((内部)40.8270449E6,(内部)-73.9279148E6);
}}
xml布局

看起来您使用的是过时/过时的。谷歌去年取消了对此的支持

相反,你想使用(谷歌Play服务的一部分)。Xamarin在Android中有地图功能。让地图在Android中工作可能有点棘手,所以请仔细阅读这些文档。具体来说,你需要阅读


有一个演示如何使用添加地图到您的应用程序的示例。

对于那些正在寻找完整示例的人,请查看演示如何将Google地图与Xamarin Android集成的示例,希望这有帮助