Android - 403 when requesting map image with valid API key

时间:2018-11-16 21:42:23

标签: android google-maps google-static-maps

I'm trying to load a static map API image, but it keeps 403-ing, which seems to be because of an invalid API key (based on the docs https://developers.google.com/maps/documentation/maps-static/error-messages)

I've verified in the console that the API key is valid and non-expired. The url https://maps.googleapis.com/maps/api/staticmap?center=47.3,-122.359&zoom=12&size=411x231&maptype=roadmap&mobile=true&scale=2&key=xxxxx loads fine in the browser, so I take that to mean that the API key is valid.

The API key lives in the AndroidManifest.xml file

<meta-data
        android:name="com.google.android.maps.v2.API_KEY"
        android:value="xxxxx"/>

Anyone else experience this?

2 个答案:

答案 0 :(得分:0)

您可以发布有关如何访问和构建要发送的网址的代码吗?

如果您使用的是高级计划,那么您将需要添加签名元数据字段,如此处所述:https://developers.google.com/maps/documentation/maps-static/get-api-key?hl=en_US#dig-sig-key

答案 1 :(得分:0)

因此,我做了一些挖掘工作,似乎Google在今年6月做出了更改,其中URL现在要求发送密钥。它们不再支持无键使用。这很糟糕,因为它破坏了使用旧结构的旧应用程序版本。