3

I need to create a custom class that extends MapFragment. I am not sure how to instantiatemy new class, so that MapFragment will be instantiated in the correct way.

MapFragment are suppose to be created by doing

MapFragment.newInstance(options)

If I have my own class, that extends MapFragment

public class MyMapFragment extends MapFragment {



}

How do I go about to instantiate MyMapFragment, or is this approach all together wrong?

  • An answer to the question "Set GoogleMapOptions for the MapFragment subclass" (http://stackoverflow.com/a/24687803/262789) should provide what you need. – Jade Apr 23 '15 at 13:33

2 Answers2

0

It's likely you can accomplish what you need using the built in MapFragment (although it isn't clear WHY you want to subclass the fragment).

Use a standard MapFragment, use map = mapFragment.getMap() to access the underlying GoogleMap, and use map.setXXXListener to catch events.

If you really need lower-level access for some reason, you are going to have to extend Fragment and build and manage a GoogleMap yourself.

dokkaebi
  • 9,004
  • 3
  • 42
  • 60
0

Here is what i tried to do:

ClassNotFoundException reading a Serializable object in a class extending MapFragment in onSaveInstanceState

But i got stuck at a point when i tried to save some data using onSaveInstanceState. If you dont want to store data to reuse it, the source code explains how i created the class and how it was loaded.

Community
  • 1
  • 1
Jovy
  • 101
  • 1
  • 4