Problème recupération de la position actuel googlemap android
BOnjour,
j'ai une application dans laquelle j'utilise la géolocalisation et j'aimerais faire une chose, c'est à dire que lorsque l'on clique sur un bouton "se localiser", la map nous affiche notre position actuelle .
Voici mon morceau de code :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
Location mCurrentLocation ;
.......
private final LatLng localisation = new LatLng(mCurrentLocation.getLatitude(),mCurrentLocation.getLongitude());
map = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
......
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
map.setMapType(GoogleMap.MAP_TYPE_NORMAL);
CameraUpdate update = CameraUpdateFactory.newLatLngZoom(localisation ,11);
map.animateCamera(update);
} |
en gros j'essaye d'avoir la position courante grâce aux méthodes getLatitude et getLongitude , mais ça marche pas, j'ai un nullpointer exception lorsque j'execute le programme, .
Merci pour vos conseils et votre aide