0
我正在尝试将googlemap添加到我的应用程序中,但无法使其正常工作。 我在xamarin btw上使用ViewPager。 布局:在Android应用程序中设置GoogleMap
...
<fragment
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:name="com.google.android.gms.maps.MapFragment" />
...
我的片段:
public class InfoFragment : FragmentV4, IOnMapReadyCallback
{
private GoogleMap mMap;
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
var view = inflater.Inflate(Resource.Layout.InfoFragment, container, false);
//Set up google maps coords in infos section
SetUpMap();
return view;
}
private void SetUpMap()
{
if (mMap == null) {
//((MapFragment)FragmentManager.FindFragmentById (Resource.Id.map)).GetMapAsync (this);
var mapFragment = (SupportMapFragment)Activity.SupportFragmentManager.FindFragmentById(Resource.Id.map);
mapFragment.GetMapAsync(this);
}
}
//Launching of the actual map
public void OnMapReady (GoogleMap googleMap)
{
//Setup cords and stuff...
}
}
在我的地图的设置。当我做
var mapFragment = (SupportMapFragment)Activity.SupportFragmentManager.FindFragmentById(Resource.Id.map);
它总是返回null。有人可以帮忙吗?