JP_
JP_

Reputation: 1666

How do I keep a Google Map marker in the center of the map without lag?

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?

Upvotes: 2

Views: 1771

Answers (1)

MaciejGórski
MaciejGórski

Reputation: 22232

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.

Upvotes: 4

Related Questions