Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TWebbrowser very slow to load real time markers from local google map HTML

I am actually displaying every 2 seconds many real time GPS points (20) by showing it from an index.html (using google maps to display and treat points) in my TWebBrowser, and it slows a lot my app.

And as i got another module under the same application allowing me to enter data in my database, it freezes usually my app.

I know Threads are made for that, but i am not sure that it will solve my problem. Any ideas ???

Thanks Gwenael

PS : did the fact that i am loading my javascript code from an external file (and not the source code loadead in my delphi application), can slow my app ?

like image 441
Gwenael Avatar asked Oct 10 '22 02:10

Gwenael


1 Answers

If you get your javascript from an external file it will get cached, so no, that probably won't slow you down much, except for the first time maybe.

Probable causes for slowness, and suggestions to speed things up:

  • TWebBrowser wraps Internet Explorer, which is not exactly famous for its raw speed when it comes to this type of task; If you want fast JavaScript handling, consider DelphiChromiumEmbedded

  • If you draw a marker every two seconds, you'll have to draw 1800 markers for a one-hour drive. If you want to show multiple trips, it's just going to be a heavy task to draw all the icons with alpha-transparency and all.

I usually draw a marker (arrow with driving direction) every 2 minutes, or if more than 200m has been travelled since the last marker. That way you don't have to draw a whole cloud of markers when a car is standing still.

You can use douglas-peucker algorithm to simplify the line. As a parameter you'll give a maximum error that you allow in the line, and it'll remove as many points as possible without exceeding that error. So, when you have a straight line, it'll remove all points between the edges.

Also, you can consider clustering points at certain zoomlevels. If you would use OpenLayers instead, it would be easier, but with the help of the Google Maps Util Library you can do the same with Google Maps (Example). If you zoom out, it's a bit useless to draw 2000 overlapping icons on an area of 10x10 pixels.

If you show me your code, I can give you some more direct advice on how to speed things up.

like image 124
Wouter van Nifterick Avatar answered Oct 14 '22 04:10

Wouter van Nifterick