Advertisement
Guest User

Untitled

a guest
Mar 1st, 2015
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.34 KB | None | 0 0
  1. public class MainActivity extends Activity {
  2. Button centerButton;
  3. MapView mapView;
  4.  
  5. @Override
  6. protected void onCreate(Bundle savedInstanceState) {
  7. super.onCreate(savedInstanceState);
  8.  
  9. // Create the main map view
  10. mapFragment = new MapFragment();
  11. mapFragment.setArguments(args);
  12. getFragmentManager().beginTransaction()
  13. .add(R.id.main_content, mapFragment).commit();
  14. }
  15.  
  16. /*
  17. * This function centers the map. It is just one of many
  18. * that stops working on device rotation.
  19. */
  20. public void centerMap(View view) {
  21. mapFragment.getMapView().getController().setCenter(new GeoPoint(12.0,0.0));
  22. Lod.d(TAG, "Reacting and working.");
  23. }
  24. }
  25.  
  26. <RelativeLayout
  27. xmlns:android="http://schemas.android.com/apk/res/android"
  28. android:layout_width="match_parent"
  29. android:layout_height="match_parent"
  30. android:id="@+id/d_layout"
  31. >
  32.  
  33. <!-- The main content view -->
  34. <LinearLayout
  35. android:layout_width="match_parent"
  36. android:layout_height="match_parent"
  37. android:orientation="vertical"
  38. android:id="@+id/main_content">
  39.  
  40. </LinearLayout>
  41.  
  42. <LinearLayout
  43. android:baselineAligned="false"
  44. android:layout_width="match_parent"
  45. android:layout_height="match_parent"
  46. android:orientation="horizontal"
  47. >
  48.  
  49. <!-- This is the layout for other control items-->
  50. <LinearLayout
  51. android:layout_width="match_parent"
  52. android:layout_height="wrap_content"
  53. android:orientation="vertical"
  54. android:id="@+id/sub"
  55. android:layout_gravity="top"
  56. android:paddingLeft="20dp"
  57. android:paddingRight="20dp"
  58. >
  59. </LinearLayout>
  60.  
  61. </LinearLayout>
  62.  
  63.  
  64. </RelativeLayout>
  65.  
  66. <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
  67. android:layout_width="match_parent"
  68. android:layout_height="match_parent"
  69. android:orientation="vertical" >
  70. <org.osmdroid.MapView
  71. android:id="@+id/mapfragment"
  72. android:layout_width="match_parent"
  73. android:layout_height="match_parent"
  74. tilesource="Mapnik"
  75. />
  76. <Button
  77. android:layout_gravity="right|bottom"
  78. android:layout_width="wrap_content"
  79. android:layout_height="wrap_content"
  80. android:id="@+id/center_button"
  81. android:text="center"
  82. android:onClick="centerMap"
  83. />
  84. </FrameLayout>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement