I'm using the Google Maps API v2 for Android, and I want to place a couple of markers on the map. I have the code as following
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
View rootView = inflater.inflate(R.layout.fragment_map, container, false);
MapFragment fm = (MapFragment) getFragmentManager().findFragmentById(R.id.map);
map = fm.getMap();
rootView.findViewById(R.id.map_hybrid).setSelected(true);
map.setMapType(GoogleMap.MAP_TYPE_HYBRID);
map.getUiSettings().setCompassEnabled(true);
CameraPosition cameraPosition = new CameraPosition.Builder()
.target(new LatLng(39.15326,-9.362926))
.zoom(15)
.build();
MapFragment.newInstance(new GoogleMapOptions()
.camera(cameraPosition));
map.addMarker(new MarkerOptions().position(new LatLng(39.15326,-9.362926))
.icon(BitmapDescriptorFactory.fromResource(R.drawable.btn_map_home)));
while(i < mapInfo.size())
{
BitmapDescriptor mapIcon;
... changes the resource of the mapIcon accordingly...
map.addMarker(new MarkerOptions()
.draggable(false)
.title(((ArrayList<String>) mapInfo.get(i)).get(3))
.position(new LatLng(((ArrayList<Double>) mapInfo.get(i)).get(0), ((ArrayList<Double>) mapInfo.get(i)).get(1)))
.icon(mapIcon));
i = i + 1;
}
And whenever I zoom in and zoom out, the icons move. I want them to be fixed
EDIT:
Images explaining the issue.