TMSFNCOpenLayers - Problem with the movement of graphic elements

For many years I have used (among others) the TMS WebOSMaps components. I have used them in a number of applications. They worked perfectly and quickly. Unfortunately, they only used Android (Delphi 10.2) in SDK 14 (Android 4) and they can't run on new devices with Anroid 11+.
So I bought Delphi 11 and FNC Maps, reworked the source code from FMX components to FNC and was very disappointed. The resulting applications (for Android) are practically unusable and users refuse to use them:
Why: The static use of graphic elements is probably OK, but I use fast dynamic changes in the position of the markers (marker replaced by a circle due to the impossibility of using a local PNG) and this is practically impossible in the new version. What worked in the good old FMX version (even with local icons) is useless here. Requests to change the position of an element are queued somewhere in memory and nothing happens. After a while, the marker starts to move jerkily and in a few seconds it appears somewhere. It is interesting that the whole map can be moved practically in real life, and on the other hand, any graphic element (Marker, Circle, Rectangle ..) has such a huge delay.
If I compile the same project for windows, everything is OK and the response is fast enough.

Am I making a mistake somewhere, or is it a feature of the FNC version?

I enclose a test program where it is clearly visible. (by moving the trackbar)
The "Map Move" option moves the map, the "Point Move" option changes the coordinates of the point, and the "Point Cre" option deletes the old one and creates a new point.
When you select the "Point Cre" option and move the trackbar several times from one side to the other, the program crashes (memory will probably run out).
Can a program with such features be offered to users?
FNCMapTest.zip (8.3 KB)

We have investigated the sample. We noticed an underlying Android specific performance issue. We are currently looking for a solution.

Thank you for answer. So hopefully it will be fixed. :grinning:

Hi,

We have applied a fix for the performance during updating an element on the map. However, the issue with removing a circle and re-adding it remains. We'll allocate more time to further investigate this issue.

This is good news. Thank you for a quick response.

Hi,

We are currently still investigating the issue with adding and removing elements dynamically, however to avoid performance issues and flickering, we recommend to use the approach of adding the circle, and updating the same circle instead of adding and removing it continuously. It makes no sense to do this unless you have some specific requirements?

We have meanwhile found a memory leak related to assigning event handlers to an element, that are not properly cleaned up, we are currently investigating a solution. Note that this happens only on OpenLayers, due to the specific implementation of event handlers for that service.

Memory leak is fixed! Next version will have this included.

Hi,

Thank you for the information.

Of course - adding and removing one particular circle was intended as a demonstration of non-functional synchronization of individual application layers.

If you manage to solve the problem of faster element movement such as circle, square and so on, then everything will be OK.

Why I use circles: - because using markers (and especially in the Android environment) is practically impossible.

Reasons: You certainly know that local icons cannot be used in the Android environment (LocalFileAccess is not enabled for Android). So you can only use icons from a website (http ...) for markers, which is logical for an application running on a web server, but illogical for an application running locally on a separate device.

I tried to use my icon server and it worked on an older Android.
However, no icons will be displayed on Android 11 devices (any new permissions ??) !! The marker is created, exists, but is invisible ...

Where the icons appear, they have a fixed position and the icon offset cannot be set. (for the good old WebOSMaps, I rewrote MapMarkerToJS and added Yoffset and Center for the icon).

Therefore, in order to be able to upgrade my application from Delphi10.2 + TMSFMXWebOSMaps to Delphi11 + TMSFNCOpenLayers, I use rings instead of markers, the size of which I adjust according to the zoom level.

So in conclusion, if I could wish for some practical modifications to the graphic elements on OL in the Android environment:

  • Enabling local icons for markers.
  • Add the option to set YOffset and possibly Center to the marker
  • Allow fast movement for all elements (Marker, Circle, Rectangle, Polygon ...)

Hi,

We can confirm the issue with moving markers & elements of any kind is fixed as well as the memory leak which eventually led into a crash. For the local marker icons, you can easily convert your icon to a base64 string and then use this as a parameter for the marker. Using a base64 string can be used for every platform. So for the code part:

b64 := TTMSFNCUtils.FileToBase64('MyFile.jpg');

or

  bmp := TTMSFNCBitmap.CreateFromFile('MyFile.jpg');
  b64 := TTMSFNCUtils.SaveBitmapToBase64(bmp);

Thank you very much. I'll try it as soon as I can.
Have a nice day :-)

1 Like