Osmdroid, how to create a static overlayitem that remains at the center of the map
I've searched high and low to find out how i can put an overlayitem that is not fixed to a GeoPoint (i.e geographical coordinates), but rather stays at a fixed point in the view (e.g. the center of the MapView) regardless of moving/scrolling in the map.
MapView has an .addView() method. I tried creating a view with a drawable but the view will be fixed on the map, exactly like an overlayitem, which is not what i want.
Can anyone help me?
Surely if you just want something fixed to the centre of the display, rather than on the mapView, you're going about it wrong. overlayItems ARE tied to GeoPoints, that's their purpose.
just create whatever it is as a new, normal, android view object of whatever type, and add it to the main view, on top of your MapView, laid out wherever you need it?
Make a framelayout with your map and a View. Fill a background in your view, and center it horizontally and vertically to make the background centered over your map.
<FrameLayout android:id="@+id/form_lin_map" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:layout_gravity="center_horizontal|center_vertical"> <org.osmdroid.views.MapView android:id="@+id/form_mapView" android:layout_width="fill_parent" android:layout_height="220dp" android:enabled="true" android:clickable="true" android:paddingBottom="10dp" /> <View android:id="@+id/form_View" android:layout_width="40dp" android:layout_height="40dp" android:layout_gravity="center_horizontal|center_vertical" android:background="@drawable/cross" /> </FrameLayout>'