Adnan Adnan - 3 months ago 54
Android Question

How to display static google map on android imageview?

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?


Google offer the static map API for free.

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.

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 = "" + latEiffelTower + "," + lngEiffelTower + "&zoom=15&size=200x200&sensor=false"

StackOverflow already have some answer on how to download an image from the web in order to display it in an imageview:

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