Skip to content

Commit

Permalink
[API] Source/OSM.TilesProvider.Google.pas: + Add Google maps provider
Browse files Browse the repository at this point in the history
  • Loading branch information
Fr0sT-Brutal committed Sep 19, 2022
1 parent ce92254 commit 99e14aa
Showing 1 changed file with 62 additions and 0 deletions.
62 changes: 62 additions & 0 deletions Source/OSM.TilesProvider.Google.pas
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{
Google tile image provider.
https://gis.stackexchange.com/questions/225098/using-google-maps-static-tiles-with-leaflet
- should be an official description but I didn't find it.
(c) Fr0sT-Brutal https://github.com/Fr0sT-Brutal/Delphi_OSMMap
@author(Fr0sT-Brutal (https://github.com/Fr0sT-Brutal))
@author(Martin (https://github.com/array81))
}
unit OSM.TilesProvider.Google;

interface

uses
SysUtils,
OSM.SlippyMapUtils, OSM.TilesProvider;

type
// Google tile image provider
TGoogleTilesProvider = class(TTilesProvider)
const
//~ global defaults
// Default copyright text
DefTilesCopyright = '(c) Google';
{~ TODO: Note that difference in the "lyrs" parameter in the URL:
Hybrid: s,h;
Satellite: s;
Streets: m;
Terrain: p;
}
// Default pattern of tile URL. Placeholders are for: Random subdomain (0..MaxSubdomainNum), X, Y, Zoom
DefTileURLPatt = 'http://mt%d.google.com/vt/lyrs=m&hl=en&x=%d&y=%d&z=%d';
// Maximal subdomain number
MaxSubdomainNum = 3;
public
// Pattern of tile URL. Placeholders are for: Random subdomain (0..MaxSubdomainNum), X, Y, Zoom
TileURLPatt: string;

constructor Create;
function GetTileURL(const Tile: TTile): string; override;
end;

implementation

constructor TGoogleTilesProvider.Create;
begin
MinZoomLevel := Low(TMapZoomLevel);
MaxZoomLevel := 19;
// TileFormat.Format := 'png';
// TileFormat.Width := 256;
// TileFormat.Height := 256;
TilesCopyright := DefTilesCopyright;
TileURLPatt := DefTileURLPatt;
end;

function TGoogleTilesProvider.GetTileURL(const Tile: TTile): string;
begin
Result := Format(TileURLPatt, [Random(MaxSubdomainNum), Tile.ParameterX, Tile.ParameterY, Tile.Zoom]);
end;

end.

0 comments on commit 99e14aa

Please sign in to comment.