Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SupportMapFragment shows black screen for some milli seconds

I am working on a project where I want to show map fragment in fragment activity thats why i used the following,

public class VenueMapFragment extends SupportMapFragment implements OnClickListener {
private LatLng mPosFija;
private String title;
private BMSActionBar action_bar;

public VenueMapFragment() {
    super();
}


public static VenueMapFragment newInstance(LatLng posicion,String title){
    VenueMapFragment frag = new VenueMapFragment();
    frag.mPosFija = posicion;
    frag.title = title;
    return frag;
}

View layout;
@Override
public View onCreateView(LayoutInflater arg0, ViewGroup arg1, Bundle arg2) {
    layout = super.onCreateView(arg0, arg1, arg2);
    layout.setVisibility(View.GONE);
    initMap();
    return layout;
}

private void initMap(){
    UiSettings settings = getMap().getUiSettings();
    settings.setMyLocationButtonEnabled(true);
    settings.setZoomControlsEnabled(false);
    getMap().animateCamera(CameraUpdateFactory.newLatLngZoom(mPosFija,16),1000,null);
    getMap().addMarker(new MarkerOptions().position(mPosFija).title(title).visible(true));
}

@Override
public void onClick(View v) {

}}

when I move from one fragment to other map shows black screen for some milli seconds after that it works fine and also when I press back also it shows the same. It really looks ugly.

Please help me to solve this issue.

like image 524
VK.Dev Avatar asked Dec 10 '25 23:12

VK.Dev


2 Answers

this is a known issue with v2 look here for some possible workarounds in the meantime

https://code.google.com/p/gmaps-api-issues/issues/detail?id=4639

https://code.google.com/p/gmaps-api-issues/issues/detail?id=4659

like image 166
tyczj Avatar answered Dec 12 '25 13:12

tyczj


If its a known issue ,you can't really do much about it.But here is something you can do.The processing you are doing can be moved to Async Task.Till the time the map is displayed, an image or logo can be flashed in the background .

like image 23
Ankit Srivastava Avatar answered Dec 12 '25 13:12

Ankit Srivastava



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!