Forum > Third party

TMapViewer

<< < (32/33) > >>

CV:
I'm still playing with and learning from the examples that come the LazMapViewer package.
Another question came up about the handling of GpsItems. I've create such an object with the following code:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TMainForm.btCreatePointClick(Sender: TObject);var  rPt: TRealPoint;  gpsPt: TGpsPoint;  gpsName: String = '';begin  rPt := MapView.Center;  gpsPt := TGpsPoint.CreateFrom(rPt);  gpsPt.Name := '';  MapView.GpsItems.Add(gpsPt, _CLICKED_POINTS_);end;  So far so good. The marker appears where it should be (at the center of the screen). It also shows up correctly in the GPS points list (part of the example). 
Next I've moved the window a bit and tried to move/change the location of the GpsObject to the new center by applying:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TMainForm.btRelocateToCenterClick(Sender: TObject);var  rPt: TRealPoint;  gpsObj: TGpsObj;begin  rPt := MapView.Center;  if (MapView.GpsItems.Count > 0) then begin    gpsObj := MapView.GpsItems[0];    if gpsObj is TGpsPoint then begin      TGpsPoint(gpsObj).MoveTo(MapView.Center.Lon, MapView.Center.Lat, NO_ELE ,NO_DATE );    end;  end;end; From now on the painting of the marker get's weird, or disappears completely, also depeding on zoom level.
What am I doing wrong?

wp:
Did you try to call MapView.Redraw at the end of btRelocateToCenterClick?

CV:
No improvement with .Redraw.
I've also altered the settings for DrawingEngines, Threads and Double Buffering: no improvement.

The workaround I found is to clear the list and create a new entry with updated coordinates:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---      MapView.GpsItems.Clear(_CLICKED_POINTS_);      gpsObj := TGpsPoint.CreateFrom(rPt);      gpsObj.Name := '';      MapView.GPSItems.Add(gpsObj, _CLICKED_POINTS_); 
(This marker shows the current GPS-position. New coordinates about every 0.5 second)

wp:
I cannot reproduce this - although I agree that sometimes the markers disappear. This is a consequence of the tiled painting routine which draws the map tile by tile in individual threads and unpredictable order, and puts the markers on top of it which may be overwritten if the image tile is painted later. I think the painting routine requires a major overhaul...

Since you have to erase the marker list I assume that you already have some markers before your code is executed. Please be aware that gpsObj := MapView.GpsItems[0] refers to the first marker added which is not necessarily the one you are interested in.

CV:
Maybe the drawing routine somehow memorizes the GPS location when adding/creating a new element?..
Btw, my workaround idea was inspired by the GPSListViewer (TGPSListViewer.BtnDeletePointClick, deleting a point from the list).
(And thanks, I'm aware of affecting all elements of the list)


All in all I'm still very happy how nice and smooth this component works. Keeping the effort in mind it took to come to this level I feel a bit bad to propose some improvements. Also the idea contradicts the tiles-approach. But this would be my wishlist:

For offline usage it's a pain to handle all the tiles. Even for small areas I have to deal with several 100k of tiles/files. Would it be possible to get the data out of one single file (regardless its size)? I've seen this approach based on vector data:
https://github.com/serbod/osmap

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version