androidandroid-maps

Custom navigation in maps


How do I add a feature in the map activity in my Android app that allows users to move to the west, east, north, south of the map by clicking on buttons placed by me on the map?

The buttons are on the edge of the activity as shown in the pic here.


Solution

  • in your case

    int step = 100;
    

    Move east

    CameraUpdate update = CameraUpdateFactory.scrollBy(step, 0);
    googleMap.moveCamera(update);
    

    Move west

    CameraUpdate update = CameraUpdateFactory.scrollBy(-step, 0);
    googleMap.moveCamera(update);
    

    Move south

    CameraUpdate update = CameraUpdateFactory.scrollBy(0, step);
    googleMap.moveCamera(update);
    

    Move north

    CameraUpdate update = CameraUpdateFactory.scrollBy(0, -step);
    googleMap.moveCamera(update);