How to apply API key to Google Maps Tile server URL? - google-maps-api-3

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.

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.

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:
https://azure.com/maps
https://learn.microsoft.com/en-us/azure/azure-maps/
https://learn.microsoft.com/en-us/rest/api/maps/render/getmaptile

Related

gmapsdistance - which API is needed? [duplicate]

I've started getting this error from a Google Maps widget within a CMS I use:
This API key is not authorized to use this service or API. Places API error: ApiTargetBlockedMapError
The error message provides a helpful link to this page, which includes the following text:
ApiTargetBlockedMapError Error
The Maps JavaScript API has not been authorized for the used API key.
Please check the API restrictions settings of your API key in the
Google Cloud Platform Console.
See API keys in the Google Cloud Platform Console. For more
information, see Using API Keys.
I know Google has tweaked this API in the past, so I went to the console and checked the permissions given for the key I am using. It includes these four permissions, include the Maps JavaScript API permission:
Geocoding API
Maps Embed API
Maps JavaScript API
Maps Static API
The only part not working is the address auto-complete. When I change to Don't Restrict Key mode so the key works with all services, it works fine. Any idea which service checkbox I might be missing? I'm wondering if Google is just displaying the wrong error.
Any ideas?
This is what I did. Updated.
Make sure you have enabled all the next Google Maps Services
If you have key restrictions, make sure you add the services like the next image..
Restart the project. It worked.
It turns out that Google has tweaked their permissions settings without updating the error. I had to give access to the Places API as well for the autocomplete to function.
I've submitted a PR to the CMS widget's documentation:
https://github.com/Frojd/wagtail-geo-widget/pull/59/files

What are the scopes to select in mapbox token access geocoding?

I am using WordPress to build my website. As part of the custom theme, I can choose Mapbox API for my location based search results. However, I am not entirely sure what "scope" to select when creating a token access. Attached is the screenshot. I am looking for the Mapbox Geocoding feature.
All tokens are able to geocode locations, so you do not need to set a particular scope to use the Geocoding API.
Disclaimer - I work at Mapbox.

How do i tell Openrefine to fetch some data trough the google and facebook API (Grel)

I have a list of around 500 foundations and companies and i need to fetch more data like address, description, lat long, email or phone number, from the google and FB APIs I have found something more or less like this, but it won't work in OpenRefine, i need some help please.
I think it is possible to do beacause there is an addon called spotlight for spreadsheets that is able to fetch Google URLs and Lat Long https://www.youtube.com/watch?v=Vj1v3QfyrgA&feature=youtu.be
https://maps.googleapis.com/maps/api/place/findplacefromtext/output?parameters/json?input=value&inputtype=textquery&fields=photos,formatted_address,name,rating,email,geometry&key=YOURKEY
I have created the FB and Google places and google staic map API already. I have tried different queries, but it won't work unless it is in GREL
value.parseJson().geonames[0].lng
value.parseJson().geonames[0].geonameId
value.parseJson().geonames[0].lat
From the error "This API project is not authorized to use this API" the first thing to check is that you have enabled the Places and/or Geocoding API in the Google Developer console, and you have setup an API Key and that it is showing as a credential for the Places API and/or the Geocoding API
Next step, take OpenRefine out of the equation and check you can get a simple API call working in your browser - using one of the Google Places API examples:
https://maps.googleapis.com/maps/api/place/findplacefromtext/json?input=Museum%20of%20Contemporary%20Art%20Australia&inputtype=textquery&fields=photos,formatted_address,name,rating,opening_hours,geometry&key=<INSERT YOUR API KEY HERE>
If that gives you the same error, you know the issue is not with OpenRefine.
If you are still having problems in OpenRefine make sure you are creating URLs in OpenRefine that are valid for the appropriate Google API based on the documentation for that API and that you are using the correct API key.

Google Maps APIs sometimes requires domain verification?

I maintain a WordPress store locator plugin, and this week someone told me it wasn't working anymore. Eventually he fixed it by verifying his domain in the API Console.
That this was a solution to some APIs of Google Maps not working was new to me, and it's also the first time someone told me they fixed it this way.
The problem is that I can't find any information in which scenario verifying your domain fixes a Google Maps API related problem. I read through the Geocode API / Google Maps JavaScript API / Google Places API Web Service pages, but no where do I see something about the need to verify your domain ( I could of course have missed it ).
Does anyone know when you need to verify your domain if you want to use the Google Maps APIs? Normally it works fine without doing it, but in his case it wasn't, and I really like to know what he could possible have done to make it a requirement.
You shouldn't need to verify the domain for using Google Maps API.
You need to generate one API Key for your app so you can use it when you call the Google Map JavaScript API like this:
<script src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&callback=initMap" async defer></script>
Substitute the value YOUR_API_KEY for the one that Google generated for you.

Which set of modules must I use to add a google map linked to an address in Drupal?

Which modules can I use to add a google map to a node with a address entered by a user, so that the location shows on the map? (i'm asking, because I tried a few and could never find one that worked straight off the bat)
Am I allowed to just use google maps?
Will the Google Map API work from my local machine, or will it only work once it's online acting from the registered website address?
You should be able to get what you want using the two following modules :
GMap
The GMap module provides an interface
to the Google Maps API within Drupal.
It integrates with the Location module
to provide users a clickable map for
entering latitude and longitude, as
well as to display maps of Drupal
nodes and users.
Location
The Location module allows real-world
geographic locations to be associated
with Drupal nodes, including people,
places, and other content. The
Location module allows admins to
collect addresses, geocode them
(translate addresses to
lattitude/longitude), and associate
locations with Drupal nodes and users.
About your question 3) :
you can get one API key for your production website, and others for your other environments (like dev, test, staging, ...)
if you don't have the right API key (in dev, for instance), you'll have a not-nice JS alert each time a map loads -- but it should still be displayed.
You can take a look at this entry from Google maps's FAQ : How does the Google Maps APIs key system work?

Resources