Skip to content

Drawing on Google Maps Android API v2

This post is a recipe for drawing various things on the Google MapView on Android. It assumes that you have a MapView (or MapFragment) set up per this post

Code below assumes that mGMap is the google map object, obtained from:

MapFragment mf = (MapFragment) (getFragmentManager().findFragmentById(;
mGMap = mf.getMap();

Draw Marker

// draw marker
MarkerOptions mp = new MarkerOptions();
mp.title("Test Marker");

Center Camera on Location (and Animate)

// center camera
CameraPosition cp = new CameraPosition.Builder()

Draw Line

// draw line
if (prevPos != null) {
	mGMap.addPolyline(new PolylineOptions()
	.add(prevPos, pos)

Posted in Android. Tagged with , , , .