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

China☆狼群 提交于 2019-12-12 18:07:48

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!