Skip to content Skip to sidebar Skip to footer

Differences Between Mapview, Mapframent And Supportmapfragment

I would know the differences because I'm developing an app and I would introduce Google Map API v2 for compiling above Android 2.3. Which should I use?

Solution 1:

MapView:

A View which displays a map (with data obtained from the Google Maps service). When focused, it will capture key-presses and touch gestures to move the map.

Users of this class must forward all the life cycle methods from the Activity or Fragment containing this view to the corresponding ones in this class.

Use it if you are going to add a map into a fragment. (you need to update each lifecycle to MapView).

See Google API Documentation

MapFragment:

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.

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).

See Google API Documentation.

SupportMapFragment:

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. Being a fragment, this component can be added to an activity's layout file simply

Use SupportMapFragment if you are targeting Android API levels below 12.

See Google API Documentation.

Post a Comment for "Differences Between Mapview, Mapframent And Supportmapfragment"