JonniBravo
JonniBravo

Reputation: 1071

Launch Google Maps from app

I have setup my app to launch Google maps to a set location using the code below, but the map displays zoomed full and you cant see any roads you have to zoom out manually to see anything. How can I set the zoom level with the code below I've tried setZoom(16); but this has no effect.

if (mapnav == 10) {
   String uri = "geo: 53.777969,-1.571474";        
   setZoom(16);

   Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));

   startActivity(i);}

Also can I launch into Directions instead of the map

Upvotes: 2

Views: 5879

Answers (1)

Colin Hebert
Colin Hebert

Reputation: 93197

You can specify a zoom level in your URI with for example "geo: 53.777969,-1.571474?z=23"

Google Maps

geo:latitude,longitude
geo:latitude,longitude?z=zoom
geo:0,0?q=my+street+address
geo:0,0?q=business+near+city

VIEW

Opens the Maps application to the given location or query. The Geo URI scheme (not fully supported) is currently under development.
The z field specifies the zoom level. A zoom level of 1 shows the whole Earth, centered at the given lat,lng. A zoom level of 2 shows a quarter of the Earth, and so on. The highest zoom level is 23. A larger zoom level will be clamped to 23.

For the google navigation part you can use "google.navigation:q="+location where location are the coordinates. The intent Intent.ACTION_VIEW.


Resources :

On the same topic :

Upvotes: 5

Related Questions