Recent

Author Topic: LazMapViewer Get Positions from Track  (Read 1834 times)

Dzandaa

  • Sr. Member
  • ****
  • Posts: 250
  • From C# to Lazarus
LazMapViewer Get Positions from Track
« on: August 18, 2021, 05:02:53 pm »
Hi,

Using Lazarus 2.0.12 on Windows, Mac, Linux

I'm Translating one of My program written in C# to Pascal Lazarus.
I use that program to visualize walks we've made with friends.

I'm using LazMapViewer and have 2 GPS Objects
Code: Pascal  [Select][+][-]
  1.    Track: TGpsTrack; // show the path of the track.
  2.    CurPos: TGpsPoint; // Show a Cursor

For now, all is O.K., I can load the path from a .CSV file and display it and also the Cursor at the start of the path.

Code: Pascal  [Select][+][-]
  1.  Track.Name := 'CSV';
  2.  Map.GPSItems.Add(Track, ID);
  3.  CurPos.Name:= 'Pos';
  4.  Map.GpsItems.Add(CurPos, _CURSOR_);

My problem:
 I want CurPos to follow the Track with a timer.
But I don"t know how to get the Track positions back from
Map.GPSItems and set CurPos to a new value.

Any idea?

Thank you.

P.S. I found the solution by myself, thank you.

« Last Edit: August 19, 2021, 04:17:35 pm by Dzandaa »
Dzandaa

wp

  • Hero Member
  • *****
  • Posts: 11916
Re: LazMapViewer Get Positions from Track
« Reply #1 on: August 20, 2021, 03:33:39 pm »
This is an interesting topic... Therefore I made some of the built-in functions a bit more user-friendly and added a new demo "trackdemo" which loads a gpx file and uses a separate GPSPoint which moves along the track, either triggered by a timer or by a user-click on the points in a points grid.

The timed motion of the track is flickering to some extent. This can be avoided by turning of the "UseThreads" property - the advantage is some waiting time at first program start until the map tiles have arrived from the map server.

Have a look at the CCR version of LazMapViewer to get this new code (it is not yet contained in the OPM release).

When writing this new demo I noticed that GPS points can only be displayed by a single loaded bitmap (POIImage) or by custom drawing. If somebody wants to display several kinds of bitmaps (one for "restaurants", one for "gas stations", one for "museums" etc) it would be maybe simpler to have an imagelist with all these images and an imageindex for the GPSPoint(s). Do you think this is a usefull extension of the lazMapViewer?

 

TinyPortal © 2005-2018