【发布时间】:2014-08-18 15:18:42
【问题描述】:
直到最近地图视图工作正常,但现在显示为白色,即使我从该位置获取地址,如您在图片中看到的那样
我猜不出来是什么问题
代码是这样的
@覆盖 公共位图 doInBackground(Void... 参数) {
String url = String.format(
"http://maps.google.com/maps/api/staticmap?center=%f,%f&zoom=16&size=%dx300&sensor=false&key=%s",
lat,
lon,
imageWidth,
context.getResources().getString(R.string.mapApiKey2)
);
Log.d("MAP REQUEST ", "" + url);
Bitmap bmp = null;
HttpClient httpclient = new DefaultHttpClient();
HttpGet request = new HttpGet(url);
InputStream in;
try {
in = httpclient.execute(request).getEntity().getContent();
bmp = BitmapFactory.decodeStream(in);
in.close();
} catch (IllegalStateException e) {
} catch (ClientProtocolException e) {
} catch (IOException e) {
}
return bmp;
}
我的 MapView 也可以正常工作,所以问题出在这张静态地图上。
如果我把这段代码中生成的 url 粘贴到我得到的浏览器上
The Google Maps API server rejected your request. This API project is not authorized to use this API. Please ensure that this API is activated in the APIs Console: Learn more: https://code.google.com/apis/console
但我不明白,因为我已经在那里激活了它
【问题讨论】:
-
错误日志中有任何消息吗?
-
没有没有关于地图的错误
-
确保您使用的是正确的 API 密钥
-
我的想法完全正确,@AleksG 但如果没有错误,它就不可能是 API 密钥。
-
@user3249477 请再次仔细查看日志。如果是 API 密钥问题,则只有一行
W/消息。
标签: android google-maps