Getting an ambiguous sky screen when loading a google map

when I download a google map to the device that I get under the screen sometimes. It comes on a second boot, as shown below. google map otherwise it works just like a regular google map with a route. I use SupportmapFragment and get googleMap object as.

supportMapFragment = (SupportMapFragment) getChildFragmentManager().findFragmentById(R.id.map_view_fragment); 

below is the code for displaying the map in activity / fragment

 public static void drawRouteIntoMap(final List<? extends MapHelper> position, final GoogleMap googleMap) { /*List<MapHelper> position = new ArrayList<MapHelper>(); for (int i = lastPosition; i < maps.size(); i++) { position.add(maps.get(i)); }*/ final LatLngBounds.Builder mapBounds = new LatLngBounds.Builder(); if (position.size() > 0 && Validator.isNotNull(googleMap)) { googleMap.clear(); List<PolylineOptions> polylineOptionses = new ArrayList<PolylineOptions>(); PolylineOptions option = null; Boolean lastPause = null; for (MapHelper map : position) { if (map.isPause()) { if (Validator.isNull(lastPause) || !lastPause) { option = new PolylineOptions().width(5).color(Color.rgb(255, 0, 155)).geodesic(true); polylineOptionses.add(option); } mapBounds.include(new LatLng(map.getLatitude(),map.getLongitude())); option.add(new LatLng(map.getLatitude(), map.getLongitude())); } else { if (Validator.isNull(lastPause) || lastPause) { option = new PolylineOptions().width(5).color(Color.rgb(0, 179, 253)).geodesic(true); polylineOptionses.add(option); } mapBounds.include(new LatLng(map.getLatitude(),map.getLongitude())); option.add(new LatLng(map.getLatitude(), map.getLongitude())); } lastPause = map.isPause(); } for (PolylineOptions options : polylineOptionses) { googleMap.addPolyline(options); } if(Validator.isNotNull(option)){ //List<LatLng> points = option.getPoints(); googleMap.setOnMapLoadedCallback(new GoogleMap.OnMapLoadedCallback() { @Override public void onMapLoaded() { LatLng startPoint = new LatLng(position.get(0).getLatitude(), position.get(0).getLongitude()); googleMap.addMarker(new MarkerOptions().position(startPoint).title("start").icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN))); mapBounds.include(startPoint); LatLng endPoint = new LatLng(position.get(position.size() - 1).getLatitude(), position.get(position.size() - 1).getLongitude()); mapBounds.include(endPoint); googleMap.addMarker(new MarkerOptions().position(endPoint).title("finish").icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_RED))); googleMap.setPadding(15, 205, 10, 110); googleMap.moveCamera(CameraUpdateFactory.newLatLngBounds(mapBounds.build(), 0)); //googleMap.animateCamera(CameraUpdateFactory.newLatLngBounds(mapBounds.build(), 10)); googleMap.moveCamera(CameraUpdateFactory.zoomOut()); } }); } } } supportMapFragment.getMapAsync(new OnMapReadyCallback() { @Override public void onMapReady(GoogleMap googleMap) { if (Validator.isNotNull(googleMap)) { googleMap.setMyLocationEnabled(false); googleMap.clear(); googleMap.setOnMapClickListener(new GoogleMap.OnMapClickListener() { @Override public void onMapClick(LatLng latLng) { if (activity.preferences.isSaveScreen()) { facebook.setChecked(false); twitter.setChecked(false); activity.replaceFragment(new FullMapFragment(), null); } if (!activity.preferences.isSaveScreen()) { activity.preferences.setHistoryScreen(true); activity.replaceFragment(new FullMapFragment(), null); } } }); if (gps) { nonGpsSummary.setVisibility(View.GONE); List<HistoryMap> historyMaps = new ArrayList<HistoryMap>(); if (Validator.isNotNull(activity.preferences.getUserHistory().getHistoryMaps())) { historyMaps.addAll(Arrays.asList(activity.preferences.getUserHistory().getHistoryMaps())); } if (historyMaps.size() > 0) { if (Validator.isNotNull(googleMap)) { drawRouteIntoMap(historyMaps, googleMap); } } else { mapFrame.setVisibility(View.GONE); } } else { gpsSummary.setVisibility(View.GONE); } } } }); 

this question is related to the scaling of a specific google map route . using that I get the correct route with mapbounds, but I don't understand why this screen is displayed.

I do not receive coordinates 0.0 I am debugging that the api key is also correct.

+6
source share
2 answers

You call moveCamera twice. The first tries to move the camera, and the second does not wait for the end of the first and performs a reduction.

This may not happen all the time and may behave differently on different devices.

The best option is to install the add-on on CameraUpdateFactory.newLatLngBounds(mapBounds.build(), 0) instead of 0

+5
source

This problem occurs when your coordinates are incorrectly set. Make sure the coordinates you use point to the ground in order to display the maps correctly. Another possible reason is that your API key is not working, try creating a new API key for this project.

For more information, check out these related SO questions.

+3
source

All Articles