Using TLocationSensor with TMapView in RAD Studio XE8

Posted by on in Data


During and after my Maps Skill Sprint last week, I received multiple questions on how to use TMapView with RAD Studio XE8. I thought I would create a new demo that showcases the following functionality to help answer those questions.

This demo showcases the following RAD Studio XE8 functionality:

You can download the demo here:




Gold User, Rank: 5, Points: 558
Senior Product Manager, RAD Studio


  • D. M23885
    D. M23885 Sunday, 30 October 2016

    Since its not possible to edit my post, allow me to make some correction on the questions would be great to know:

    1. How could we draw a continues line with when the location info is changing (user is moving), like a tracking thing?

    2. How could we remove the marker ?

    3. How can we write on the TMapView as simple text e.g. to show GPS signal AND with an augmented bar to add e.g. map type changes ?

    4. What extra coding need to be down to enable background location refresh and adding marker on the map (addition to add the Location service to the Version UIBackground services).

    5. Finally, how could we cache a given size area of the map, so it could be used even offline?

    And please kindly do a c++ example too, not only delphi.


    And sorry for the double post, just my accident sent the last message and not possible to edit it.

  • Sarina D
    Sarina D Thursday, 3 November 2016

    Hi D,

    Please see the answers below:

    1) Once Map objects have been created, they cannot be updated. If you need to change something, you will need to add it and remove the old instance.

    2) Removing the marker should be done by deleting its descriptor. You can find examples on how to delete markers by having a look at the maps sample shipping with the product as it includes marker deletion code.

    3) Drawing custom bitmaps (or text) on top of the map view is currently not supported. It may be possible to overlay something on iOS, but it would not work on Android at this point.

    4) There is no auto refresh in the maps. The location sensor component can be used to obtain location if available and it can be then used to center the map and/or to add markers.

    5) Caching is handled by the OS service. It is not something that’s exposed in the API. Newer versions of Google Maps for example ask the user if they want to do so and it's also available in the application options. But it's handled internally by each maps provider.

    Hope that helps.


  • D. M23885
    D. M23885 Sunday, 6 November 2016

    Dea Sarina,

    Thank you for your reply! It helped in many ways to drive me to the solution, except nr3. Since I am only interested in IOS, Android would not worry me. What i had found out, that overlay indeed possible on IOS, but you require native UIView component for it. There are companies out there have them, but I was hoped, that RAD Studio have some solution to avoid too many external components, that's why I asked. Anyway, till it will be supported, I wont go into this direction. ;)

    Allow me some more questions if possible:

    1. All your ios components are native, am I right? with other words, if I decide to go 100% into RAD Studio direction, and I will create an official app with it, then AppStore wont reject it with saying its not accepted as component are not native?

    2. Could you support us to post a small code snipet/example in C++ builder (so no delphi please...), what if we would compile to ios, the location update work in background of the ios device, please? (The "UIBackgroundModes" already added in Version (, but that's not enough and there is no CONCRETE example for this (what partial exist, is in Delphi), though many People looking for this example.
    Could you help us out with this?

    2. I am trying to accomplish to show a route track in whole length in 1 view. Any ide how to approach this? Maybe there is a concrete trick how to detect if a Marker is whithin the visible zoom level area of the Tmapview or soemthign better idea?

    3. Do you know any convenient way how is possible to shift TmapView by x / y axis? I would like to bear it with the orientationsensor, this is why I ask for your advise.

    4. Last but not least, may I ask if you could support us to post a small code snipet/example in C++ builder in which a concrete ios API call is initiated? For e.g. lets say we need to access 'horizontalAccuracy' (through CLLocationManager?). Again, many people in the community looking forward to see a sample like this.
    Could you help us out with this if possible?

    Many many thanks for your time and help, and sorry to ask so many questions, but I need to modell everything to decide on the app dev tool,

    Have a lovely day,


  • D. M23885
    D. M23885 Sunday, 30 October 2016

    Dear Sarina,

    May i ask if You could update this example, with:

    1. How could we draw a continues line with when the location info is changing (user is moving), like a tracking thing?
    2. How could we add a small image in the marker?
    3. How could we cache a given size area of the map, so it could be used even offline?

    BIG BIG thank you for your time, kindness and help,

    PS: personal dream : would be so great if an xample like this could have C++ Builder version too ? (I know that Delphi is very similar, but sometimes for an amateur like myself is pretty hard to "convert" between Delphi example and C++ Builder.

  • Dennies C54022
    Dennies C54022 Thursday, 7 December 2017

    Hi, D.,

    I got the same requirement as yours.

    I am trying to use TMapPolylineDescriptor to have the polyline on TMapView.
    Since I had made it work in Xcode + obj-c (MKMapView and MKOverlay), I believe
    that will work.

    I will try this way in couple hours, and if it works, I will provide the sample
    code to Sarina to share on community.

    Good luck.

  • Dennies C54022
    Dennies C54022 Tuesday, 12 December 2017

    Hi, D.,

    I had finished the code snippet, with TMapPolylineDescriptor, I added multiple points, and added the record with TMapView.AddPolyline, it works.

    I will set the procedures as an article in my blog later, and then I will upload the URL for sharing.

    Best Regard,

  • ApostolosT
    ApostolosT Wednesday, 17 June 2015

    Hi Sarina,
    The demo you provided doesn't work on Android. I run it, and after the splash screen the app crashes with no error or message of any kind.
    In fact, upon further investigation, the TMapView is the one to blame. Just dropping it on one of the forms of my existing mobile app, causes the app to crash, when I try to show this specific form. Removing the TMapView and the form loads as usual.
    The above is tested on a phone with 4.1.2 JellyBean and another phone with 5.1.1 Lollipop.

  • Sarina D
    Sarina D Wednesday, 17 June 2015

    Hi Apostolos,

    Did you generate the API key and set the correct Project->Options for Android? Please check the steps here: for details


  • Please login first in order for you to submit comments
  • Page :
  • 1

Check out more tips and tricks in this development video: