Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class MainActivity extends Activity {
- Button centerButton;
- MapView mapView;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- // Create the main map view
- mapFragment = new MapFragment();
- mapFragment.setArguments(args);
- getFragmentManager().beginTransaction()
- .add(R.id.main_content, mapFragment).commit();
- }
- /*
- * This function centers the map. It is just one of many
- * that stops working on device rotation.
- */
- public void centerMap(View view) {
- mapFragment.getMapView().getController().setCenter(new GeoPoint(12.0,0.0));
- Lod.d(TAG, "Reacting and working.");
- }
- }
- <RelativeLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:id="@+id/d_layout"
- >
- <!-- The main content view -->
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical"
- android:id="@+id/main_content">
- </LinearLayout>
- <LinearLayout
- android:baselineAligned="false"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="horizontal"
- >
- <!-- This is the layout for other control items-->
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="vertical"
- android:id="@+id/sub"
- android:layout_gravity="top"
- android:paddingLeft="20dp"
- android:paddingRight="20dp"
- >
- </LinearLayout>
- </LinearLayout>
- </RelativeLayout>
- <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical" >
- <org.osmdroid.MapView
- android:id="@+id/mapfragment"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- tilesource="Mapnik"
- />
- <Button
- android:layout_gravity="right|bottom"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:id="@+id/center_button"
- android:text="center"
- android:onClick="centerMap"
- />
- </FrameLayout>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement