androidandroid-maps-v2

How to change the position of a Marker on a Android Map v2


I need to do the following: I have a Marker on the map and I need to change the position of it. So I tried the following:

MarkerOptions a = new MarkerOptions()
            .position(new LatLng(50,6)));
        map.addMarker(a);
        a.position(new LatLng(50,5));

where map is a GoogleMap. I think I have to refresh the map or somthing equal?


Solution

  • Found the solution, Need to do it like this:

    MarkerOptions a = new MarkerOptions()
        .position(new LatLng(50,6)));
    Marker m = map.addMarker(a);
    m.setPosition(new LatLng(50,5));