【问题标题】:Empty OsmDroid Map? Where to custom the new map?空的 OsmDroid 地图?在哪里自定义新地图?
【发布时间】:2014-08-23 09:24:14
【问题描述】:

最近尝试关注these steps: website.

以随意的方式将地图添加到屏幕中 使用此代码:

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);



    }}

还有这个, 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>

但不幸的是,上面的代码似乎什么也没给我。 除了地图视图之外,所有组件似乎都很正常,它似乎什么都没有(空的)。 而且我找不到在哪里自定义我自己的地图的地图。有什么线索吗?

【问题讨论】:

  • 您是否尝试过使用@+id/frm_lay 为FrameLayout 设置高度以查看是否出现任何内容?

标签: java android map gps osmdroid


【解决方案1】:

您没有按照您提到的教程进行操作。 从跟随它开始,让它工作。然后,您可以引入更改。

“我找不到在哪里自定义我自己的地图的地图。” =>这是一个独特的问题,所以创建一个单独的问题。如果你想要一个答案,那就更(更)清楚你想要什么。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-07-27
    • 1970-01-01
    • 1970-01-01
    • 2016-12-06
    • 2013-03-27
    相关资源
    最近更新 更多