Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/236.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/google-maps/4.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
AndroidGms.Maps.MapFragment到Android.Views.View_Android_Google Maps_Xamarin_Mvvmcross - Fatal编程技术网

AndroidGms.Maps.MapFragment到Android.Views.View

AndroidGms.Maps.MapFragment到Android.Views.View,android,google-maps,xamarin,mvvmcross,Android,Google Maps,Xamarin,Mvvmcross,我试图在MVXFrament上添加一个映射,但得到以下错误 不存在来自的隐式引用转换 “AndroidGms.Maps.MapFragment”到“Android.Views.View” xml <fragment android:id="@+id/map" android:layout_width ="match_parent" android:layout_height ="match_parent" android:name="com.google.andro

我试图在MVXFrament上添加一个映射,但得到以下错误

不存在来自的隐式引用转换 “AndroidGms.Maps.MapFragment”到“Android.Views.View”

xml

<fragment
   android:id="@+id/map"
   android:layout_width ="match_parent"
   android:layout_height ="match_parent"
   android:name="com.google.android.gms.maps.MapFragment"/>

View.cs

public class MapView : MvxFragment<MapViewModel>, IOnMapReadyCallback
{
    private GoogleMap mMap;
    private View view;

    public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
    {

        var ignored = base.OnCreateView(inflater, container, savedInstanceState);
        view = this.BindingInflate(Resource.Layout.MapView, null);
        SetUpMap();
        return view;
     }

     private void SetUpMap()
     {
       if (mMap == null)
        {
         // the error appears here
         view.FindViewById<MapFragment>(Resource.Id.map).GetMapAsync(this);
        }
      }
 }
公共类MapView:MvxFragment,IOnMapReadyCallback { 私有谷歌地图; 私人视野; 创建视图上的公共覆盖视图(布局、充气机、视图组容器、捆绑包保存状态) { 忽略变量=base.OnCreateView(充气机、容器、savedInstanceState); 视图=this.BindingInflate(Resource.Layout.MapView,null); SetUpMap(); 返回视图; } 私有void SetUpMap() { 如果(mMap==null) { //错误出现在这里 view.findviewbyd(Resource.Id.map).GetMapAsync(this); } } }


更新:

如果使用
FragmentManager
ChildFragmentManager
,则会出现以下错误


片段不是视图,因此不能使用
FindViewById
方法。那么,你怎么找到你的碎片呢

您需要使用
FragmentManager
ChildFragmentManager
(我将让您确定在何种情况下使用哪一个)

然后,您可以调用
FindFragmentById
在FragmentManager上获取您的片段:

var mapFragment = FragmentManager.FindFragmentById<MapFragment>(Resource.Id.map);

使用带有Play Services的仿真器我已在设备上安装了APK,此错误消息不存在,但我无法看到地图,我只能在左下角看到谷歌图标。有什么问题吗?
var mapFragment = ChildFragmentManager.FindFragmentById(Resource.Id.map).JavaCast<MapFragment>();