如何显示在Android ImageView的静态谷歌地图? [英] How to display static google map on android imageview?

查看:138
本文介绍了如何显示在Android ImageView的静态谷歌地图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要显示在一个ImageView的一个静态的谷歌地图。类似的东西为WhatsApp的显示共享时的位置。我怎样才能做到这一点?

I want to display a static google map on an imageview. Something similar to "Whatsapp" showing while share the location. How can I do this?

推荐答案

谷歌提供的静态地图API是免费的。

Google offer the static map API for free.

您可以从网上下载一个动态配置的位图,将其存储在文件系统或存储,然后得到一个绘制的它,以便将其设置为ImageView的。

You can download a dynamically configured bitmap from the web, store it on the filesystem or on memory, then get a drawable from it in order to set it to the ImageView.

您需要根据你的坐标的URL来利用这个网址的网页加载数据。为例为200x200的位图显示了巴黎埃菲尔铁塔:

You need to generate an url from your coordinates to load the data from the web using this url. Exemple for a 200x200 bitmap showing the eiffel Tower in Paris:

String latEiffelTower = "48.858235";
String lngEiffelTower = "2.294571";
String url = "http://maps.google.com/maps/api/staticmap?center=" + latEiffelTower + "," + lngEiffelTower + "&zoom=15&size=200x200&sensor=false"

计算器已经对如何从网络,以在ImageView的显示其下载的图像部分答案:<一href="http://stackoverflow.com/search?q=imageview+url+%5Bandroid%5D">http://stackoverflow.com/search?q=imageview+url+%5Bandroid%5D

您可以在这里找到了谷歌静态地图API 的文档。

You can find here the documentation for the Google Static Maps API.

这篇关于如何显示在Android ImageView的静态谷歌地图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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