Empty OsmDroid Map? Where to custom the new map?

折月煮酒 提交于 2019-12-25 03:06:56

问题


Recently I tried to follow these steps: website.

with the casual way of adding the map to be visible into the screen using this code:

GPSTrackerActivity.java

public class GPSTrackerActivity extends Activity {

    private SDCardHandler SDTool;
    private ToastSender ToastObject;

    private FrameLayout frm_lay;
    private MapView myOpenMapView;
    private MapController myMapController;

    @Override
    protected void onCreate(Bundle in) {
        super.onCreate(in);
        setContentView(R.layout.activity_gpstracker);

        SDTool = new SDCardHandler();
        ToastObject = new ToastSender(this);

        frm_lay = (FrameLayout) findViewById(R.id.frm_lay);

        myOpenMapView = (MapView) findViewById(R.id.openmapview);
        myOpenMapView.setBuiltInZoomControls(true);
        myMapController = myOpenMapView.getController();
        myMapController.setZoom(4);



    }}

and this one, activity_gpstracker.xml :

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/gps_title"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:textColor="@color/default_color" />

    <TextView
        android:id="@+id/textView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/gps_desc"
        android:textColor="@color/default_color" />

    <TableLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >

        <TableRow
            android:id="@+id/tableRow1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" >

            <TextView
                android:id="@+id/textView3"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/gps_livtr"
                android:textColor="@color/default_color" />

            <ToggleButton
                android:id="@+id/toggleButton1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" />
        </TableRow>
    </TableLayout>

    <TextView
        android:id="@+id/textView4"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/gps_curloc"
        android:textColor="@color/default_color" />

    <FrameLayout
        android:id="@+id/frm_lay"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >

        <org.osmdroid.views.MapView
            android:id="@+id/openmapview"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent" />

    </FrameLayout>

    <TableLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >

        <TableRow
            android:id="@+id/tableRow2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" >

            <TextView
                android:id="@+id/textView5"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/gps_latitude"
                android:textColor="@color/default_color" />

            <EditText
                android:id="@+id/txt_latitude"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:ems="10"
                android:inputType="text" />
        </TableRow>

        <TableRow
            android:id="@+id/tableRow3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" >

            <TextView
                android:id="@+id/textView6"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/gps_longtitude"
                android:textColor="@color/default_color" />

            <EditText
                android:id="@+id/txt_longtitude"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:ems="10" >

                <requestFocus />
            </EditText>
        </TableRow>

        <TableRow
            android:id="@+id/tableRow5"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" >

            <TextView
                android:id="@+id/textView7"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/gps_altitude"
                android:textColor="@color/default_color" />

            <EditText
                android:id="@+id/txt_altitude"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:ems="10"
                android:inputType="text" />
        </TableRow>
    </TableLayout>

</LinearLayout>

but unfortunately, the code above seems giving me nothing. All components seems normal except the map view, it appeared to be nothing (empty). And i found noway where to custom the map of my own map into it. Any clues?


回答1:


You don't follow the tutorial you mention. Start by following it, and have it working. Then you can introduce changes.

"And i found noway where to custom the map of my own map into it. " => this is a distinct issue, so create a separate question. And if you want an answer, be much (much) more clear about what you want.



来源:https://stackoverflow.com/questions/25460443/empty-osmdroid-map-where-to-custom-the-new-map

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!