• Blog
  • How to Use Google Maps to Determine the User’s Location in Embarcadero Delphi FMX App

How to Use Google Maps to Determine the User’s Location in Embarcadero Delphi FMX App

Learn how to integrate Google Maps into an Embarcadero Delphi FMX app and display user locations with ease.

Publish date:
Discover more of what matters to you

Google Maps is widely used in a variety of applications, including web apps and mobile apps. It allows users to plan their routes between two points or learn how much time it will take to get to a particular destination (for example, walking or driving), and more.

Every mobile phone now has built-in GPS sensors to determine a user’s location. The user’s location is conveniently displayed on the map with a marker.

How do you request location permissions properly on Android? How do you embed Google Maps with full marker support in Delphi app?

In this article, we will demonstrate how to integrate Google Maps into an Embarcadero Delphi FMX app. We will also show how to retrieve the user’s location coordinates and display them on the map with a marker. 

Getting a Google API Key for Working with Google Maps

To use Google Maps in an Embarcadero Delphi FMX app, we need to get a Google API Key. Working with the Maps service without this key is not possible.

To get this key, follow the link https://console.cloud.google.com/getting-started?inv=1&invt=Abhk8w and click “Sign In.”

How to Use Google Maps to Determine the User’s Location Via Embarcadero Delphi FMX App


Select your Google account and log in with your credentials. 

How to Use Google Maps to Determine the User’s Location Via Embarcadero Delphi FMX App


Enter a password and click “Next.”

How to Use Google Maps to Determine the User’s Location Via Embarcadero Delphi FMX App


Create a new project.

Need expert help with your Delphi FMX app?
From Google Maps integration to real-time data, platform-specific permissions, and UX optimization, Softacom handles the hard parts so you can focus on your product.
Talk to Experts
How to Use Google Maps to Determine the User’s Location Via Embarcadero Delphi FMX App
How to Use Google Maps to Determine the User’s Location Via Embarcadero Delphi FMX App


Then, we create a name for a project and click “Create.”

How to Use Google Maps to Determine the User’s Location Via Embarcadero Delphi FMX App


The project has been successfully created.

How to Use Google Maps to Determine the User’s Location Via Embarcadero Delphi FMX App


We select the project from the list.

How to Use Google Maps to Determine the User’s Location Via Embarcadero Delphi FMX App
How to Use Google Maps to Determine the User’s Location Via Embarcadero Delphi FMX App
How to Use Google Maps to Determine the User’s Location Via Embarcadero Delphi FMX App


Then, click on the menu.

How to Use Google Maps to Determine the User’s Location Via Embarcadero Delphi FMX App


Select “APIs & Services” and “Enable APIs & Services.”

How to Use Google Maps to Determine the User’s Location Via Embarcadero Delphi FMX App


Click “Enable APIs and Services.”

How to Use Google Maps to Determine the User’s Location Via Embarcadero Delphi FMX App


Search for and select “Maps SDK for Android” as we are going to deploy the FMX app on the Android platform.

How to Use Google Maps to Determine the User’s Location Via Embarcadero Delphi FMX App


Click “Enable.”

How to Use Google Maps to Determine the User’s Location Via Embarcadero Delphi FMX App


Then, click “Agree & continue.”

How to Use Google Maps to Determine the User’s Location Via Embarcadero Delphi FMX App


Then, you can go through the verification process by inserting your credit card details, registration address, organization type and so on. This can help ensure a stable service operation. 

How to Use Google Maps to Determine the User’s Location Via Embarcadero Delphi FMX App

But you can also return to the project page without entering any personal data. 

If you revisit the “Maps SDK for Android” service activation tab, you’ll see that it has been successfully activated even without sharing a bank account or other personal data.

How to Use Google Maps to Determine the User’s Location Via Embarcadero Delphi FMX App


Now we should generate the Google API Key. To do this, we open the Navigational Menu.

How to Use Google Maps to Determine the User’s Location Via Embarcadero Delphi FMX App


Then, click “Credentials.”

How to Use Google Maps to Determine the User’s Location Via Embarcadero Delphi FMX App


Select “Create Credentials.”

How to Use Google Maps to Determine the User’s Location Via Embarcadero Delphi FMX App


Click “API Key.”

How to Use Google Maps to Determine the User’s Location Via Embarcadero Delphi FMX App


Wait for the key generation process to complete.

How to Use Google Maps to Determine the User’s Location Via Embarcadero Delphi FMX App


We have received an API Key. Copy and save it for further use in the Embarcadero Delphi FMX app.

How to Use Google Maps to Determine the User’s Location Via Embarcadero Delphi FMX App

Configuring the Embarcadero Delphi FMX App 

To work with Google Maps, we need to add the API Key to the configurations of our Embarcadero Delphi FMX app. To do that, go to Project > Options.

How to Use Google Maps to Determine the User’s Location Via Embarcadero Delphi FMX App


Then, select “Version info.”

How to Use Google Maps to Determine the User’s Location Via Embarcadero Delphi FMX App


Now, we simply paste the generated API Key into the apiKey field and click Save.

How to Use Google Maps to Determine the User’s Location Via Embarcadero Delphi FMX App


Also, to work with Google Maps on the Android platform, we enable the Maps Service. Go to the Entitlement List and check the box for Maps Service to set it to True. Then, click Save.

How to Use Google Maps to Determine the User’s Location Via Embarcadero Delphi FMX App


To determine the user’s location in the Delphi FMX app (Android platform), we need to check the box for Permissions Access Fine Location (precise location tracking using the smartphone’s built-in GPS sensor on Android). Also, we need to allow approximate location tracking via Wi-Fi and mobile communication towers (Access Coarse Location). To do that, simply check the corresponding box. Finally, click Save.

How to Use Google Maps to Determine the User’s Location Via Embarcadero Delphi FMX App


To display and interact with Google Maps in our Embarcadero Delphi FMX app, we use the TMapView component.

How to Use Google Maps to Determine the User’s Location Via Embarcadero Delphi FMX App


To determine the user’s coordinates (latitude and longitude), we use the TLocationSensor component.

How to Use Google Maps to Determine the User’s Location Via Embarcadero Delphi FMX App


We use the TSpeedButton button to switch between map types (normal, satellite or hybrid).

How to Use Google Maps to Determine the User’s Location Via Embarcadero Delphi FMX App

The TCheckBox component is used to enable or disable the TLocationSensor component. 

How to Use Google Maps to Determine the User’s Location Via Embarcadero Delphi FMX App

To determine the user’s location, the user should grant location access when the app starts on Android. We need to request permissions for both precise and approximate locations. To do this, we create two string fields for the permission requests. 

How to Use Google Maps to Determine the User’s Location Via Embarcadero Delphi FMX App


To ensure proper handling of permissions on the Android platform, the following libraries must be included.

How to Use Google Maps to Determine the User’s Location Via Embarcadero Delphi FMX App

In the OnShow method of the main form, we request permissions for both precise and approximate location access.

The AGrantResults array (of type TClassicPermissionStatusDynArray) contains the user’s response. The user can allow or deny the permissions. To display the user’s choice (granted or denied), we use the TJToast Java wrapper to show a message indicating their decision.

How to Use Google Maps to Determine the User’s Location Via Embarcadero Delphi FMX App


To change the map type (normal, satellite, or hybrid), we use event handlers for TSpeedButton

How to Use Google Maps to Determine the User’s Location Via Embarcadero Delphi FMX App

To track the user’s location, we handle the OnLocationChanged event. We will display the location using a marker. 

To do that, we declare a TMapMarker object. 

How to Use Google Maps to Determine the User’s Location Via Embarcadero Delphi FMX App


In the onCreate method of the main form, we will assign the value nil to our marker.

How to Use Google Maps to Determine the User’s Location Via Embarcadero Delphi FMX App


The TCheckBox onChange handler activates or deactivates the TLocationSensor based on its state. If the TCheckBox is checked, the sensor is activated; if not – deactivated.

How to Use Google Maps to Determine the User’s Location Via Embarcadero Delphi FMX App


In the onLocationChange method, we declare two local variables: MyMarkerDescr (of type TMapMarkerDescriptor) for the marker description and myLocation (of type TMapCoordinate) to store the user’s current coordinates.

How to Use Google Maps to Determine the User’s Location Via Embarcadero Delphi FMX App

Just in case, we redraw the TMapView to ensure the map is up to date. Then, check if there is already a marker on the map (FMyLocationMarker = nil).

If not, we update the user’s current coordinates (MyLocation := TMapCoordinate.Create(NewLocation.Latitude, NewLocation.Longitude)). 

Next, we set the center coordinates of our map (essentially passing the user’s location coordinates: MapView1.Location := MyLocation). 

Then, we create a description of the current location marker using a constructor. As parameters, we pass MyLocation and the marker name ‘I am here -:)’ (MyMarkerDescr := TMapMarkerDescriptor.Create(MyLocation,)).

To configure the marker’s description, we disable moving the marker on the map (Draggable := False). The marker will be visible on the map (Visible := True). Our marker will be three-dimensional (Appearance := TMarkerAppearance.Billboard). 

Also, the marker will contain longitude and latitude coordinates (Snippet := Format(‘Lat/Lon: %s,%s’, [FloatToStrF(NewLocation.Latitude, ffGeneral, 4, 2), FloatToStrF(NewLocation.Longitude, ffGeneral, 4, 2)]);).

After that, we add the marker to the map (FMyLocationMarker := MapView1.AddMarker(MyMarkerDescr)). 

Then, we increase the zoom level (MapView1.Zoom := 30). If the marker is already on the map, we remove it (FMyLocationMarker.Remove) and assign it the value nil (FMyLocationMarker := nil).

How to Use Google Maps to Determine the User’s Location Via Embarcadero Delphi FMX App


Also, we make our marker responsive to clicks (event TMapView OnMarkerClick). We implement the functionality for displaying the coordinates of the user’s location using TJToast. We identify our marker by its name (we declare the local string variable MarkerTitle).

How to Use Google Maps to Determine the User’s Location Via Embarcadero Delphi FMX App
Build smarter, faster Delphi FMX apps with Softacom
Our team of Delphi experts can help you integrate complex components with confidence.
Get in touch

Demonstrating the Work of the Embarcadero Delphi FMX App on the Android Platform

Let’s demonstrate the work of our Embarcadero Delphi FMX app on the Android platform. 

The request for current location determination. 

How to Use Google Maps to Determine the User’s Location Via Embarcadero Delphi FMX App


Switching the map type (normal, satellite, or hybrid).

How to Use Google Maps to Determine the User’s Location Via Embarcadero Delphi FMX App


Displaying the marker of the user’s current location.

How to Use Google Maps to Determine the User’s Location Via Embarcadero Delphi FMX App


Marker click processing.

How to Use Google Maps to Determine the User’s Location Via Embarcadero Delphi FMX App
Your business logic is what matters, and we’ll handle the tech
Softacom specializes in building custom Delphi FMX apps with complex integrations.
Review code

Subscribe to our newsletter and get amazing content right in your inbox.

This field is required
This field is required Invalid email address
By submitting data, I agree to the Privacy Policy

Thank you for subscribing!
See you soon... in your inbox!

confirm your subscription, make sure to check your promotions/spam folder

Get in touch
Our benefits
  • 17+ years of expertise in legacy software modernization
  • AI Migration Tool:
    faster timelines, lower costs, better accuracy (99.9%)
  • Accelerate release cycles by 30–50% compared to manual migration
  • 1–2 business day turnaround for detailed estimates
  • Trusted by clients across the USA, UK, Germany, and other European countries
Review
Thanks to Softacom's efforts, the solutions they delivered are already in use and have increased revenue streams.
  • Niels Thomassen
  • Microcom A/S
This field is required
This field is required Invalid email address Invalid business email address
This field is required
By submitting data, I agree to the Privacy Policy
We’ll reply within 24 hours — no sales talk, no spam