Have an amazing solution built in RAD Studio? Let us know. Looking for discounts? Visit our Special Offers page!
CodeDelphiRAD Studio

Using Tabbed Maps Visualization In A Windows App is Easy!

This visualization sample demonstrates the use of the TMapView class. We will show how to display and interact with the map, including:

  • Changing between two tabs that display different maps.
  • Showing the coordinates of the map center.
  • Zooming in and zooming out both maps.

Location Visualization

You can find the Tabbed Map sample project at:

  • Start | Programs | Embarcadero RAD Studio Sydney | Samples and navigate to:
    • Object PascalMulti-Device SamplesDevice Sensors and ServicesMaps
    • CPPMulti-Device SamplesDevice Sensors and ServicesMaps
  • Subversion Repository:
    • You can find Delphi and C++ code samples in GitHub Repositories. Search by name into the sample repositories according to your RAD Studio version.

Visualization with 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 Do We Use the Sample?

  1. Navigate to one of the locations given above and open:
    • Delphi: TabbedMapProject.dproj.
    • C++: TabMapProject.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.

To interact with the map:

  • Use the Saint-Pétersbourg and San Francisco tabs to change between the two maps.
  • Change the zoom using the Zoom out and Zoom in buttons.
  • Move the map and see the coordinates of the map center in the CameraInfo TLabel, at the button of the app.

Files

File in DelphiFile in C++Contains
TabbedMapProject.dprojTabMapProject.cbprojThe project itself.
TabbedMap.fmxTabbedMap.fmxThe main form where the components are located.
TabbedMap.pasTabbedMap.hTabbedMap.cppImplementation of the sample.

Maps Visualization Implementation

  • The sample uses TMapView to display and manage the maps.
  • TMapCoordinate is used to create the initial coordinates with the indicated latitude and longitude. Then, the center of the maps is set to such coordinates with the TMapView.Location property.
  • The TMapView.Zoom property is used to set the initial zoom of both maps to 10. This same property is also used to zoom in and zoom out both maps by adding or subtracting 1 to the Zoom property.
  • TMapView.OnCameraChanged updates the CameraInfo TLabel that indicates the Latitude and Longitude of the map Location.

If you want to check the original post, follow the link below:

http://docwiki.embarcadero.com/CodeExamples/Sydney/en/FMX.Tabbed_Map_Sample

Interested in developing Android and Windows applications with a map visualization on Delphi or c++ environments? Try the Windows UI Toolkit.


Reduce development time and get to market faster with RAD Studio, Delphi, or C++Builder.
Design. Code. Compile. Deploy.
Start Free Trial   Upgrade Today

   Free Delphi Community Edition   Free C++Builder Community Edition

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

IN THE ARTICLES