I need to display two MapFragments with two different locations in an activity. In my XML file I have two MapFragments called "map" and "map_two", and in java my code in onCreate is :
com.google.android.gms.maps.MapFragment mapFragment = (MapFragment) getFragmentManager().findFragmentById(map);
mapCount = 1;
mapFragment.getMapAsync(this);
com.google.android.gms.maps.MapFragment mapFragmentTwo = (MapFragment) getFragmentManager().findFragmentById(map_two);
mapCount = 2;
mapFragmentTwo.getMapAsync(this);
Then I override onMapReady :
@Override
public void onMapReady(GoogleMap googleMap) {
if (mapCount == 1){
mMap = googleMap;
LatLng vannes = new LatLng(47.66, -2.75);
mMap.addMarker(new MarkerOptions().position(vannes).title("Vannes"));
mMap.moveCamera(CameraUpdateFactory.newLatLng(vannes));
} else if (mapCount == 2){
mMap = googleMap;
LatLng bordeaux = new LatLng(44.833328, -0.56667);
mMap.addMarker(new MarkerOptions().position(bordeaux).title("Bordeaux"));
mMap.moveCamera(CameraUpdateFactory.newLatLng(bordeaux));
}
}
My issue is that the two maps show the same location, whereas I want to show two different locations. Do you see how to make it ?
Thank you,
Alex