TatukGIS menu

Knowledge Base

KB10946 - Basemap and ScreenToMap

If any ScreenToMap or MapToScreen is used when drawing a basemap, the results can be unpredictable. The reason is the typical call GIS.ScreenToMap() cannot be used because basemap uses its own viewer to draw in a background thread. A workaround is use _shape.LayerViewer.ScreenToMap like in the following sample Delphi code snippet (similar logic with all platforms).

procedure TForm1.doLabelPos(
        _sender : TObject ; 
        _shape  : TGIS_Shape ;
        _pos    : TGIS_LabelPosition ; 
  var   _pt     : TPoint ; 
  const _rct    : TRect
) ;
  _pt := _shape.Layer.Viewer.Ref.MapToScreen( _shape.Centroid ) ;
Created: June 04, 2021, Modified: June 09, 2021