In my application, I use the map view in action below. but the map does not load properly. After clicking on the card 2-3 times, its display of a clear map. & when the same card, if the load is fully visible, explicit load. What is the solution for this?
Screenshot -

<com.google.android.gms.maps.MapView
android:id="@+id/map"
android:layout_width="fill_parent"
android:layout_height="200dp"
android:layout_margin="10dp" />
java code -
try {
MapsInitializer.initialize(getApplicationContext());
} catch (GooglePlayServicesNotAvailableException e) {
e.printStackTrace();
}
switch (GooglePlayServicesUtil.isGooglePlayServicesAvailable(getApplicationContext()) )
{
case ConnectionResult.SUCCESS:
mapView = (MapView)findViewById(R.id.map);
mapView.onCreate(savedInstanceState);
if(mapView!=null)
{
map = mapView.getMap();
map.getUiSettings().setMyLocationButtonEnabled(false);
map.setMyLocationEnabled(true);
CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngZoom(locationPosition, 10);
map.animateCamera(cameraUpdate);
map.setMapType(GoogleMap.MAP_TYPE_NORMAL);
}
break;
case ConnectionResult.SERVICE_MISSING:
break;
case ConnectionResult.SERVICE_VERSION_UPDATE_REQUIRED:
break;
default: Toast.makeText(getApplicationContext(), GooglePlayServicesUtil.isGooglePlayServicesAvailable(getApplicationContext()), Toast.LENGTH_SHORT).show();
}
CameraPosition cameraPosition = new CameraPosition.Builder()
.target(locationPosition).zoom(10).bearing(0)
.tilt(70)
.build();
map.setBuildingsEnabled(true);
map.setMyLocationEnabled(true);
map.setMapType(GoogleMap.MAP_TYPE_NORMAL);
map.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
map.addMarker(new MarkerOptions() .position(locationPosition).icon(BitmapDescriptorFactory.fromResource(R.drawable.icon_marker)));
source
share