Google Map API V2 - How do I keep a marker in the center of the screen while user is scrolling the map?

后端 未结 7 1783
执念已碎
执念已碎 2020-12-10 02:00

Google Map API V2 - How do I keep a marker in the center of the screen while user is scrolling the map ?

My purpose is to let user choose a location. I use the follo

7条回答
  •  伪装坚强ぢ
    2020-12-10 02:46

    Marker marker;//have a instance variable marker
    mMap.setOnCameraChangeListener(new OnCameraChangeListener();
    public void onCameraChange(CameraPosition cameraPosition) {   
                    MarkerOptions options = new MarkerOptions()
                                            .position(cameraPosition.target);
    
                     if(marker != null){marker.remove();}
                     marker = mMap.addMarker(options);
    }
    

    This won't be smooth because,onCameraChange call back is not called during intermediate frames.It is called only after the camera is changed completely.

提交回复
热议问题