目前我正在使用GOOGLE Static Map API。但是我的URL超过了为搁浅URL分配的最大字符数。没有GOOGLE Static Map API,有没有办法做到这一点?
您无法通过提供一组位置列表来获取静态地图列表。那将为您提供JSON / XML响应。要获得4年前我在解决方案下使用的某个位置的静态地图。我不确定任何更新的解决方案。看看这个网址
http://maps.google.com/maps/api/staticmap?center=LATITUDE,LONGITUDE&zoom=15&size=200x200&sensor=false
url在这里是棘手的部分,它实际上返回了所请求的lat的静态图像,lang。你也可以指定你想要的图像尺寸,这里我使用200x200。您也可以使用任何ImageLoader,即Glide,picasso来加载该图像
public Bitmap getMapImage(double latitude, double longitude) {
Bitmap bmp = null;
InputStream inputStream = null;
try {
java.net.URL mapUrl = new URL("http://maps.google.com/maps/api/staticmap?center="+latitude+","+longitude+"&zoom=15&size=200x200&sensor=false");
HttpURLConnection httpURLConnection = (HttpURLConnection) mapUrl.openConnection();
inputStream = new BufferedInputStream(httpURLConnection.getInputStream());
bmp = BitmapFactory.decodeStream(inputStream);
inputStream.close();
httpURLConnection.disconnect();
} catch (IllegalStateException e) {
Log.e("tag", e.toString());
} catch (IOException e) {
Log.e("tag", e.toString());
}
return bmp;
}