Map color when no internet connection

In my Android app, sometimes there will be no internet connection and therefore the map tiles won't be available. Currently the map is white. Is there a way of changing the color to something else? Setting the Map.Color property does not do it.


When there is no internet connection, you can use the LoadHTML call and use a body with a specific background color. There is currently no other way to control the background color.

Thanks Pieter.
I used the following to set the map background color.
Map.LoadHTML('< html>< body style="background-color: #d2ad8f;">< /body></ html>');
It works, but unfortunately I still want to plot polylines and markers while off-line. When setting this HTML, unfortunately the polylines and markers are not visible. With the default white screen (when there is no internet connection) then the polylines and markers can still be drawn.
I guess I'm stuck with a white screen while off-line unless there is another solution.


We have further investigated this here and you have 2 situations.

  • going offline while map has been loaded.
  • starting the application when offline.

In the first example, the map already loaded some tiles. when going offline, you'll see a default image with "sorry, we have no imagery here". Here the background color of those tiles can be changed, but only if the map has succesfully been initialized, which needs an internet connection. With the second approach, the map cannot be succesfully initialized and shows a blank DIV. This has different outcome depending on the browser, for Android, you can use the following code inside the FMX.TMSFNCMaps.GoogleMaps.pas unit:

function TTMSFNCMapsGoogleMaps.GetInitializeMap: string;
  Result :=
    '  ' + MAPOPTIONS + ' = {' + LB +
    '    draggable: ' + LowerCase(BoolToStr(MapsProperties.GetPanning, True)) + ',' + LB +
    '    scrollwheel: ' + LowerCase(BoolToStr(MapsProperties.GetZoomOnWheelScroll, True)) + ',' + LB +
    '    disableDoubleClickZoom: ' + LowerCase(BoolToStr(not MapsProperties.GetZoomOnDblClick, True)) + ',' + LB +
    '    mapTypeControl: ' + LowerCase(BoolToStr(MapsProperties.GetShowMapTypeControl, True)) + ',' + LB +
    '    backgroundColor: ''orange'',' + LB +
    '    zoomControl: ' + LowerCase(BoolToStr(MapsProperties.GetShowZoomControl, True)) + ',' + LB +
    '    fullscreenControl: false,' + LB +
    '    center: {lat: ' + MapsProperties.GetDefaultLatitude + ', lng: ' + MapsProperties.GetDefaultLongitude + '},' + LB +
    '    zoom: ' + MapsProperties.GetDefaultZoomLevel + LB +
    '  }'+ LB + LB +

    '  ' + MAPVAR + ' = new ' + MAPSERVICEVAR + '.Map(document.getElementById("' + MAPID + '"), ' + MAPOPTIONS + ');';

the added part is:

    '    backgroundColor: ''orange'',' + LB +

We'll see if we can add a property to control this, but this is currently Google Maps specific.

Hi Pieter. I have revisited this issue because I had not followed it up at the time and it has become an issue for our app once again.

The problem: Our android app is used in a vehicle. The users of our Android app may not have access to the internet, but the app still needs to be able to draw the path of the vehicle (polylines) as the vehicle moves. When there is no internet the Google map shows as completely white and nothing can be shown on the map. It appears that the map has not properly initialised.
In your previous response you suggested that a background color may be included in TTMSFNCMapsGoogleMaps.GetInitializeMap. I don't think that will fix the issue as it is not just that the map color is white. It does not show our direction arrow or any polylines. I note that in the latest source code that it now includes background color in GetInitializeMap.
Are you able to suggest a way of initializing the map properly (or making it work) without connecting to the internet?

Sorry, at this moment it isn't possible to initialize Google maps in an offline situation.
Also, you can't legally use the Google Maps Javascript API from local files without an Enterprise (Premier) license

See the terms of use.

My app eventually crashes when off line (after 5 minutes or so). This does not happen when it's on line. Do you have any suggestions why this may be happening and what I may be able to do to stop this?
I have an OnMapInitialized event handler but it seems to be called whether on line or not, suggesting that the map is initialized. Is there a way to determine if the TTMSFNCMapsGoogleMaps component has not Initialized (off line) and if so, how can I get it back to a stable state? I need to make the app not crash when off line, even if it is just a white screen for the map. Note that sometimes when off line the map is black instead of white and does then display my little direction arrow even though it is off line. It looks like it's in some sort of state where it's partially working.
Just to clarify your last point. I'm assuming you are saying that we would need the Enterprise license if we were to load map tiles from local files rather than live updates via the web. Is that correct?

Please note that the TTMSFNCGoogleMaps component expects a constant internet connection to function correctly.
It is unfortunately currently not supported to use TTMSFNCGoogleMaps offline.

You'll have to manually check if the internet connection is active on application level and disable the map if necessary.