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?
Asked
Active
Viewed 2.6k times
52

Johnathan Au
- 5,244
- 18
- 70
- 128
2 Answers
58
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.
-
2Thanks, that's encouraging =) – Johnathan Au Mar 06 '13 at 00:32
-
With regards to functionalities that require MapView such as onTouchEvent(MotionEvent event, MapView mapView), would it be possible to implement this with ease in MapFragments? – Johnathan Au Mar 07 '13 at 03:57
-
you can let your FragmentActivity that holder the MapFragment implement onMapClick and onMapLongClick depending on what you want to accomplish. – Emil Adz Mar 07 '13 at 08:17
-
4There does seem to be a MapView in the V2 API: https://developers.google.com/maps/documentation/android/reference/com/google/android/gms/maps/MapView – Brian White Nov 04 '13 at 04:21
-
1I think it's wan't there for the time this answer was written. If I'm not mistaken they added this so you could integrate it in fragments. – Emil Adz Nov 05 '13 at 11:43
-
2So are fragments still the way to go? – Johnathan Au Feb 17 '15 at 08:59
-
Adding Mapview to fragment's oncreateview increases the layout time by least 500ms, Any possible optimizations there? – Tamil Apr 08 '19 at 21:30
39
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).

King of Masses
- 18,405
- 4
- 60
- 77