Unit OSM.MapControl

Description

Visual control displaying a map. Data for the map (tile images) must be supplied via callbacks.

(c) Fr0sT-Brutal https://github.com/Fr0sT-Brutal/Delphi_OSMMap

See also
OSM.TileStorage
OSM tile images cache.

Overview

Classes, Interfaces, Objects and Records

Name Description
Record TMapMarkGlyphStyle Visual properties of mapmark's glyph
Record TMapMarkCaptionStyle Visual properties of mapmark's caption
Class TChildObjList Base wrapper for list of map's child objects (mapmarks, tracks).
Class TMapMark Class representing a single mapmark.
Class TMapMarkList List of mapmarks.
Record TLineDrawProps Options for drawing track lines
Class TTrack Track data
Class TTrackList List of tracks.
Class TMapControl Control displaying a map or its visible part.

Functions and Procedures

function ToInnerCoords(const StartPt, Pt: TPoint): TPoint; overload; inline;
function ToOuterCoords(const StartPt, Pt: TPoint): TPoint; overload; inline;
function ToInnerCoords(const StartPt: TPoint; const Rect: TRect): TRect; overload; inline;
function ToOuterCoords(const StartPt: TPoint; const Rect: TRect): TRect; overload; inline;
procedure Triangle(Canvas: TCanvas; const Rect: TRect);
function RectByCenterAndSize(const CenterPt: TPoint; Size: Integer): TRect;
function ShiftStateIs(Current, Desired: TShiftState): Boolean;

Types

TMapMarkGlyphShape = (...);
TOpacity = Byte;
PMapMarkGlyphStyle = ˆTMapMarkGlyphStyle;
PMapMarkCaptionStyle = ˆTMapMarkCaptionStyle;
TMapMarkCustomProp = (...);
TMapMarkCustomProps = set of TMapMarkCustomProp;
TMapLayer = Byte;
TMapLayers = set of Byte;
TOnItemNotify = procedure (Sender: TObject; Item: T; Action: TListNotification) of object;
TMapMarkFindOption = (...);
TMapMarkFindOptions = set of TMapMarkFindOption;
TMapOption = (...);
TMapOptions = set of TMapOption;
TMapMouseMode = (...);
TOnGetTile = function (Sender: TMapControl; TileHorzNum, TileVertNum: Cardinal): TBitmap of object;
TOnDrawTile = procedure (Sender: TMapControl; TileHorzNum, TileVertNum: Cardinal; const TopLeft: TPoint; Canvas: TCanvas; var Handled: Boolean) of object;
TOnDrawMapMark = procedure (Sender: TMapControl; Canvas: TCanvas; const Point: TPoint; MapMark: TMapMark; var Handled: Boolean) of object;
TOnDrawLayer = procedure (Sender: TMapControl; Layer: TMapLayer; Canvas: TCanvas; const CanvasRect, MapInViewRect: TRect) of object;
TOnSelectionBox = procedure (Sender: TMapControl; const GeoRect: TGeoRect; Finished: Boolean) of object;
TOnMapMarkMouseButtonEvent = procedure (Sender: TMapControl; MapMark: TMapMark; Button: TMouseButton; Shift: TShiftState) of object;

Constants

DefaultCacheImageTilesHorz = 8;
DefaultCacheImageTilesVert = 8;
DefaultCacheMarginSize = 2;
DefaultLabelMargin = 2;
DefaultMapMarkGlyphStyle: TMapMarkGlyphStyle = ( Shape: gshCircle; Size: 20; BorderColor: clWindowFrame; BgColor: clSkyBlue; Opacity: High(TOpacity); );
DefaultMapMarkCaptionStyle: TMapMarkCaptionStyle = ( Visible: True; Color: clMenuText; BgColor: clWindow; DX: 3; Transparent: True );
DefLineDrawProps: TLineDrawProps = ( Width: 3; Style: psSolid; Color: clBlue );
LayersAll: TMapLayers = [Low(TMapLayer)..High(TMapLayer)];
LayersNone: TMapLayers = [];
S_Lbl_Loading = 'Loading [%d : %d]...';

Description

Functions and Procedures

function ToInnerCoords(const StartPt, Pt: TPoint): TPoint; overload; inline;

Convert absolute map coords to a point inside a viewport having given top-left point

function ToOuterCoords(const StartPt, Pt: TPoint): TPoint; overload; inline;

Convert a point inside a viewport having given top-left point to absolute map coords

function ToInnerCoords(const StartPt: TPoint; const Rect: TRect): TRect; overload; inline;

Convert absolute map rect to a rect inside a viewport having given top-left point

function ToOuterCoords(const StartPt: TPoint; const Rect: TRect): TRect; overload; inline;

Convert a rect inside a viewport having given top-left point to absolute map rect

procedure Triangle(Canvas: TCanvas; const Rect: TRect);

Draw triangle on canvas

function RectByCenterAndSize(const CenterPt: TPoint; Size: Integer): TRect;

Return rectangle with center point in CenterPt and with size Size

function ShiftStateIs(Current, Desired: TShiftState): Boolean;

Determine whether current ShiftState corresponds to desired one (that is, if mouse button and pressed modifiers are the same - not a simple comparison because TShiftState could include additional entries like "Pen", "Touch" and so on. This function only checks Ctrl, Alt, Shift and Left, Right, Middle mouse buttons.

Types

TMapMarkGlyphShape = (...);

Shape of mapmark glyph

Values
  • gshCircle
  • gshSquare
  • gshTriangle
TOpacity = Byte;

Opacity level, from 0 (transparent) to $FF (non-transparent)

PMapMarkGlyphStyle = ˆTMapMarkGlyphStyle;

This item has no description.

PMapMarkCaptionStyle = ˆTMapMarkCaptionStyle;

This item has no description.

TMapMarkCustomProp = (...);

Flags to indicate which properties must be taken from MapMark object when drawing. By default props will use owner's values

Values
  • propGlyphStyle
  • propCaptionStyle
  • propFont
TMapMarkCustomProps = set of TMapMarkCustomProp;

This item has no description.

TMapLayer = Byte;

Number of a layer. 0 means default, base layer.

TMapLayers = set of Byte;

This item has no description.

TOnItemNotify = procedure (Sender: TObject; Item: T; Action: TListNotification) of object;

Notification that item is added to the list or removed from it

TMapMarkFindOption = (...);

Options for TMapMarkList.Find. Default is empty set

Values
  • mfoConsiderGlyphSize: If set (for map pixels only): consider mapmark glyph size as well. If not set (default): search by exact coords.
  • mfoOnlyVisible: If set: consider only visible mapmarks. If not set (default), consider all mapmarks
TMapMarkFindOptions = set of TMapMarkFindOption;

This item has no description.

TMapOption = (...);

Options of map control

Values
  • moDontDrawCopyright
  • moDontDrawScale
TMapOptions = set of TMapOption;

This item has no description.

TMapMouseMode = (...);

Mode of current handling of mouse events:

Values
  • mmNone: default handling - mouse doesn't activate the map
  • mmDragging: dragging the map
  • mmSelecting: drawing selection box
TOnGetTile = function (Sender: TMapControl; TileHorzNum, TileVertNum: Cardinal): TBitmap of object;

Callback to get an image of a single tile having number (TileHorzNum;TileVertNum). Must return bitmap of a tile or Nil if it's not available at the moment

TOnDrawTile = procedure (Sender: TMapControl; TileHorzNum, TileVertNum: Cardinal; const TopLeft: TPoint; Canvas: TCanvas; var Handled: Boolean) of object;

Callback to draw an image of a single tile having number (TileHorzNum;TileVertNum) at point TopLeft on canvas Canvas. Must set Handled to True, otherwise default actions will be done. This type is common for both TMapControl.OnDrawTile and TMapControl.OnDrawTileLoading callbacks.

TOnDrawMapMark = procedure (Sender: TMapControl; Canvas: TCanvas; const Point: TPoint; MapMark: TMapMark; var Handled: Boolean) of object;

Callback to custom draw a mapmark or just a glyph with center point Point. It is called before default drawing. If Handled is not set to True, default drawing will be done.

TOnDrawLayer = procedure (Sender: TMapControl; Layer: TMapLayer; Canvas: TCanvas; const CanvasRect, MapInViewRect: TRect) of object;

Callback to custom draw a visible layer of whole map view. CanvasRect is rectangle of current view in canvas coords (use it in paint functions) and MapInViewRect is rectangle of current view in map coords (use it to check visibility of objects).

TOnSelectionBox = procedure (Sender: TMapControl; const GeoRect: TGeoRect; Finished: Boolean) of object;

Callback to react on selection by mouse

TOnMapMarkMouseButtonEvent = procedure (Sender: TMapControl; MapMark: TMapMark; Button: TMouseButton; Shift: TShiftState) of object;

Callback to react on mouse button press/release

Constants

DefaultCacheImageTilesHorz = 8;

Default Width (Horizontal dimension) and Height (Vertical dimension) of cache image in number of tiles. Cache is init-ed with these values but could be changed later.
Memory occupation of an image: (4 bytes per pixel) * TilesH * TilesV * (65536 pixels in single tile)
For value 8 it counts 16.7 Mb

DefaultCacheImageTilesVert = 8;

This item has no description.

DefaultCacheMarginSize = 2;

Default margin that is added to cache image to hold view area, in number of tiles

DefaultLabelMargin = 2;

Default size of margin for labels on map, in pixels

DefaultMapMarkGlyphStyle: TMapMarkGlyphStyle = ( Shape: gshCircle; Size: 20; BorderColor: clWindowFrame; BgColor: clSkyBlue; Opacity: High(TOpacity); );

Default style of mapmark glyph. TMapControl.MapMarkGlyphStyle is init-ed with this value

DefaultMapMarkCaptionStyle: TMapMarkCaptionStyle = ( Visible: True; Color: clMenuText; BgColor: clWindow; DX: 3; Transparent: True );

Default style of mapmark caption. TMapControl.MapMarkGlyphStyle is init-ed with this value

DefLineDrawProps: TLineDrawProps = ( Width: 3; Style: psSolid; Color: clBlue );

Default style of track line.

LayersAll: TMapLayers = [Low(TMapLayer)..High(TMapLayer)];

Constant containing all numbers of layers

LayersNone: TMapLayers = [];

Constant containing no layers

S_Lbl_Loading = 'Loading [%d : %d]...';

Default pattern to draw on currently loading tiles

Author


Generated by PasDoc 0.16.0.