Select to view content in your preferred language

Esri.ArcGISRuntime.Xamarin.Form - MapView

1878
4
Jump to solution
05-19-2017 08:25 AM
JimFiddes
Regular Contributor

I'm developing a mobile product utilizing Esri.ArcGISRuntime.Xamarin.form nuget package and I'm having trouble adding a MapView to a Xamarin.Forms.AbsoluteView container. When I look at the documentation I see the mapview inherits from Xamarin.forms.view however when I go to add this child I'm receiving a message that the view is not what it needs to be. In VS2015 when I follow out the definitions of a mapview it takes me to Android.Views.View.

***************CODE SNIPPET***************

using Esri.ArcGISRuntime;
using Esri.ArcGISRuntime.Geometry;
using Esri.ArcGISRuntime.Mapping;
using Esri.ArcGISRuntime.Symbology;
using Esri.ArcGISRuntime.UI;
using Esri.ArcGISRuntime.UI.Controls;
using Xamarin.Forms;

public class MapControlView : ContentPage
{
  // Create and hold reference to the used MapView
  private MapView _myMapView = new MapView();

  private void CreateLayout()
  {
    Xamarin.Forms.AbsoluteLayout simpleLayout = new Xamarin.Forms.AbsoluteLayout
    {
      VerticalOptions = LayoutOptions.FillAndExpand
    };
    simpleLayout.Children.Add(_myMapView);
    // Show the layout in the app
    this.Content = new StackLayout
    {
      Children = {simpleLayout}
    };
  }

}

0 Kudos
1 Solution

Accepted Solutions
dotMorten_esri
Esri Notable Contributor

Note that you're getting two MapView controls: You get the native Android Esri.ArcGISRuntime.UI.Controls.MapView control which is to be used in native non-forms Xamarin Android apps, and you get Esri.ArcGISRuntime.Xamarin.Forms.MapView which should be used in Xamarin.Forms apps.

View solution in original post

4 Replies
AlexanderNohe1
Honored Contributor

Moved this to the .NET stream rather than the Android stream as the Android stream refers to the native Android runtime.

JimFiddes
Regular Contributor

Thanks, seems like a blurry line with Xamarin now.

0 Kudos
AlexanderNohe1
Honored Contributor

I agree.

0 Kudos
dotMorten_esri
Esri Notable Contributor

Note that you're getting two MapView controls: You get the native Android Esri.ArcGISRuntime.UI.Controls.MapView control which is to be used in native non-forms Xamarin Android apps, and you get Esri.ArcGISRuntime.Xamarin.Forms.MapView which should be used in Xamarin.Forms apps.