0

I have two activities and each has a Mapview. The problem is that when a Mapview changes its center or zoom the other one changes too. I’ve realized that each Mapview has a different id (in xml) and a different name variable. But the problem persist.

The code of each activity is too long to post here, because it implements a lot of functions. But I post the most significant part:

Activity 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" />

Activity 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" />
Víctor Albertos
  • 8,093
  • 5
  • 43
  • 71

1 Answers1

0

If you're using multiple MapViews per process, it might conflict.

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

Only one MapActivity is supported per process. Multiple MapActivities running simultaneously are likely to interfere in unexpected and undesired ways.

And also see my reply on How to use multiple MapActivities/MapViews per Android application/process

But as SpK commented, please provide the code of your activities.

Community
  • 1
  • 1
Mathias Conradt
  • 28,420
  • 21
  • 138
  • 192
  • I just realized that when you assign different processes to the activities that contained the maps it isn’t possible debug the app. Why? Even the debug perspective don't launch. – Víctor Albertos Aug 14 '12 at 01:40
  • Eclipse? Or DDMS standalone? Did you run DDMS standalone? I don't use Eclipse, I use IntelliJ IDEA, or logcat directly. But not sure, haven't worked with different processes in one app for long time. – Mathias Conradt Aug 14 '12 at 04:48