Declaration
function GenerateGoogleStaticMapURL(const ApiKey: String;
OutSizeX, OutSizeY: Integer;
const Location: string;
Zoom: Integer = 12;
MapType: TIEGoogleMapType = iegmRoadmap;
ssMarkers: TStrings = nil;
const ImgFormat: string = 'png'): string; overload;
function GenerateGoogleStaticMapURL(const ApiKey: String;
OutSizeX, OutSizeY: Integer;
Latitude, Longitude: Double;
Zoom: Integer = 12;
MapType: TIEGoogleMapType = iegmRoadmap;
ssMarkers: TStrings = nil;
const ImgFormat: string = 'png'): string; overload;
Description
Returns the URL for a web based map image using the Google Static Maps API.
You can sign up for the service and an API key at:
developers.google.com/maps/documentation/maps-static/start
Parameter | Description |
ApiKey | Your Google Static Maps API key |
OutSizeX, OutSizeY | The size of the image you want. Max size provided by the service is generally 1280x1280 (values greater than 640x640 will use the API scale parameter to be enlarged) |
Location | An address or landmark, e.g. 'Brooklyn Bridge, New York, NY' |
Latitude, Longitude | A decimal latitude and longitude, e.g. 40.714728, -73.998672 |
Zoom | The map zoom level (see description below) |
MapType | Map style, e.g. road map or satellite image |
ssMarkers | An optional list of markers to add to the image (see below) |
ImgFormat | The format of the map image, e.g. 'png', 'png32', 'gif' or 'jpg' |
Note: You need an API key that supports the "Google Cloud Vision API". See
our instructions for this
Zoom Level
The approximate level of detail for each zoom level:
Value | Description |
1 | World |
5 | Landmass/continent |
10 | City |
15 | Streets |
20 | Buildings |
Markers
The set of marker style descriptors is a series of latitude and longitude sets separated by the pipe (|) character. ImageEn requires one marker per line of ssMarkers, or all markers on a single line separated by the pipe (|) character.
These style descriptors contain the following key/value assignments:
◼size: (optional) Specifies the size of marker from the set: tiny, mid, small. If no size parameter is set, the marker will appear in its default (normal) size(optional)
◼color: (optional) Specifies a 24-bit color (e.g. color=0xFFFFCC) or a predefined color from the set: black, brown, green, purple, yellow, blue, gray, orange, red, white
◼label: (optional) Specifies a single uppercase alphanumeric character from the set: A-Z, 0-9
Example: color:blue|label:S|40.702147,-74.015794
For more information:
developers.google.com/maps/documentation/maps-static/start#Markers
| Demos\InputOutput\GoogleVisionApi\GoogleVisionApi.dpr |
// Show map of Chinatown, New York
url := GenerateGoogleStaticMapURL( MY_API_KEY, ImageEnView1.ClientWidth, ImageEnView1.ClientHeight, 40.714728, -73.998672 );
ImageEnView1.IO.LoadFromUrl( url );
// Show map of Brooklyn Bridge with 3 markers
ssMarkers := TStringList.Create();
ssMarkers.Add( 'color:blue|label:S|40.702147,-74.015794' );
ssMarkers.Add( 'color:green|label:G|40.711614,-74.012318' );
ssMarkers.Add( 'color:red|label:C|40.718217,-73.998284' );
url := GenerateGoogleStaticMapURL( MY_API_KEY, ImageEnView1.ClientWidth, ImageEnView1.ClientHeight, 'Brooklyn Bridge,New York,NY', 13, iegmRoadmap ssMarkers );
ImageEnView1.IO.LoadFromUrl( url );
ssMarkers.Free;