0

在我的地图项目中,我有一张地图,它在主活动中占据了设备的整个屏幕。我在地图上有一些别针。如果我们按下 pin ,它将导致另一个 Activity。我有一张地图,其尺寸是屏幕尺寸的三分之一。如果我们从另一个活动来到主活动。

Main Activity 中的 Map 采用另一个 Activity 中的 Map 大小。

我的主要活动 xml 是 <

?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/mainlayout"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <LinearLayout
        android:id="@+id/linearLayout1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true" >

        <EditText
            android:id="@+id/search"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_weight="1"
            android:ems="10" >

            <requestFocus />
        </EditText>

        <Button
            android:id="@+id/submit"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_weight="3"
            android:text="Search" />
    </LinearLayout>



    <com.xxx.yyy.FireMapView
        android:id="@+id/mapview"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentRight="true"
        android:layout_below="@+id/linearLayout1"
        android:apiKey="xxxxxxxxxxx"
        android:clickable="true" >
    </com.xxx.yyy.FireMapView>

</RelativeLayout>

我的另一个活动 xml 是,

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

    <com.xxx.yyy.FireMapView
        android:id="@+id/mapview1"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_marginBottom="10dp"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="10dp"
        android:layout_marginTop="10dp"
        android:layout_weight="3"
        android:apiKey="xxxxxx"
        android:clickable="true" >
    </com.xxx.yyy.FireMapView>

    <LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/reportentry1"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_weight="1"
        android:orientation="vertical" >

        <LinearLayout
            android:id="@+id/a1"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal" >

            <TextView
                android:id="@+id/add"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:layout_weight="1"
                android:text="Address" />

            <EditText
                android:id="@+id/address"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:layout_weight="1" />
        </LinearLayout>

        <LinearLayout
            android:id="@+id/ft1"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal" >

            <TextView
                android:id="@+id/ft2"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:layout_weight="1"
                android:text="ft" />

            <Spinner
                android:id="@+id/ft3"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:layout_weight="1" />
        </LinearLayout>

        <LinearLayout
            android:id="@+id/c"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal" >

            <TextView
                android:id="@+id/c1"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:layout_weight="1"
                android:text="C" />

            <EditText
                android:id="@+id/c2"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:layout_weight="1"
               />
        </LinearLayout>

        <LinearLayout
            android:id="@+id/p1"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal" >

            <TextView
                android:id="@+id/p2"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:layout_weight="1"
                android:text="p" />

            <EditText
                android:id="@+id/p3"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:layout_weight="1" />
        </LinearLayout>

        <LinearLayout
            android:id="@+id/fc"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal" >

            <TextView
                android:id="@+id/fc1"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:layout_weight="1"
                android:text="fc" />

            <Spinner
                android:id="@+id/fc2"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:layout_weight="1" />
        </LinearLayout>

        <LinearLayout
            android:id="@+id/btn_info"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal" >

            <Button
                android:id="@+id/cancel"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:layout_weight="1"
                android:text="Cancel" />

            <Button
                android:id="@+id/report"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:layout_weight="1"
                android:text="Report" />
        </LinearLayout>
    </LinearLayout>

</LinearLayout>

请给我正确的方法....

谢谢

4

1 回答 1

0

As per docs android maintains one mapview instance per process. So, you can't maintain different mapview instances in single process.

If size is only your problem then while coming back to to your mainactivity call

mapView.getController.zoomIn();

mapView.getController.zoomOut();

in onRestart() of mainactivity.

It's not perfect solution but at least it worked for me.

This issue was already reported http://code.google.com/p/android/issues/detail?id=3756

于 2012-08-03T10:09:33.597 回答