Location and Maps

Last modified: August 20, 2024

Introduction

The Maps module allows you to work with maps. Consult the instructions below to include map capabilities in your native mobile apps.

Prerequisites

  • Complete the Prerequisites section of Deploying Native Apps
  • Create an app on the Google Cloud Console and have Google Maps enabled for Android (and iOS, if you wish to use Google Maps on iOS as well) and also posses an API key.
  • Before you can start using the Google Maps Platform APIs and SDKs, you must sign up and create a billing account.
  • Install Mendix Studio Pro 8.15.0 and above to use the Native Mobile App Builder

Setting Up the Maps Module

Make sure you have app containing the Maps module. This is a core module, so it is available in the Widgets panel. You can either add it to an existing app or make a new app from scratch.

Configuring Map Provider

Next you will configure the Maps widget provider. You will have two choices: Default and Google Maps. Selecting Default will have your app use the default-enabled map on your device. This means using Google Maps on Android devices and Apple Maps on iOS devices. Selecting Google Maps as your Maps configuration will have only Google Maps used on both platforms:

  1. Double-click your Maps widget and Selecting the Map tab.

  2. Select either the Default or Google Maps provider:

    maps provider configuration

Configuring Maps Capability

  1. Set up a native template with the Native Mobile App Builder. This can be launched from the App menu as shown in Build a Mendix Native App Locally. Complete the wizard and configure the app’s details and tokens:

    launch native mobile builder
  2. Once done with the wizard, select the Capabilities menu item:

    capability menu option
  3. Enable the maps capability. This exposes a set of configurations:

    maps input fields
    • As described in the Prerequisites section, the API key gives the maps widget access to Google Cloud services
    • The Purpose for maps string is a specialized text that tells Apple why you need to use maps in your app (Apple requests explanation as maps use device location data)
    • I want to use Apple Maps for iOS mirrors the decision explained in the Configuring Map Provider section above
  4. Click the Save button.

  5. Navigate to the build page then click Build.

Read More