Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

  1. I am trying to execute a static map from a cell on a google sheet via a google script. My end goal is to load my own map (contained in a .kmz that was downloaded from google my maps) and display a pin to locate a user-defined zone (colored polygon on map).

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:

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
259 views
Welcome To Ask or Share your Answers For Others

1 Answer

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

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

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) 

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...