ARCGis Xamarin - MapView from previous page displays after navigating to new page

Viewed 333

I have a 'main' map page from which the user can either add data to the map or click on existing data to see the details. This is done with PushModalAsync() where I navigate to a new page. My problem is in both of those new pages I have a new map with a new MapView that is 'underneath' the MapView from the 'main' page. Both the MapView and Map itself are new objects on the secondary pages.

After navigating to my new pages, the previous MapView shows in the area of the screen where it existed (on 'main' page) where my new MapView also exists. In other words, on my new map pages my map is laid out differently and partially sits higher in the layout than the 'main' map does. The part that sits higher is the only part of the new map that is visible and I can interact with. The part that sits on the same area is the 'main' map view and I cannot interact with it and it blocks my new map.

I tried this with PushAsync as well (not modal) and nothing changed. How is one supposed to have multiple maps in an app across multiple pages? Is this even possible with ArcGIS? This app used to be with Google Maps/Apple and the exact same layout worked just fine.

My main map page in yellow is the area where my future map, in a new page, is supposed to display

My new page, with new MapView and new map, covered by previous map

Edit: Code here (with irrelevant parts removed) This page is navigated to from another page with a map on it wherein this map is covered if it is laid out in the same area of the first map. From this page I navigate to a 3rd page where both maps show up. Removal works successfully, however when I try to add I get an error saying I cannot add a null child to a view group:

public partial class EventDetails : ContentPage
{
    public Xamarin.Forms.Grid MapGrid = new Xamarin.Forms.Grid()
    {
    RowDefinitions =
    {
        new RowDefinition { Height = 220 },
        new RowDefinition { Height = GridLength.Auto }
    },
    ColumnDefinitions =
    {
        new ColumnDefinition { Width = 500 }
    },
    HorizontalOptions = LayoutOptions.Center
    };
    public Map DetailMap;
    public MapView MyDetailMapView = new MapView();

    public EventDetails(MapLog eventDetails, string strMapType)
    {    
        DetailMap = new Map(BasemapType.ImageryWithLabels, eventDetails.Latitude, eventDetails.Longitude, iMapDetail);
        MyDetailMapView.Map = DetailMap;
        MyDetailMapView.ViewpointChanged += MyMapView_ViewpointChanged;
        var scrollView = new ScrollView
        {
            Content = mainStack
        };
        MapGrid.Children.Add(MyDetailMapView, 0, 0);
        MapGrid.Children.Add(scrollView, 0, 1);
        Content = MapGrid;
    }

#if __ANDROID__ 
protected override void OnAppearing()
{

    if (!MapGrid.Children.Contains(MyDetailMapView))
    {
        try
        {
            MapGrid.Children.Add(MyDetailMapView);
        }
        catch (Exception ex)
        {
            DisplayAlert("Err", ex.Message, "Ok");           
        }

    }
    base.OnAppearing();

 }

protected override void OnDisappearing()
{
    if (MapGrid.Children.Contains(MyDetailMapView))
        MapGrid.Children.Remove(MyDetailMapView);
    base.OnDisappearing();
}
#endif
}

EDIT*: I updated my Xamarin Forms version and ARCGIS Runtime and now the solution to remove/add the map does work without issue.

1 Answers
Related