Android - Two Maps in one App - android

I got an App where on main screen show google mapView. But I need also in details view show the map.
I know that it is impossible to run two maps simultaneously. Everything is working when I want to show something on the main map and later in detailed view, but when I come back to main one, it stops.
How to stop main map and come back later to it?

Having two maps in one app produces many weird application behavior. For example, Ive had overlays from one map show up in the second map.
That said, it is possible to have two maps in one application without the above happening. What you need to do is to specify a new process for the second mapview:
<activity
android:label="#string/app_name"
android:name=".SecondMapActivityName"
android:process=":SecondMapProcess"
>
</activity>
The above code lies in the manifest and is for the activity containing the second MapView. This way a new process starts for this activity within the same app and both your maps behave as they should.

What I do is create a new mapview in code each time I want to use it (yes overhead but it works ;)).
mMapView = new MapView(this, MAPS_KEY);
setContentView(mMapView);
mMapView.invalidate();

If you don't need to interact with your other map, you can use it in lite mode:
https://developers.google.com/maps/documentation/android-api/lite
It creates a bitmap image that looks like a map.

Related

Is it possible to use Androids GoogleMap in a background service?

I need to generate thumbnails of different maps so they can be displayed in a list, which gives an overview over all available maps in my App.
For the generation of a map screenshot I found the snapshot-method in GoogleMap.
Now I would like to run the thumbnail Generation in a background thread.
According to the documentation you need to call getMapon a MapViewor a MapFragment to instantiate a GoogleMap.
Is there a different way of getting hold of a GoogleMap-Object, instead of using the View or the Fragment? Is there something like a OffScreenRenderer that would allow to use the GoogleMap without actually displaying it on the Screen and ideally running it not in the MainThread?
For thumbnails I use Static Maps API V2 and Android-Universal-Image-Loader.
But you want to show those list thumbnails some time in the future, right? If yes then generate them when showing (and cache after showing).

How to solve Google Map zoom level issue in android

Hi guys I'm developing an Android application which contains two google maps that are displayed one after the other. I have written two Activities for that namely:
CustomItemizedOverlay.java
CurrentLocations.java
The both of the above two Activities extends MapActivity.
Here first iam displaying CustomItemizedOverlay.java which consists of multiple markers and in this Activity i have an Image when click on that image iam displaying CurrentLocation.java which shows current location with a Marker. When I click the Hardware back button in the CurrentLocation.java I'm finishing this Activity and going to CustomItemizedOverlay.
In this Activity previously I have displayed several Markers but now I'm not able to see the Markers, whenever I'm decreasing the Zoom level then I'm able to see the markers. From this CustomItemizedOverly Activity if I go again to CurrentLocation Activity this time I'm not able to see the CurrentLocation Marker too except the case when I decrease the zoom level.
I don't understand why because I'm restarting the Activity. Any ideas?
I've had a few issues with the map view not refreshing in the past. From the sounds of it your map view isn't redrawing properly when the activity comes back into the foreground? If so try calling mapview.invalidate() in the onResume() override of the activity to force a redraw.

Android MapView Changing in Another View

I have two activity groups that contain a list that go to a detail view. The detail activty extends a mapactivity. Once I set the lat/long and add the point and center it everything works great. If I go to the other activity to do the same thing, both maps are changing with each lat/long change. The code and view xml are seperate, so why are both maps changing to the same lat/long?
If you look at the docs for MapActivity, it says: only one MapActivity is supported per process. Ignoring this causes all sorts of problems besides the ones you are experiencing. The workaround is to put one of the MapActivities in a separate process. To do this modify the manifest entry for one of your activities and add the android:process attribute, like:
<activity android:name="MapActivity2" android:process=":MapActivity2">
Note that there are downsides to putting one of the activities in a separate process.

Android: Bottom of Google Maps gets black inside the application

I have one Map on my main activity and It works fine. Recently I added another small map view on one of my sub activities using the same google map key. Now when I press back after looking at the map on sub activity, it returns to the main view and bottom of the map on main activity turns black. See the attached image.
Is there anyone who has faced this problem and know why sometimes bottom of map turns balck?
You can only have 1 map activity per process.
http://code.google.com/android/add-ons/google-apis/reference/com/google/android/maps/MapActivity.html

Problems when my googlemaps view activity regain the focus (map with black zone in down part of the window)

i have a problem with my app, it haves a lot of activitys, two of them haves googlemap views. My A activity haves a full mapview and my B activity haves a small map view. OK, when i am on the B activity and press back key somethimes until i return to my A activity, the map of my A activity shows with errors, with a black zone in the down part of the window. THis only happens when i press back from the B activity.
Because this, i need to implement/override onResume() method of A to RESTART THE ACTIVITY TO REPAINT ALL FROM SRATCH.... LIKE TO DO AGAIN ONCREATE METHOD, but i think i can't call it again... or i can?
wich code i have to put to repaint all the window from scratch ?
i tryed with all this:
-mapView.requestLayout() --> it works a little, repaints the map but with the zoom and showing the last map showed on B activity... no sense :S i dont want that. Are different maps, not have to show the same coordinates and zoom, each one have his own.
-mapView.invalidate() --> doesn't works
-mapView.postInvaldiate() --> doesn't works
Having multiple maps (MapViews) running in the same process is not adviced. Typically, using the default configuration, all Activities (including MapActivities) run within the same process.
According to the api docs, located here
http://code.google.com/android/add-ons/google-apis/reference/com/google/android/maps/MapActivity.html
Only one MapActivity is supported per process. Multiple MapActivities running simultaneously are likely to interfere in unexpected and undesired ways.
Issues I encountered with multiple MapViews within the same process :
Although it appears that there are 2
different maps in the app, changes in
the first map (ex: moving it to a
certain position, toggling sattelite
view) also got reflected in the
second map, as if it was the same
map.
On occasion, map tiles were not
getting loaded properly. Portions of
the map, or the complete map remained
empty.
In Logcat, apache http connection pool errors were logged (originating from the TilesProvider)
There is a defect logged here : http://code.google.com/p/android/issues/detail?id=3756
A solution / workaround is to host your maps in different processes :
<activity android:name=".MapView1" android:process=":MapView1">
<activity android:name=".MapView2" android:process=":MapView2">

Categories

Resources