ImageEn, unit iexVirtualBitmaps

TIESlippyMap

Properties · Methods · Events · Demos · Examples

Declaration

TIESlippyMap = class(TIEVirtualBitmapProvider);


Description

Slippy Map is a term referring to the main openstreetmap.org map display, a web interface for browsing rendered OpenStreetMap data (from openstreetmap wiki).
For more detail: wiki.openstreetmap.org/wiki/Slippy_Map

TIESlippyMap is a virtual image provider for TIEBitmap objects. Selecting a position using Latitude and Longitude a map (an image) will be loaded and handled as TIEBitmap content.
Local caching is provided to speed up re-loading tiles and to support off-line jobs.



Demo


Demo  Demos\Other\GeoMaps\GeoMaps.dpr

Example


ImageEnView1.IEBitmap.VirtualBitmapProvider := TIESlippyMap.Create();
with TIESlippyMap(ImageEnView1.IEBitmap.VirtualBitmapProvider) do
begin
  // move to London
  Latitude  := 51.503614574056016;
  Longitude := -0.12774750793460043;
  // location at bitmap center
  PointPosition := Point(ImageEnView1.IEBitmap.Width div 2, ImageEnView1.IEBitmap.Height div 2);
  // zoom
  Zoom := 14;
end;
ImageEnView1.Update();

// Save an image with pins drawn for GPS coordinates
const
  Pin_Width  = 40;
  Pin_Height = 40;
var
  i: integer;
  idx: integer;
  lat, lon: double;
  x, y: integer;
  fn: string;
begin
  // Prompt for a filename
  fn := ImageEnView1.IO.ExecuteSaveDialog();
  if fn = '' then
    exit;

  // Hide changes from view
  ImageEnView1.LockUpdate();
  try

    // Add pins as shape layers
    for i := 0 to ImageEnMView1.MultiSelectedImagesCount - 1 do
    begin
      idx := ImageEnMView1.MultiSelectedImages[i];
      lat := ImageEnMView1.MIO.Params[idx].EXIF_GPSLatitude;
      lon := ImageEnMView1.MIO.Params[idx].EXIF_GPSLongitude;
      x := map.LongitudeToBmpX(lon);
      y := map.LatitudeToBmpY(lat);

      ImageEnView1.LayersAdd( iesPinLeft, x, y - Pin_Height, Pin_Width, Pin_Height );
    end;

    // Save current image + layers to file
    ImageEnView1.LayersSaveMergedTo( fn );

    // Clean up
    ImageEnView1.LayersClear(False);

  finally
    // Reenable ImageEnView1
    ImageEnView1.UnlockUpdate();
  end;
end;

Methods and Properties


Generic Rendering
Public Method  DrawTo

TIEVirtualBitmapProvider rendering
Public Method  GetSegment
Public Method  Render

Multithreading and Cache
Public Property  CachePath
Public Property  MaxThreads
Public Property  MemoryCacheSize

Map Coordinates and Zooming
Public Property  Latitude
Public Property  Longitude
Public Property  PointPosition
Public Property  Zoom

Coordinates Conversion
Public Method  BmpXToLongitude
Public Method  BmpYToLatitude
Public Method  LongitudeToBmpX
Public Method  LatitudeToBmpY

Other
Public Method  Create
Public Property  MissingTileColor
Public Property  UserKey


Events

Event  OnBeginWork
Event  OnFinishWork