Android – SupportMapFragment with GoogleMaps API 2.0 giving IllegalArgumentException

You can fix this, if you delete all nested fragments in onDestroyView(). Don’t know if it is a proper solution. public void onDestroyView() { super.onDestroyView(); Fragment fragment = (getFragmentManager().findFragmentById(R.id.map)); FragmentTransaction ft = getActivity().getSupportFragmentManager().beginTransaction(); ft.remove(fragment); ft.commit(); } And inflating them as usual in onCreateView() public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { return inflater.inflate(R.layout.map, container, … Read more

How to show multiple markers on MapFragment in Google Map API v2?

I do it like this to show car positions on the map with markers of different colors: private void addMarkersToMap() { mMap.clear(); for (int i = 0; i < Cars.size(); i++) { LatLng ll = new LatLng(Cars.get(i).getPos().getLat(), Cars.get(i).getPos().getLon()); BitmapDescriptor bitmapMarker; switch (Cars.get(i).getState()) { case 0: bitmapMarker = BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_RED); Log.i(TAG, “RED”); break; case 1: bitmapMarker = … Read more

Error opening SupportMapFragment for second time

Update: As an alternative solution (which I think is much better) you can use a MapView which is described: here I ran across a similar problem while working with a tabs implementation. With Google Maps V2, you are stuck with the SupportMapFragment, so using the MapView isn’t an option. Between juanmeanwhile’s post and comment #1 … Read more