In this tutorial, we will guide you step by step to set up your first application using Situm Wayfinding Module. We have also prepared a sample app that shows how to use the Situm Wayfinding Module in different situations.
Configure the WYF module in your Android project #
First of all, you must include the Wayfinding Module in your Android project. To do this, first of all you should add the maven repository either to your project’s “build.gradle” file (for Gradle versions <=6) or to your “settings.gradle” file (for Gradle versions >7).
//Add this to your Project's "build.gradle" file allprojects { repositories { maven { url "https://repo.situm.es/artifactory/libs-release-local" } } }
//Add this to your Project's "settings.gradle" file dependencyResolutionManagement { repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) repositories { google() mavenCentral() maven { url = "https://repo.situm.com/artifactory/libs-release-local" } } }
Then add the Situm WYF library dependency to the “build.gradle” file (to the individual module file, not to the project’s “build.gradle” file). You must specify your desired SDK version (see Changelog for details) and add the transitive = true property to download the Situm SDK dependencies.
//Add this to your module's "build.gradle" file dependencies { ... implementation ('es.situm:situm-wayfinding:X.Y.Z-alpha@aar') { transitive = true } }
Set your Situm credentials #
There are two ways to set the Situm credentials, in the AndroidManifest.xml file or programmatically.
Option 1: AndroidManifest.xml #
You can set the credentials (user and API key) in the AndroidManifest.xml file adding the next meta-data fields:
<?xml ...> <manifest ...> <application ...> <meta-data android:name="es.situm.maps.API_USER" android:value="SITUM_USER_EMAIL" /> <meta-data android:name="es.situm.maps.API_KEY" android:value="SITUM_API_KEY" /> ... <activity ...></activity> </application> </manifest>
Option 2: Programmatically #
In the code, you can set the the user and API key with:
librarySettings.setApiKey("SITUM_USER_EMAIL", "SITUM_API_KEY");
or you can set the user and password with:
librarySettings.setUserPass("SITUM_USER_EMAIL", "SITUM_PASSWORD");
Configure Google Maps #
Situm WYF uses Google Maps as a base layer, on top of which everything else is drawn: floorplans, routes, user’s location… More concretely, it uses the Dynamic Maps service, which has a generous free tier.
First, you should create an API Key for your project. Then, add the API Key to your “AndroidManifest.xml” file:
<?xml ...> <manifest ...> <application ...> <meta-data android:name="com.google.android.geo.API_KEY" android:value="GOOGLE_MAPS_APIKEY" /> ... <activity ...></activity> </application> </manifest>
Other configurations #
Android Pie Devices #
If you are targeting Android Pie devices, add Apache Http Legacy to your “AndroidManifest.xml”:
... <application ...> <uses-library android:name="org.apache.http.legacy" android:required="false"/> <application/> ...
Toolbar #
By default, the wayfinding library will include a “ToolBar” that implements a POI search feature. In order to work, you should either tell your activity or app theme that you already have a Toolbar by adding these lines to your “themes.xml”
<resources ...> <style ...> ... <item name="windowNoTitle">true</item> <item name="windowNoTitle">true</item> ... </style> </resources>
or remove the Situm search Toolbar by setting to “false” the “situm_has_search_view” property of your “SitumMapView” (see next Section to know what the SitumMapView is):
<es.situm.wayfinding.SitumMapView ... app:situm_has_search_view="false" />
Add SitumMapView #
In your layouts/activity_main.xml file declare the SitumMapView:
... <es.situm.wayfinding.SitumMapView android:id="@+id/map_view" android:layout_width="match_parent" android:layout_height="match_parent" /> ...
That’s it! You will be able to build and run this app. Try it out and for more advanced uses, go to our sample app in Github.