Most developers are familiar with the Google Maps API. In my opinion, its popularity is rooted in the data it serves up. Google Maps tends to be accurate and pretty quick when responding to millions of requests from all around the world.

However, it’s not that easy to work with the Google Maps API. At times I dread going through the associated overhead when the only functionality I need is a static map image of a particular location. Recently I stumbled across another Google Maps related API that is specifically for serving up static images based on a latitude / longitude pair. The best part is it’s dead simple to use.

Follow along with the tutorial below, or download and import the entire project directly into Eclipse. Ready?

1. Create a new Android project in Eclipse. Target SDK 14 (ICS) or better.

2. In your manifest file, you’ll need to add the internet permission.


3. Our layout consists of a text view and an image view wrapped by a linear layout. Make the needed modifications in your /res/layouts folder.


4. We need to set our image view source to the remote URL that is the Google Maps endpoint. We do this in the /src/ file. For the purpose of this demonstration, I’m doing all the work in the on create override. Note that, because the image needs to be downloaded, we have to throw that processing off onto a background thread to keep our UI from stuttering on startup.
package com.example.googlestaticmapssaas;

import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;

import android.os.AsyncTask;
import android.os.Bundle;
import android.widget.ImageView;

public class MainActivity extends Activity {

protected static final String STATIC_MAP_API_ENDPOINT = ",-122.0839445&zoom=15&size=200x200&sensor=false";

protected void onCreate(Bundle savedInstanceState) {
AsyncTask setImageFromUrl = new AsyncTask(){
protected Bitmap doInBackground(Void... params) {
Bitmap bmp = null;
HttpClient httpclient = new DefaultHttpClient();
HttpGet request = new HttpGet(STATIC_MAP_API_ENDPOINT);

InputStream in = null;
try {
in = httpclient.execute(request).getEntity().getContent();
bmp = BitmapFactory.decodeStream(in);
} catch (Exception e) {
return bmp;
protected void onPostExecute(Bitmap bmp) {
if (bmp!=null) {
final ImageView iv = (ImageView) findViewById(;

That’s all there is to it. Though before you copy and paste the code directly into your next app, be sure to read Google’s usage and API key requirements. It’s pretty generous and in most cases should be just fine, but it’s always a good idea to know what you’re agreeing to before your app tops the charts.