The Google Maps Activity

One of the applications that comes with Android is Google Maps itself. If it's appropriate, you can start Google Maps from your application the same way you start any other Activity:

1. Create an Intent (new Intent(String action, Uri uri)) that says you need to display a Map. The parameters are:

• An action, for which you must specify ACTION_VIEW.

• A Uri, for which you should specify one of the following URI Schemes, substituting your data:

—geo:latitude,longitude

—geo:latitude,longitude?z=zoom

—geo:0,0?qmy_street_address

—geo:0,0?qbusiness_near_city

2. Call startActivity(Intent intent), using the Intent you just created.

An example that creates a map is:

Intent intent = new Intent(ACTION_VIEW, "geo:37.422006,-122.084095"); startActivity(intent);

This is certainly easy, and gets you all the power of Google Maps, but you can't really integrate the map into your application this way. Google Maps is an application unto itself, and there's no way for you to change anything about the user interface or add overlay graphics to the map to point out whatever is of interest to your users. Android provides more flexible packages to add that power.

0 0

Post a comment