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?
A View which displays a map (with data obtained from the Google Maps service). When focused, it will capture keypresses and touch gestures to move the map.
public class MapFragment extends Fragment. A Map component in an app. This fragment is the simplest way to place a map in an application. It's a wrapper around a view of a map to automatically handle the necessary life cycle needs.
Callback interface for when the map is ready to be used. Once an instance of this interface is set on a MapFragment or MapView object, the onMapReady(GoogleMap) method is triggered when the map is ready to be used and provides a non-null instance of GoogleMap .
To use a GoogleMap object in your app, you must use either a SupportMapFragment or MapView object as a container object for the map and then retrieve the GoogleMap object from the container.
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
MapView
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With