Using Supportmapfragment Instead Of Mapfragment
I am using Xamarin and I have modified the Google Maps API 2 sample to use SupportMapFragment objects rather than MapFragment objects. Can I have some help with the InitMapFragment
Solution 1:
SupportFramgentManager is inherited from FragmentActivity so make sure the activity extends FragmentActivity. Then modify your code as follows:
private void InitMapFragment()
{
_mapFragment = SupportFragmentManager.FindFragmentByTag("map") as SupportMapFragment;
if (_mapFragment == null)
{
GoogleMapOptions mapOptions = new GoogleMapOptions()
.InvokeMapType(GoogleMap.MapTypeNormal)
.InvokeZoomControlsEnabled(true)
.InvokeCompassEnabled(true);
FragmentTransaction fragTx = SupportFragmentManager.BeginTransaction();
_mapFragment = SupportMapFragment.NewInstance(mapOptions);
fragTx.Add(Resource.Id.mapWithOverlay, _mapFragment, "map");
fragTx.Commit();
}
}
Post a Comment for "Using Supportmapfragment Instead Of Mapfragment"