Android Google Maps v2, MAP_TYPE_NONE and black squares
Asked Answered
J

1

8

I've been struggeling with Google Maps v2 and custom tiles. It works fine, but we get black squares in Google Maps very often, and they are very distruptive.

I can reproduce the problem very simply by doing this:

mapFragment = new MapFragment() {
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
        mapFragment.getMap().setMapType(GoogleMap.MAP_TYPE_NONE);
    }
};

FragmentTransaction trans = getFragmentManager().beginTransaction();
trans.replace(R.id.map, mapFragment);
trans.commit();

I use this code and a standard activity with a framelayout. If I zoom far enough in the background on my Nexus4 it turns black. If I put tiles on top of that I will see black flashes as I zoom in.

I've seen a ton of workarounds on how to fix this, and none of them seem to work at all. It seems to only happen on certain zoom levels, but I (A) need those zoom levels, and (B) cannot seem to limit zooming (without building a custom pinch to zoom implementation anyways).

I've done some testing with custom tile providers. With MAP_TYPE_NONE, a tile provider which simply returns 1 blue pixel and my normal map tile provider I can visually see the map changing from black -> blue -> my map. Even though my custom blue tile provider returns immediately with a 1px blue tile.

Jarlathus answered 12/6, 2013 at 7:55 Comment(4)
note that in order to see this you need to set the view background to something other than black. We've been using the android theme holo light.Jarlathus
do you mean, you didn't get map image, just get grids right?Happening
flashes black first, then I get the grid, then I get the map image.Jarlathus
could you please put links to the workarounds that you mention in your question so we can see which ones you've tried? thxLupe
S
1

This issue, as well as a trailing black rectangle when moving the Map view, was reported months ago and has just received a fix from Google.

This fix is unfortunately limited to compatible devices and because it's a fresh fix, may introduce new bugs on the "fixed" devices and keep the old ones (a bit different) on the other devices.

I don't see any need to copy here the conversation from Google's bug tracker since it's fully public: https://code.google.com/p/gmaps-api-issues/issues/detail?id=4659

Skiba answered 29/8, 2013 at 17:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.