SupportMapFragment Instead of MapFragment

岁酱吖の 提交于 2019-12-12 07:22:10

问题


I want to make an android application that uses Google Maps for Android v2.

I can show a map. I can even navigate and zoom. But, when I want to search for more operations to make, I can't find any.

I want this application to work on API level 8 and above. So, I used SupportMapFragment. I heard that, if I want to make my application to work on API level 8 and above, I have to use SupporMapFragment.

I found examples about MapFragments, but unfortunately, not about SupportMapFragment.

I want to make these operations work in my application, however, they're using MapFragment:

One

Two

Is there a way of doing things like, "add marker", "show my current location", and "take position of the point that I clicked"? (using SupportMapFragment, of course. )

Thank you very much already.


回答1:


Is there a way of doing things like, "add marker", "show my current location", and "take position of the point that I clicked"? (using SupportMapFragment, of course. )

Yes.

Step #1: Add the Android Support package to your app.

Step #2: Have your activities inherit from FragmentActivity from the Android Support package.

Step #3: Change all MapFragment references (Java code and layout XML resources) to SupportMapFragment.

And you're done.

All of my Maps V2 samples use SupportMapFragment, in conjunction with ActionBarSherlock (which is why you will see SherlockFragmentActivity as opposed to FragmentActivity.



来源:https://stackoverflow.com/questions/15693975/supportmapfragment-instead-of-mapfragment

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!