Class TMapControl

Unit

Declaration

type TMapControl = class(TScrollBox)

Description

Control displaying a map or its visible part.

Hierarchy

Overview

Fields

Public MapMarkGlyphStyle: TMapMarkGlyphStyle;
Public MapMarkCaptionStyle: TMapMarkCaptionStyle;
Public MapMarkCaptionFont: TFont;
Public SelectionShiftState: TShiftState;
Public DragShiftState: TShiftState;

Methods

Public constructor Create(AOwner: TComponent); override;
Public destructor Destroy; override;
Public procedure RefreshTile(TileHorzNum, TileVertNum: Cardinal);
Public function MapToGeoCoords(const MapPt: TPoint): TGeoPoint; overload;
Public function MapToGeoCoords(const MapRect: TRect): TGeoRect; overload;
Public function GeoCoordsToMap(const GeoCoords: TGeoPoint): TPoint; overload;
Public function GeoCoordsToMap(const GeoRect: TGeoRect): TRect; overload;
Public function ViewToMap(const ViewPt: TPoint): TPoint; overload;
Public function ViewToMap(const ViewRect: TRect): TRect; overload;
Public function MapToView(const MapPt: TPoint): TPoint; overload;
Public function MapToView(const MapRect: TRect): TRect; overload;
Public function MapToCanvas(const MapPt: TPoint; Canvas: TCanvas): TPoint; overload;
Public function MapToCanvas(const MapRect: TRect; Canvas: TCanvas): TRect; overload;
Public procedure ScrollMapBy(DeltaHorz, DeltaVert: Integer);
Public procedure ScrollMapTo(Horz, Vert: Integer);
Public procedure SetZoom(Value: Integer; const MapBindPt: TPoint); overload;
Public procedure SetZoom(Value: Integer); overload;
Public procedure ZoomToArea(const GeoRect: TGeoRect);
Public procedure ZoomToFit;
Public function MapMarkVisible(MapMark: TMapMark): Boolean; inline;
Public function MapMarkAtPos(const MapPt: TPoint): TMapMark;
Public procedure SetCacheImageProperties(TilesHorz, TilesVert, MarginSize: Cardinal);
Public function SaveToBitmap(const SaveRect: TRect; DrawOptions: TMapOptions; DrawMapMarks: Boolean): TBitmap; overload;
Public function SaveToBitmap(DrawOptions: TMapOptions; DrawMapMarks: Boolean): TBitmap; overload;

Properties

Public property TilesProvider: TTilesProvider read FTilesProvider write SetTilesProvider;
Public property Zoom: Integer read FZoom;
Public property MapOptions: TMapOptions read FMapOptions write FMapOptions;
Public property CenterPoint: TGeoPoint read GetCenterPoint write SetCenterPoint;
Public property NWPoint: TGeoPoint read GetNWPoint write SetNWPoint;
Public property MinZoom: TMapZoomLevel index 0 read FMinZoom write SetZoomConstraint;
Public property MaxZoom: TMapZoomLevel index 1 read FMaxZoom write SetZoomConstraint;
Public property MapMarks: TMapMarkList read FMapMarkList;
Public property Tracks: TTrackList read FTracks;
Public property MouseMode: TMapMouseMode read FMouseMode write SetMouseMode;
Public property LabelMargin: Cardinal read FLabelMargin write SetLabelMargin;
Public property ViewRect: TRect read ViewAreaRect;
Public property VisibleLayers: TMapLayers read FVisibleLayers write SetVisibleLayers;
Public property OnGetTile: TOnGetTile read FOnGetTile write FOnGetTile;
Public property OnDrawTile: TOnDrawTile read FOnDrawTile write FOnDrawTile;
Public property OnDrawTileLoading: TOnDrawTile read FOnDrawTileLoading write FOnDrawTileLoading;
Public property OnZoomChanged: TNotifyEvent read FOnZoomChanged write FOnZoomChanged;
Public property OnDrawMapMark: TOnDrawMapMark read FOnDrawMapMark write FOnDrawMapMark;
Public property OnDrawMapMarkGlyph: TOnDrawMapMark read FOnDrawMapMarkGlyph write FOnDrawMapMarkGlyph;
Public property OnDrawLayer: TOnDrawLayer read FOnDrawLayer write FOnDrawLayer;
Public property OnSelectionBox: TOnSelectionBox read FOnSelectionBox write FOnSelectionBox;
Public property OnMapMarkMouseDown: TOnMapMarkMouseButtonEvent read FOnMapMarkMouseDown write FOnMapMarkMouseDown;
Public property OnMapMarkMouseUp: TOnMapMarkMouseButtonEvent read FOnMapMarkMouseUp write FOnMapMarkMouseUp;

Description

Fields

Public MapMarkGlyphStyle: TMapMarkGlyphStyle;

Default glyph style of mapmarks. New items will be init-ed with this value

Public MapMarkCaptionStyle: TMapMarkCaptionStyle;

Default caption style of mapmarks. New items will be init-ed with this value

Public MapMarkCaptionFont: TFont;

Default font of mapmarks. New items will be init-ed with this value

Public SelectionShiftState: TShiftState;

Modifiers and mouse buttons combination to enter selection state on mouse down. Assigning this property removes necessity of handling "mouse down" event just for changing map state.

Public DragShiftState: TShiftState;

Modifiers and mouse buttons combination to enter dragging state on mouse down. Assigning this property removes necessity of handling "mouse down" event just for changing map state.

Methods

Public constructor Create(AOwner: TComponent); override;

This item has no description.

Public destructor Destroy; override;

This item has no description.

Public procedure RefreshTile(TileHorzNum, TileVertNum: Cardinal);

(Re)draw single tile having numbers (TileHorzNum;TileVertNum)

Public function MapToGeoCoords(const MapPt: TPoint): TGeoPoint; overload;

Convert a point from map pixel coords to geo coords

Public function MapToGeoCoords(const MapRect: TRect): TGeoRect; overload;

Convert a rect from map pixel coords to geo coords

Public function GeoCoordsToMap(const GeoCoords: TGeoPoint): TPoint; overload;

Convert a point from geo coords to map pixel coords

Public function GeoCoordsToMap(const GeoRect: TGeoRect): TRect; overload;

Convert a rect from geo coords to map pixel coords

Public function ViewToMap(const ViewPt: TPoint): TPoint; overload;

Convert a point from view area coords to map coords

Public function ViewToMap(const ViewRect: TRect): TRect; overload;

Convert a rect from view area coords to map coords

Public function MapToView(const MapPt: TPoint): TPoint; overload;

Convert a point from map coords to view area coords

Public function MapToView(const MapRect: TRect): TRect; overload;

Convert a rect from map coords to view area coords

Public function MapToCanvas(const MapPt: TPoint; Canvas: TCanvas): TPoint; overload;

Convert a point from map coords to view area's canvas coords ! Compiler-specific input ! Canvas here varies:

  • Delphi: dimensions of current display res and top-left is at viewport's top-left

  • LCL: dimensions somewhat larger than client area and top-left is at control top-left Canvas.ClipRect helps avoiding defines here

Public function MapToCanvas(const MapRect: TRect; Canvas: TCanvas): TRect; overload;

Convert a rect from map coords to view area's canvas coords

Public procedure ScrollMapBy(DeltaHorz, DeltaVert: Integer);

Delta move the view area

Public procedure ScrollMapTo(Horz, Vert: Integer);

Absolutely move the view area

Public procedure SetZoom(Value: Integer; const MapBindPt: TPoint); overload;

Set zoom level to new value and reposition to given point

Parameters
Value
- new zoom value
MapBindPt
- point in map coords that must keep its position within view
Public procedure SetZoom(Value: Integer); overload;

Simple zoom change with binding to top-left corner

Public procedure ZoomToArea(const GeoRect: TGeoRect);

Zoom to show given region GeoRect

Public procedure ZoomToFit;

Zoom to fill view area as much as possible

Public function MapMarkVisible(MapMark: TMapMark): Boolean; inline;

Returns mapmark visibility based on mapmark's own property and also on currently selected visible layers of the map

Public function MapMarkAtPos(const MapPt: TPoint): TMapMark;

Returns most recently added visible mapmark located at given map point considering its glyph size.

Public procedure SetCacheImageProperties(TilesHorz, TilesVert, MarginSize: Cardinal);

Set properties of cache image and rebuild it

Parameters
TilesHorz
- width (Horizontal dimension) of cache image, in number of tiles
TilesVert
- height (Vertical dimension) of cache image, in number of tiles
MarginSize
- margin that is added to cache image to hold view area, in number of tiles
Public function SaveToBitmap(const SaveRect: TRect; DrawOptions: TMapOptions; DrawMapMarks: Boolean): TBitmap; overload;

Export map fragment as bitmap.

Parameters
SaveRect
- rect in map coords to export
DrawOptions
- drawing options
DrawMapMarks
- draw mapmarks or not
Exceptions raised
Exception
if a tile is unavailable
Public function SaveToBitmap(DrawOptions: TMapOptions; DrawMapMarks: Boolean): TBitmap; overload;

Export whole map as bitmap.

Parameters
DrawOptions
- drawing options
DrawMapMarks
- draw mapmarks or not
Exceptions raised
Exception
if a tile is unavailable

Properties

Public property TilesProvider: TTilesProvider read FTilesProvider write SetTilesProvider;

Tiles provider object. Assigning this property could change some map properties (zoom range, for example, and hence current zoom) so cache will be cleared and the map will be redrawn with new conditions.
Map control takes ownership on assigned object and destroys it when needed.
Assign Nil to use an instance of TDummyTilesProvider.

Public property Zoom: Integer read FZoom;

Current zoom level

Public property MapOptions: TMapOptions read FMapOptions write FMapOptions;

Map options

Public property CenterPoint: TGeoPoint read GetCenterPoint write SetCenterPoint;

Point of center of current view area. Set this property to move view. If map is smaller than view area and resulting point falls out of the map, the Eastmost-Southmost (Bottom-right) point is returned and any assigning to this property has no effect.

Public property NWPoint: TGeoPoint read GetNWPoint write SetNWPoint;

Point of top-left corner of current view area. Set this property to move view If map is smaller than view area any assigning to this property has no effect.

Public property MinZoom: TMapZoomLevel index 0 read FMinZoom write SetZoomConstraint;

Minimal zoom level. Zoom couldn't be set to a value less than this value

Public property MaxZoom: TMapZoomLevel index 1 read FMaxZoom write SetZoomConstraint;

Maximal zoom level. Zoom couldn't be set to a value greater than this value

Public property MapMarks: TMapMarkList read FMapMarkList;

List of mapmarks on a map. Addition and deletion of items automatically redraws the parent map but to reflect any modifications of item properties call Map.Invalidate manually.

Public property Tracks: TTrackList read FTracks;

List of tracks. After any modifications call TMapControl.Invalidate or Refresh to display changes.

Public property MouseMode: TMapMouseMode read FMouseMode write SetMouseMode;

Mode of handling left mouse button press

Public property LabelMargin: Cardinal read FLabelMargin write SetLabelMargin;

Size of margin for labels on map, in pixels

Public property ViewRect: TRect read ViewAreaRect;

View area in map coords. Could be larger than the map on low zoom levels

Public property VisibleLayers: TMapLayers read FVisibleLayers write SetVisibleLayers;

Set of visible layers. Initially includes all layers. Quickly show/hide all layers with LayersAll and LayersNone constants

Public property OnGetTile: TOnGetTile read FOnGetTile write FOnGetTile;

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.
Called when map tile must be drawn. Usually you have to assign this callback only. OnGetTile could replace OnDrawTile and exists for simplicity - you don't have to paint tile image every time, the map will do it internally. It could also be assigned together with OnDrawTile which will only be called if OnGetTile doesn't return a result.

Public property OnDrawTile: TOnDrawTile read FOnDrawTile write FOnDrawTile;

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.
Called when map tile must be drawn. OnDrawTile could replace OnGetTile but provides more flexibility - handler fully controls painting which allows adding watermarks, layers and so on. It could also be assigned together with OnGetTile and will only be called if OnGetTile doesn't return a result.

If Handled is not set to True, default drawing is called for the tile.

Public property OnDrawTileLoading: TOnDrawTile read FOnDrawTileLoading write FOnDrawTileLoading;

Callback to draw a loading state 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. Called when map tile with loading state must be drawn.
OnDrawTileLoading is called only for empty tiles allowing a user to draw his own label

Public property OnZoomChanged: TNotifyEvent read FOnZoomChanged write FOnZoomChanged;

Called when zoom level is changed

Public property OnDrawMapMark: TOnDrawMapMark read FOnDrawMapMark write FOnDrawMapMark;

Callback to custom draw a mapmark. It is called before default drawing. If Handled is not set to True, default drawing will be done. User could draw a mapmark fully or change some props of a mapmark and let default drawing do its job.

Public property OnDrawMapMarkGlyph: TOnDrawMapMark read FOnDrawMapMarkGlyph write FOnDrawMapMarkGlyph;

Callback to custom draw a mapmark's glyph. It is called before default drawing. If Handled is not set to True, default drawing will be done.
Glyph rounding rectangle could be calculated with RectByCenterAndSize function and effective glyph style.

Public property OnDrawLayer: TOnDrawLayer read FOnDrawLayer write FOnDrawLayer;

Callback to custom draw a layer of whole map view. It is called for visible layers after drawing tiles and before drawing all objects (mapmarks, tracks, labels)

Public property OnSelectionBox: TOnSelectionBox read FOnSelectionBox write FOnSelectionBox;

Called when selection with mouse changes

Public property OnMapMarkMouseDown: TOnMapMarkMouseButtonEvent read FOnMapMarkMouseDown write FOnMapMarkMouseDown;

Called when user presses a mouse button above a mapmark

Public property OnMapMarkMouseUp: TOnMapMarkMouseButtonEvent read FOnMapMarkMouseUp write FOnMapMarkMouseUp;

Called when user releases a mouse button above a mapmark


Generated by PasDoc 0.16.0.