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.
Related
I have been trying to find a way to get this done but keep running into issues.
I want to be able to have a map in a frame (it does not necessarily have to be a FrameLayout, i just want it framed so it only takes up 1/2 or 2/3 the screen) ontop of my current layout and to have the current activity still displayed behind it.
In a perfect world, i would like to attach this view to a button and animation so clicking the button causes this view to slide in from offscreen left and settle in the center of my current activity, while still being fully clickable and and the map being useable (can zoom, click, etc.)
I have tried doing this with a fragment, but the issue is that the Activity i am working in is already extending another class that is absolutely necessary, so i can not extend Fragment or FragmentActivity, so i cant use fragments (unless i am missing a work around to achieve this.)
The same goes for MapActivity and MapView, cant extend the MapActivity class so cant use MapView.
Any time i try to inflate a map view or anything i get runtime errors because my activity does not extend the pertinent class. Is there a work around for this?
Does anyone have a suggestion as to how i can get this map to display the way i am looking for?
This is easily achieved in iOS but i cant seem to figure it out in Android.
Thank you in advance
EDIT
I am not looking for code, unless you have a specific example in which case obviously code is very helpful, but i am looking for an idea as to how to achieve this -- a push in the right direction if you will -- so i can write the code myself.
Solved this by adding a frame layout to my "Main" activity. That frame layout's class was set to my Map class. The Map class extended FragmentActivity and its contentView is set to my map_fragment.xml. The map_fragment.xml contains only a fragment and that fragments name is set to com.google.android.....SupportMapFragment.
After setting up my project in this way as well as setting up the correct screen layouts and dimensions for sizing purposes as well as defining a GoogleMap in my Map class, i was able to display a fully usable and interactive map over my "Main" activity.
I overrode some Activity transition animations to the Map class and got my project working 100% how i want it to.
I didnt ask for code, so i will not supply any code, but this process is pretty straight-forward if you follow the same process as i have described above.
In my application i am using 5 fragments, one fragment contains map. As per size limitation i cannot show all pin with zoom level 15 with marker.
So i want to display a bigger version of map fragment in side a alert box once use click on map fragment similar to this
How i can achieve this. Any help will be appreciated. Thanks in advance.
You have several approaches you can use.
1) use an activity with dialog theme
2) jsut declare a floating FrameLayout inside your main layout and add a MapFragment to it.
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 would like to make the google maps viewable in another activity, that is, it does not take the entire screen. Is it possible to embed a google map map activty in another activity, so that, let's say, it takes half or 3/4 of the screen please?
Thanks in advance!
Try this:
http://mobiforge.com/developing/story/using-google-maps-android
You can use MapView as any other view - position and size as you like.
If you want to place MapView into ScrollView here is good solution to make sure it works correctly: MapView inside a ScrollView?
You can include MapView in layout and code for the same in MapActivity with the portion you want for it.
Why do you want for it in another activity?
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