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?

Answers


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>'

Need Your Help

Java: How does a large amount of MouseListeners compare to pixel / grid division?

java performance swing jlabel mouselistener

Let's say for example you have a list of items or a large grid of components, and you want to implement some sort of hover/rollover mechanism. The easy way to do this would simply be to add a

Can UIImagepickercontroller have multiple Instances at a time

iphone ios uiimagepickercontroller

Here I want to use both front cam and back cam at a time in uiimage picker controller to capture a image, so I am planing to use two objects of cam one with front cam and other with back cam , Is it

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.