LoMaPh
LoMaPh

Reputation: 1710

How to apply API key to Google Maps Tile server URL?

I want to use Google Maps Tile server URL inside an application.

I'm using the URL
https://mt0.google.com/vt/lyrs=s&hl=en&x={x}&y={y}&z={z}&s=Ga
and it is working fine. The problem is that I'm not sure how to use my Google Cloud API key for this URL.

I tried adding the API key at the end of the URL:
https://mt0.google.com/vt/lyrs=s&hl=en&x={x}&y={y}&z={z}&s=Ga&key=[MY_KEY]
but I don't see any activity on "Maps JavaScript API" in my Google cloud console. Meaning that the API Key is not being used.

Does this URL need an API Key?
It's working without the Key for now, but I'm afraid it may not work in the long run or it may be illegal to use it without the Key.

Upvotes: 11

Views: 14309

Answers (4)

miguev
miguev

Reputation: 4855

The Google Map Tiles API is now generally available for Preview, including access to 2D and 3D tiles. Please note use of this API is subject to the Google Maps Platform Terms of Service and Map Tiles API Policies.

Fetching tiles directly otherwise, via requests kike https://mt0.google.com/vt/lyrs=s&hl=en&x={x}&y={y}&z={z}&s=Ga or any other that are not documented as part of an API, is against the same Terms of Service.

Upvotes: 0

Daniel F
Daniel F

Reputation: 14239

You are not allowed to access it directly via

https://mt0.google.com/vt/lyrs=s&hl=en&x={x}&y={y}&z={z}&s=Ga

, you must create a session token via

https://tile.googleapis.com/tile/v1/createSession?key=YOUR_API_KEY


You can use Google's 2D tiles legally via the 2D Tiles API

https://developers.google.com/maps/documentation/tile/2d-tiles-overview?hl=en

The current usage limits are specified at

https://developers.google.com/maps/documentation/tile/usage_limits?hl=en

2D Tiles and Street View tiles

Maximum 6,000 queries per day, calculated as the sum of all requests for all applications using the credentials of the same project.

The same information is avaliable for 3D tiles at

https://developers.google.com/maps/documentation/tile/3d-tiles-overview?hl=en

with the following limitations:

Photorealistic 3D Tiles Maximum

300 root tileset queries per day. This is calculated as the sum of all requests for all applications using the credentials of the same project.

Maximum 250,000 renderer’s tile requests per day. This is calculated as the sum of all requests for all applications using the credentials of the same project.

Rate limit is 12,000 queries per minute for the tile renderer.

You need an API key to use this service, but other than that, there is no pricing provided, which means that it is free to use up to the specified limits and if you plan to use more you would need to contact Google.

There are policies which need to be adhered to:

https://developers.google.com/maps/documentation/tile/policies?hl=en

Providing terms of use and privacy policy

If you develop a Map Tiles API application, you must make available the Terms of Use and a Privacy Policy with your application which meets the guidelines outlined in your Agreement with Google:

  • The Terms of Use and Privacy Policy must be publicly available. You must explicitly state in your application's Terms of Use that by using your application, users are bound by Google’s Terms of Service.
  • You must notify users in your Privacy Policy that you are using the Google
  • Maps API(s) and incorporate by reference the Google Privacy Policy.

Upvotes: 0

LoMaPh
LoMaPh

Reputation: 1710

Ok, So I spend some time on this and found some solutions for directly using Map Tile Server URL (without any coding required). Here is a summary:

Google Maps:

  • The URL https://mt0.google.com/vt/lyrs=s&hl=en&x={x}&y={y}&z={z}&s=Ga currently works, but it is illegal to use as it violates Google Maps TOS Section 3.2.4a https://cloud.google.com/maps-platform/terms/#3-license. because it doesn't use an API Key.
  • There was a service called Google Maps Tile API, but it has discontinued since September 2019 (the API key need to be whitelisted to be able to use this service, and they don't do it anymore since Sep).

So it seems for now there is no easy and simple way to get Tile Server URL from Google Maps.

Bing Maps:

  • The URL is in the form http://ecn.{subdomain}.tiles.virtualearth.net/tiles/r{quadkey}.jpeg?g=129 where quadkey is a compact representation of variables x, y and z. So doesn't work directly in applications that require URL's that have x,y,z variables.

Azure Maps:

  • The URL is in the form https://atlas.microsoft.com/map/tile?subscription-key=***&api-version=2.0&tilesetId=microsoft.imagery&zoom={z}&x={x}&y={y}. For different settings see here. The shortcoming of this approach is that currently it cannot be set to show hybrid maps (satellite + street and city names).

MapBox:

  • The URL is in the form https://api.mapbox.com/styles/v1/mapbox/satellite-streets-v11/tiles/256/{z}/{x}/{y}?access_token=***. You can set the style of the map (currently set to satellite-streets-v11) by choosing the desired value from here and replacing in the URL.

Upvotes: 17

rbrundritt
rbrundritt

Reputation: 18004

If you want to directly access map tiles, consider Azure Maps. They don't have the restriction that Google Maps has. It's also cheaper. Here are some samples that directly access the tile server: https://azuremapscodesamples.azurewebsites.net/index.html#Third-Party-Map-Controls

Here are some other useful resources:

Upvotes: 2

Related Questions