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
Related
As we seen in above diagram, This is related to fragments and Maps.
If we click on left side fragment, The corresponding details are shown in detailview and Map view Which are in tabhost (Right side Fragment). In the mapview we shown markers for particular data.
Problem : If we click on another item on left fragment, the right side fragment should be replaced with new details. I was able to do it.**But,the older objects of Map are still in memory.****
and some times showing, due to java.lang.ref.FinalizerRefernce
I examined with eclipse MAT. The screen shots are also attached below.
Every time when reloads, heap memory consumption is increasing..
And I followed the map lifecycle. During destroying of frament, I added the code like..
mapView.onDestroy() also.
Can anybody tell me where i was doing wrong?
Thanks Inadvance.
I have FragmentActivity responsible for taking pictures and in layout for it I have surfaceView responible for showing camera preview, two more layouts (Layout A and Layout B) that are visible="gone" on start and layout B that has map fragment in it.
When you take a picture, layout A become visible, and you can swicth from it to the layout B. When you do that, map fragment doesn't show up, instead of it you can see camera preview in the area that was intended for tha map. If I than go on some other activity and come back to this one, map is there.
I have one more activity in this app with only map in it and it works fine.
If anyone had this problem please help!
Problem was that SurfaceView and SupportMapFragment both use openGL and if you want to use one of (visible) than you have to remove (gone) the other.
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.
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.
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">