Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 673
Viherbar Avatar asked Apr 28 '15 12:04

Viherbar


1 Answers

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.

like image 199
Ferdous Ahamed Avatar answered Sep 29 '22 16:09

Ferdous Ahamed