问题
I have latitude and longitude values in a Google Sheet and I want to draw a Google Map URL using App Scripts. I have a paid Google Maps API key but can't find ways to integrate it with my App Scripts code in the Script Editor?
While executing the codes, it shows error message,
"The Google Maps Platform server rejected your request. You must use an API key to authenticate each request to Google Maps Platform APIs. For additional information, please refer to http://g.co/dev/maps-no-account"
The codes are as follows:
function mappingLoc() {
var spreadsheet = SpreadsheetApp.getActive();
var dashboard = spreadsheet.getSheetByName('Dashboard');
var tempdataset = spreadsheet.getSheetByName('TempDataSet');
var data = tempdataset.getLastRow();
var latis = [];
var latis = tempdataset.getRange(2, 4, data).getValues();
var longis = [];
var longis = tempdataset.getRange(2, 5, data).getValues();
//var map = Maps.newStaticMap().addMarker(latis, longis);
var map=latis.reduce((map,[lat],i)=>map.addMarker(Number(lat),Number(longis[i][0])),Maps.newStaticMap());
dashboard.getRange("A71").setValue(map.getMapUrl());
}
回答1:
The free usage of the Static Maps API has limits
See here:
There is also a lmit for Maximum Queries per Second (QPS): 500
In other words:
If you perform more than 100 000 requests per month or more than 500 requests per second you will be required to pay.
If you are interested: Here you can find information about how to set-up a billing account and obtaining an API key for the paid service.
Alternatively:
Reduce the total amount of your requests and especially the request speed to keep using the Static Maps API for free.
来源:https://stackoverflow.com/questions/64040083/showing-errors-while-creating-google-maps-url-from-a-sheets-using-app-scripts