Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Map within fragment

I want to enclose the map within a Fragment. I tried with 2 approaches.

  1. Enclosing map within fragment using Tabhost. But this uses LocalActivityManager which is a deprecated method. I wanted to use without this method, but unable to proceed.

It is throwing IllegalException when I try to call mTabHost.setup(); for setting up my tabs.

  1. Directly using Fragment and FragmentActivity : Referred here . But unable to use methods to fetch the Current User Location.

Kindly let me know how to go about it.

like image 966
user562082 Avatar asked Jun 19 '26 22:06

user562082


2 Answers

A MapActivity can load a Fragment that contains a MapView, on API Level 11 and higher -- see this sample project for an example of how this is done.

However, this does not work with the fragment backport in the Android Support package. There is no good way to handle that, unfortunately, at this time.

like image 158
CommonsWare Avatar answered Jun 21 '26 12:06

CommonsWare


Google released the Map API Version 2. This gives you a MapFragment and a SupportMapFragment. This allows you to add a Map without extending MapActivity.

like image 24
Janusz Avatar answered Jun 21 '26 11:06

Janusz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!