ImageEn, unit iexHelperFunctions

TIEBitmapHelper.GenerateMap

TIEBitmapHelper.GenerateMap

Declaration

procedure TIEBitmapHelper.GenerateMap(Width, Height: Integer; Latitude, Longitude: double; MapZoom: Integer = 14; MapProvider: TIESlippyMapProvider = iesmpOSM_Mapnik;
                                      DrawPin: Boolean = True; PinSize: Integer = 40; PinColor: TColor = clRed; const MapCachePath: string = ''; MapApiKey: string = '');

Description

Uses the TIESlippyMap class to download and render a map using OpenStreetMap data.
For more detail: wiki.openstreetmap.org/wiki/Slippy_Map
Parameter Description
Width, Height The size to create the map image
Latitude The latitude in decimal degrees (for the center of the image). For the latitude of the image use EXIF_GPSLatitude
Longitude The longitude in decimal degrees (for the center of the image). For the longitude of the image use EXIF_GPSLongitude
MapZoom Specifies the zoom level (0-...). Level 0 is the minimum zoom (supported by all map providers) which is the most zoomed out (country level).
Maximum zoom is map provider specific, but high values, e.g. 18, are most zoomed in (street level). See TIESlippyMapProvider for maximum value for each map provider.
MapProvider Specifies a Predefined map provider
DrawPin If enabled, a pin is drawn at the center of the image
PinSize The size of the pin in pixels
PinColor The fill color of the pin
MapCachePath If specified, maps are saved to the specified path to speed up reuse
MapApiKey Specifies the user key for map providers that requires registration



Note:
You must add the iexHelperFunctions unit to your uses clause
Delphi/C++ 2005 or newer is required to use helper classes
If attached to a TImageEnView, it will automatically call Update

Demos

Demo  Demos\ImageEditing\EveryMethod\EveryMethod.dpr

Examples

Also see: Automated Samples
// Generate a map showing the location of the current image
If ( ImageEnView1.IO.Params.EXIF_HasEXIFData ) and
   ( ImageEnView1.IO.Params.EXIF_GPSLatitude_Str <> '' ) and
   ( ImageEnView1.IO.Params.EXIF_GPSLongitude_Str <> '' ) then
  ImageEnView2.IEBitmap.GenerateMap( 500, 500, ImageEnView1.IO.Params.EXIF_GPSLatitude, ImageEnView1.IO.Params.EXIF_GPSLongitude );


// Generate a map of London
ImageEnView1.IEBitmap.GenerateMap( 400, 400, 51.50361, -0.12775, 9, iesmpOSM_Mapnik, true, 40, clRed );



// Save maps of major cities
type
  TCityLocation = record
    City: string;
    Latitude: Double;
    Longitude: Double;
  end;

const
  City_Locations: array[0..29] of TCityLocation = (
    ( City: 'London';         Latitude: 51.5036145;  Longitude: -0.1277475   ),
    ( City: 'Rome';           Latitude: 41.9027835;  Longitude: 12.4963655   ),
    ( City: 'New York';       Latitude: 40.7127753;  Longitude: -74.0059728  ),
    ( City: 'Tokyo';          Latitude: 35.6761919;  Longitude: 139.6503106  ),
    ( City: 'Wellington';     Latitude: -41.2864603; Longitude: 174.776236   ),
    ( City: 'Rio de Janeiro'; Latitude: -22.9068467; Longitude: -43.1728965  ),
    ( City: 'Cape Town';      Latitude: -33.9248685; Longitude: 18.4240553   ),
    ( City: 'Paris';          Latitude: 48.856614;   Longitude: 2.3522219    ),
    ( City: 'Berlin';         Latitude: 52.520007;   Longitude: 13.404954    ),
    ( City: 'Madrid';         Latitude: 40.4167754;  Longitude: -3.7037902   ),
    ( City: 'Sydney';         Latitude: -33.8688197; Longitude: 151.2092955  ),
    ( City: 'Mumbai';         Latitude: 19.0759837;  Longitude: 72.8776559   ),
    ( City: 'Dubai';          Latitude: 25.2048493;  Longitude: 55.2707828   ),
    ( City: 'Singapore';      Latitude: 1.352083;    Longitude: 103.819836   ),
    ( City: 'Hong Kong';      Latitude: 22.3193039;  Longitude: 114.1693611  ),
    ( City: 'Beijing';        Latitude: 39.904211;   Longitude: 116.407395   ),
    ( City: 'Moscow';         Latitude: 55.755826;   Longitude: 37.6172999   ),
    ( City: 'Cairo';          Latitude: 30.0444196;  Longitude: 31.2357116   ),
    ( City: 'Istanbul';       Latitude: 41.0082376;  Longitude: 28.9783589   ),
    ( City: 'Los Angeles';    Latitude: 34.0522342;  Longitude: -118.2436849 ),
    ( City: 'Toronto';        Latitude: 43.653226;   Longitude: -79.3831843  ),
    ( City: 'Mexico City';    Latitude: 19.4326077;  Longitude: -99.133208   ),
    ( City: 'Buenos Aires';   Latitude: -34.6036844; Longitude: -58.3815591  ),
    ( City: 'São Paulo';      Latitude: -23.5505199; Longitude: -46.6333094  ),
    ( City: 'Bangkok';        Latitude: 13.7563309;  Longitude: 100.5017651  ),
    ( City: 'Seoul';          Latitude: 37.566535;   Longitude: 126.9779692  ),
    ( City: 'Amsterdam';      Latitude: 52.3675734;  Longitude: 4.9041389    ),
    ( City: 'Lagos';          Latitude: 6.5243793;   Longitude: 3.3792057    ),
    ( City: 'Nairobi';        Latitude: -1.2920659;  Longitude: 36.8219462   ),
    ( City: 'Vancouver';      Latitude: 49.2827291;  Longitude: -123.1207375 ));

var
  bmp: TIEBitmap;
  i: Integer;
begin
  bmp := TIEBitmap.Create();
  for i := Low( City_Locations ) to High( City_Locations ) do
  begin
    bmp.GenerateMap( 600, 600, City_Locations[i].Latitude, City_Locations[i].Longitude, 6, iesmpOSM_Mapnik, False );
    bmp.SaveToFile( format( 'D:\%s.png', [ City_Locations[i].City ]);
  end;
  bmp.Free();
end;