Background
I have successfuflly added the new map api v2.0 to a ViewPager and the map loads fine. I am using the FragmentViewPager. I run into troub
Just tried like this and it works.
public class MyMapFragment extends SupportMapFragment {
private List<MarkerOptions> mMarkers;
public static MyMapFragment create(GoogleMapOptions options, ArrayList<MarkerOptions> markers) {
MyMapFragment fragment = new MyMapFragment();
Bundle args = new Bundle();
args.putParcelable("MapOptions", options); //obtained by decompiling google-play-services.jar
args.putParcelableArrayList("markers", markers);
fragment.setArguments(args);
return fragment;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Hacky and ugly but it works
ArrayList<Parcelable> list = getArguments().getParcelableArrayList("markers");
mMarkers = new ArrayList<MarkerOptions>(list.size());
for (Parcelable parcelable : list) {
mMarkers.add((MarkerOptions) parcelable);
}
}
@Override
public void onResume() {
super.onResume();
GoogleMap mMap = super.getMap();
//add the markers
if (mMap != null) {
for (MarkerOptions marker : mMarkers) {
mMap.addMarker(marker);
}
}
}
}