I don't have much experience in Android and I am facing an issue related to Google map and AutoScrollViewPager. My requirement is like I want to display some screens and each screen has different data and different location on map.
All screens are swipable and swipes automatically too, so I used AutoScrollViewPager for this. In AutoScrollViewPager, I used AutoScrollViewPagerAdapter to add data on screens. Now I want different map on each screen which shows different locations for different screen.
I used SupportMapFragment, MapView for this but both does not allow me create different maps for each screen in adapter. Also Adapter does not have any method related to lifecycle of fragment or activity.
I don't think you would be needing fully functional maps in the ViewPaper. If you are just looking to show the location on the map, you can simply use images for that. Use the Google Static Maps API to get the images for the locations and show them in the ViewPager.
Related
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).
In my ExpandableListView I need to add Google Map on each item.
I tried with putting Map on each item but its giving me inflate exception. And its is also stated that an MapActivity can contain only one MapView.
Is there any other idea to achieve this.
For refrence you can see here.
Your comments regarding MapActivity indicate that you are using Maps V1, which is deprecated. Maps V2 does not require a MapActivity and can have multiple maps.
That being said, your proposed implementation is unlikely to work well, as putting scrollable things in scrollable things can be problematic. It also is rather unrealisitc IMHO -- whoever came up with that design has never used an actual smartphone, as there's no point in having an interactive map that small (again, IMHO).
Consider using static maps (there's a Google API for that somewhere) for inside the ExpandableListView, where a tap on the map brings up the full map, either in your app or in the standard Maps app.
I recommend to not use static map (as for example it's not possible to zoom to particular bounds with newLatLngBounds or add a circle in particular lat/lon).
I recommend to use map fragment in lite mode:
In addition, there is also a new ‘lite mode’ map option, ideal for situations where you want to provide a number of smaller maps, or a map that is so small that meaningful interaction is impractical, such as a thumbnail in a list. A lite mode map is a bitmap image of a map at a specified location and zoom level.
Map fragment can be nested in the list.
I am not sure whether I should be using MapView or stick to using a MapFragment. My application is an app that finds the nearest set of places that are closest to you. I want to be able to add locations, display details of a marker when I press a marker and when the user moves along the map I want to be able to get the coordinates of the center of the map and display the nearest locations within a defined radius. Would I be at a disadvantage if I continue to use MapFragments or should I switch over to MapView while I still have the chance?
First of all, soon the MapView and Google Maps API V1 will stop being supported and won't receive any new updates. And soon all the support will go away.
Secondly, MapFragment may be a little bit less flexible right now, but the map presented, manipulated a looks much better. And I guess that it's functionality will improve with time.
So I would definitely continue to use MapFragments.
UPDATE:
As #Brian White pointed out in the comments, today there is a MapView in Google API V2, and you should use it when you want to embed a map in a fragment. That way you will avoid cascading fragments when you don't have to.
MapFragment
Use it if you want to add a map into Activity class (not fragment
because it will create a nested fragment and it´s a mess).
Use SupportMapFragment if you want to support just android versions
lower than v12.
MapView
Use it if you are going to add a map into a fragment. (you need to
update each lifecicle to MapView).
I looked and searched but don't see an answer but seen many commerical Android apps that can display Google Maps in fragments along with other fragments to display lists of items and other UI fragments.
I do not know if I need to use MapActivity for the whole app since I have a mix of fragments in addition to wanting to display google map in one of the fragments.
Its like this:
Fragment 1: displays Summary of User Settings
Fragment 2: displays the Google Map of user's location
Fragment 3: displays a list of items relevant to the user
I am using a Facebook-like menu UI to navigate among the Fragments. I like to know here is....
Can I mixed these Fragments together without using MapsActivity.
If I do need to use MapsActivity, how do work it with the other fragments that displays other UI elements that doesn't use MapsActivity's functions.
Thanks in advance.
The new Google Maps API V2 for Android has just been released, which includes a MapFragment class, take a look:
https://developers.google.com/maps/documentation/android/
I am trying to make an application in which there are few tabs & one of the tab contains map.
Till now I was able to create the tabs and map on one of the tab. So when I click on the 1st tab I can see the map which shows a default city (Las Vegas).
My question is if now I want to create the same menu items (Search, Directions, Places etc.) which already exists in the default Google Map application in the emulator, Do I need to write the logic for all those menu items?
Its like I want the whole google map application in one of my tab. Is it possible?
I have created the map with zoom-in / zoom-out functionality. Now I want to add the search feature which will search for the place and locate it on the map. So do I need to write the whole code and ui for it? I am feeling like its re-inventing the wheel.
yes, you have to write the logic for all those menu items... the google maps api gives you all the tools to make it, like the map itself, overlays, items, itemized overlays, geocoding, etc. But the higher level functionalitys must be writed by you, using the tools mentioned above.