尝试启动静态Google Map时出现API错误 [英] Getting an API error when trying to launch a static google map

查看:56
本文介绍了尝试启动静态Google Map时出现API错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  1. 我正在尝试通过Google脚本从Google表格上的单元格执行静态地图.我的最终目标是加载自己的地图(包含在从Google我的地图下载的.kmz中),并显示图钉以定位用户定义的区域(地图上的彩色多边形).

我已经从以前的映射任务中设置了API密钥.

I have an API key already set up from previous mapping tasks.

function getZone() {
  var app = SpreadsheetApp;

  var ss = app.getActiveSpreadsheet().getActiveSheet();

  var address = ss.getRange("A1").getValue();

  var testMap = Maps.newStaticMap().addMarker(address);

  ss.getRange("B1").setValue(testMap.getMapUrl());
}

当我单击电子表格中的链接时,我会收到此错误:

I then receive this error when I click on the link in my spreadsheet:

Google Maps Platform服务器拒绝了您的请求.您必须使用API​​密钥来验证对Google Maps Platform API的每个请求.有关其他信息,请参阅 http://g.co/dev/maps-no-account

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

推荐答案

该错误表示您需要将API密钥附加到静态地图URL.

That error means you need to append the API key to the static map URL.

它应该是现有的URL + & key =" + YOUR_API_KEY

it should be the existing URL +"&key="+YOUR_API_KEY

最终的URL应该是(例如):

The final URL should be (for your example):

http://maps.google.com/maps/api/staticmap?sensor=false&size=512x512&markers=131+Broadview+Avenue+Warrenton+VA&key=YOUR_API_KEY) 

这篇关于尝试启动静态Google Map时出现API错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆