Google Map API V2 - How do I keep a marker in the center of the screen while user is scrolling the map?
I do not think that you can actually keep a marker in the middle of the screen and float it easily. My suggestion is to trick your user. Add your marker image onto the map like a button. you can place it in the middle of the screen using the xml layout. Then when your user selects a location just retrieve the gps coordinates from the middle of the screen.
On a side note you could also just make your marker draggable Then the user could drag it around the map.
mMap.addMarker(new MarkerOptions().position(coordinate)
.title("Your Title")
.snippet("Please move the marker if needed.")
.draggable(true));
How about?
mMap.setOnCameraChangeListener(new OnCameraChangeListener() {
public void onCameraChange(CameraPosition arg0) {
mMap.clear();
mMap.addMarker(new MarkerOptions().position(arg0.target));
}
});
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...