问题
I'm trying to keep a marker in the center of the map when a user drags the camera.
I'm currently doing this by using an OnCameraChangeListener like so:
@Override
public void onCameraChange(CameraPosition position) {
marker.setPosition(map.getCameraPosition().target);
}
My problem with this is lag. The marker flickers and doesn't stay in place perfectly until I stop dragging.
I'm assuming a better way of doing this is to add some sort of overlay over-top the map.
Any suggestions?
回答1:
Yes. You are better of putting your MapFragment
or MapView
inside FrameLayout
(or RelativeLayout
) with another ImageView
or anything else and setting its gravity
to center
.
来源:https://stackoverflow.com/questions/16783087/how-do-i-keep-a-google-map-marker-in-the-center-of-the-map-without-lag