GMap Bearing rotation in smooth motion (avoid jerky effect when changing bearing values)

前端 未结 3 745
伪装坚强ぢ
伪装坚强ぢ 2021-01-04 03:23

I want to rotate GMap by changing the bearing angle value, so the camera rotates around the center point (360-Degree one full round ). When we change the bearing, there is a

3条回答
  •  孤城傲影
    2021-01-04 03:25

    Giving this as an answer as a comment would be rather hard to read; this is taken from the google documentation.

    Consider this code:

    CameraPosition cameraPosition = new CameraPosition.Builder()
        .target(MOUNTAIN_VIEW)      // Sets the center of the map to Mountain View
        .zoom(17)                   // Sets the zoom
        .bearing(90)                // Sets the orientation of the camera to east
        .tilt(30)                   // Sets the tilt of the camera to 30 degrees
        .build();                   // Creates a CameraPosition from the builder
    map.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
    

    This code creates a new camera position, and that's exactly what you're trying to mutate: the bearing of the camera. So if you create a new camera position like this:

    CameraPosition cameraPosition = new CameraPosition.Builder()
        .bearing(50)
        .build();
    

    and then animate the camera to that position:

    map.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
    

    That should do the trick. To give some more information on what you will need to use as bearing:

    a bearing of 90 degrees results in a map where the upwards direction points due east.

    Good luck.

提交回复
热议问题