Question

This is my code:

public class MainActivity extends Activity {

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        GoogleMap map = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();

        map.setMyLocationEnabled(true);

        LocationManager locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
        Criteria criteria = new Criteria();
        String provider = locationManager.getBestProvider(criteria, true);

        Location myLocation = locationManager.getLastKnownLocation(provider);

        map.setMapType(GoogleMap.MAP_TYPE_NORMAL);

        double latitude = myLocation.getLatitude();
        double longitude = myLocation.getLongitude();

        final LatLng maposition = new LatLng(latitude, longitude);      
        map.moveCamera(CameraUpdateFactory.newLatLng(maposition));
        map.animateCamera(CameraUpdateFactory.zoomTo(16));
        map.addMarker(new MarkerOptions().title("MONKEY.D").snippet("Hace la fiesta").position(maposition).icon(BitmapDescriptorFactory));}}

How can I move this marker "maposition" ?

Was it helpful?

Solution

map.addMarker(...)

returns a reference to Marker object. And that objects has a

setPosition(LatLng latlng)

method. So use it to move this marker wherever you want.

OTHER TIPS

 mMap.addMarker(new MarkerOptions()
            .title("title")
            .icon(BitmapDescriptorFactory.fromResource(R.drawable.marker))
            .position(new LatLng(latitude, longitude));
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top