Satellite Map

I need to use Satellite (AKA Aerial) map in Metabase. I believe I need to change the “Map Tile Server URL” in admin panel > Maps.

In OpenStreetMap community help it says:

OpenStreetMap does not have any satellite imagery itself.
Our main provider of satellite imagery is Bing, Microsoft’s mapping service.

So I looked for Map Tile Server URL for Bing Map. I followed the instruction here, and obtained a URL.

The URL is in the following format:
http://ecn.{subdomain}.tiles.virtualearth.net/tiles/r{quadkey}.jpeg?g=129

quadKey is a number that represent the tileX, tileY and the zoom level. (I wrote a small function using MS base code to get quadKey from the triple [latitude, longitude, zoom_level]).

When I use this URL in Admin Panel > Maps > Map Tile server URL, I get the following map (used sample dataset > people):

The blue dots are the coordinates in US (which is not important for the current issue). The problem is that a fixed Map tile (the one corresponding to the provided quadKey) is being shown all over the map (repeated).

The default Map Tile Server URL in Metabase is
http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png

I believe the variables x, y, z in the above URL are xTile, yTile and the zoom level. I think in the custom url, since there is no room for these variables, the problem occurs (the quadKey is representing all those values in a single number).

What can be done about this?

Metabase Version: 0.33.5

Hi @King_Edward

I don’t know a lot about the Bing Maps, but with Google Maps, you would do something like this:
https://mt0.google.com/vt/lyrs=s&hl=en&x={x}&y={y}&z={z}&s=Ga
But just like many of the other services, it requires a license: https://cloud.google.com/maps-platform/

I would guess that you would need to setup your own web-server that converts the {z}{y}{x} to {quadKey}, like
http://my-map-converter.example.com/{s}/{z}/{x}/{y}
And then that server would convert it and get the correct map from Bing and proxy it back to Metabase.

1 Like

Thanks.

Where does go the API Key for Google Maps? It seems it is working without it.

@King_Edward You would either have to hack the ./resources/frontend_client/(index|embed|public).html or use a reverse proxy to inject it:
https://developers.google.com/maps/documentation/javascript/get-api-key
I don’t understand the license terms, but I’m guessing they allow X amount of requests without a key.

I couldn’t find the path ./resources/frontend_client or any html file in the docker image. Can you elaborate? In the Metabase Github repo there is the path resources/frontend_client but I was lost after that (the closest file was index_template.html, which doesn’t seem relevant).

If the hacking approach doesn’t work, I’ll try creating a web-server for this purpose.

P.S. I contacted Google Maps support:

"Direct access to Maps tiles [i.e. without API Key] is a clear violation of the Google Maps Platform Terms of Service Section 3.2.4a https://cloud.google.com/maps-platform/terms/#3-license."

@King_Edward On the Docker image, you have to modify the /app/metabase.jar (it’s just a zip-file) and within that you’ll find ./frontend_client/(embed|index|public).html
The index_template.html is used to generate those files, when Metabase is being build.
I would definitely recommend a reverse-proxy, otherwise you’ll have to manually make changes on every upgrade.

Ok, So I spend some time on this and finally found a solution. 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/{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.

I posted this on Stacked Overflow as well.

1 Like