Google map Android api V2 activate compass and tilt mode

De openkb
Aller à : Navigation, rechercher

Sommaire

Questions

I m developing an Android application that displays a Google map. I want this map to be centered on the user position, and rotated to the user direction and tilt. The behavior described can be seen in Google Maps application; When you click on the Location button once, it centers the map on your position. When clicked a second time, it achieves the described behavior.

How can I achieve this with the Google Maps API? Can I activate it programmatically?
Any suggestions?

Answers

In order to set the location as the center of the map, use:

map.moveCamera(CameraUpdateFactory.newLatLng(new LatLng(lat, lng)));

Then you should really take a look at CameraPosition.Builder() class from the docs. You will get all the answers there, but I ll show you an example of how it s being used:

CameraPosition cameraPosition = new CameraPosition.Builder().
            target(location).
            tilt(degrees).
            zoom(zoom).
            bearing(bearing).
            build();
map.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));

Source

License : cc by-sa 3.0

http://stackoverflow.com/questions/17423790/google-map-android-api-v2-activate-compass-and-tilt-mode

Related

Outils personnels
Espaces de noms

Variantes
Actions
Navigation
Outils