When you add some markers to a map using the Google Maps v2 Android API, the markers are not set to the correct positions and do not move when scaling.
When scaling, they come closer to the correct positions, as if they were translated by a factor related to the increase.
What's wrong?
Scaling example:



fragment
public class CenterMapFragment extends Fragment { private GoogleMap mMap; private List<Center> mCenterList; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { return inflater.inflate(R.layout.center_map_fragment, container, false); } @Override public void onActivityCreated (Bundle savedInstanceState){ super.onActivityCreated(savedInstanceState); mMap = ((SupportMapFragment) getActivity().getSupportFragmentManager().findFragmentById(R.id.map)) .getMap(); if (mMap != null) { mCenterList = MyApplication.dbHelper.getAllCenter(); for(Center center : mCenterList){ mMap.addMarker(new MarkerOptions().position(new LatLng(center.lat, center.lng)).icon(BitmapDescriptorFactory .fromResource(R.drawable.myicon))); } } } }
layout
<?xml version="1.0" encoding="utf-8"?> <fragment xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/map" android:name="com.google.android.gms.maps.SupportMapFragment" android:layout_width="match_parent" android:layout_height="match_parent" />
source share