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

后端 未结 7 1781
执念已碎
执念已碎 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:42

    Option 1

    I think the best option is move marker, when user move map...

    googleMap.setOnCameraMoveListener(new GoogleMap.OnCameraMoveListener() {
                @Override
                public void onCameraMove() {
                    marker.setPosition(googleMap.getCameraPosition().target);//to center in map
                }
            });
    //note marker is global
    

    Option 2

    or simple, in your layout, with relative layout put the fragment, and in above the icon of marker, you will calculate that marker will always in the middle of the map...

    i think this is complicate, by size of screens, but the phone will not move every time the marker...

提交回复
热议问题