FMX.Map Sample

From RAD Studio Code Examples
Jump to: navigation, search

This sample shows how to use maps in a Delphi/C++ application.


You can find the Map sample project at:

  • Start | Programs | Embarcadero RAD Studio Alexandria | Samples and navigate to:
    • Object Pascal\Multi-Device Samples\Device Sensors and Services\Map Type Selector
    • CPP\Multi-Device Samples\Device Sensors and Services\Map Type Selector
  • Subversion Repository:
    • You can find Delphi and C++ code samples in GitHub Repositories. Search by name into the samples repositories according to your RAD Studio version.


The sample demonstrates the use of the TMapView class. The sample shows how to display and interact with the map, including:

  • Changing to different map types: Normal, Satellite and Hybrid.
  • Centring the map using a given coordinate.
  • Rotating the map.
  • Working with map markers.

Using Google Maps on Android

If you are running this sample on Android, in order to access the Google Maps servers, you have to add a Maps API key to the sample. To acquire the API key and add it in the sample you need to follow these configuration steps:

How to Use the Sample

  1. Navigate to one of the locations given above and open:
    • Delphi: Map_ObjectPascal.dproj.
    • C++: map_cpp.cbproj.
  2. If you are running the sample on Android, ensure you first follow the steps indicated in Using Google Maps on Android
  3. Before you run the sample, ensure the device is connected to the Internet.
  4. Press F9 or choose Run > Run.
  5. When you run the sample, the TMapView loads the map.
Map Sample.png
To interact with the map:
  • Use the Normal, Satellite and Hybrid TSpeedButtons to change among the different map types.
  • Write latitude and longitude map coordinates, and click the Go button to move the center of the map to the indicated coordinates.
  • Rotate the map up to 180 degrees using the TTrackBar.
  • Click on a point in the map to add a map marker.
  • Long-click on a marker to drag that marker.


File in Delphi File in C++ Contains



The project itself.



The main form where the components are located.


Unit1.h, map_cpp.cpp

Implementation of the sample.



See Also