AnsweredAssumed Answered

Need help with compass on Xamarin Android map

Question asked by jcolaneri.CALFIRE on Apr 22, 2020
Latest reply on Apr 27, 2020 by jcolaneri.CALFIRE

I'm trying to figure out how to put a compass on a map view in a xamarin android application. I wrote (copied from your github example) this code, and went as far as to create a compass.png file in the Drawables resource directory.

 

In the Activity:

            _compass = FindViewById<Compass>(Resource.Id.compass);

            _compass.GeoView = _mapFrag.MyMapView;

            _compass.AutoHide = false;

 

and

 

In compass.axml:

 

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"

    android:orientation="vertical"

    android:layout_width="match_parent"

    android:layout_height="match_parent">

    <Esri.ArcGISRuntime.Toolkit.UI.Controls.Compass

        android:layout_width="30dp"

        android:layout_height="30dp"

        android:layout_alignParentRight="true"

        android:layout_alignParentTop="true"

        android:layout_marginTop="20dp"

        android:layout_marginRight="20dp"

        android:id="@+id/compass" />

</RelativeLayout>

 

I'll be the first to admit that markup is not my forte. I've been scouring the Internet for documentation (I know, it's a dirty word). I've come up with a bunch of sites and documents that brag about a Compass control, and a github with compass code drowning in some larger (demonstration) project that I can't sort out.

 

The FindViewById returns null.

 

env:

VisualStudio 19 / Windoze 10 / Xamarin Android

Esri.ArcGISRuntime => v100.6.0

Esri.ArcGISRuntime.Toolkit => v100.4.0

Esri.ArcGISRuntime.Xamarin.Android => v100.6.0

(note: I tried at some point in the past to bring all the libraries up to date, and it broke something else in the project)

 

Any help working this out would be appreciated. Thanks.

Outcomes