0

私には2つのアクティビティがあり、それぞれにマップビューがあります。問題は、マップビューがその中心を変更したりズームしたりすると、もう一方も変更されることです。私は、各Mapviewが異なるID(xml内)と異なる名前変数を持っていることに気づきました。しかし、問題は解決しません。

各アクティビティのコードは、多くの関数を実装しているため、ここに投稿するには長すぎます。しかし、私は最も重要な部分を投稿します:

アクティビティA)

    mapview_publish = (MapView) findViewById(R.id.mapview_publish);
    mapview_publish.setBuiltInZoomControls(true);
    mapController = mapview_publish.getController();
    mapController.setZoom(16); /

XML A)

    <com.google.android.maps.MapView
            android:id="@+id/mapview_publish"
            android:layout_width="fill_parent"
            android:layout_height="87dp"
            android:layout_marginLeft="7dp"
            android:layout_marginRight="7dp"
            android:layout_marginTop="12dp"
            android:apiKey="myapikey"
            android:clickable="false" />

アクティビティB)

    mapView = (MapView) findViewById(R.id.mapview);
    mapview.setBuiltInZoomControls(true);
    mapController = mapView.getController();
    mapController.setZoom(20);

XML B)

    <com.google.android.maps.MapView
        android:id="@+id/mapview"
        style="@style/mapView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="40dp"
        android:apiKey="myapikey"
        android:background="@color/black"
        android:clickable="true" />
4

1 に答える 1

0

プロセスごとに複数の MapView を使用している場合、競合する可能性があります。

https://developers.google.com/maps/documentation/android/reference/com/google/android/maps/MapActivity

プロセスごとに 1 つの MapActivity のみがサポートされます。同時に実行されている複数の MapActivity は、予期しない望ましくない方法で干渉する可能性があります。

また、 Android アプリケーション/プロセスごとに複数の MapActivities/MapViews を使用する方法に関する私の返信も参照してください。

しかし、SpK がコメントしたように、あなたの活動のコードを提供してください。

于 2012-08-11T12:43:34.703 に答える