Android GoogleMaps V2 does not update

My application displays the user’s managed route. After a few seconds, the card will stop loading new content and looks like this: enter image description here

My code: XML

<fragment xmlns:android="http://schemas.android.com/apk/res/android" class="com.google.android.gms.maps.SupportMapFragment" android:id="@+id/map" android:layout_width="match_parent" android:layout_height="match_parent" map:cameraZoom="19" android:layout_below="@+id/tracking_maps_colorgradient"> </fragment> 

Java:

  float zoom = 18;//googleMap.getCameraPosition().zoom; LatLng latLng = new LatLng(lastLatitude, lastLongitude); locations.add(latLng); CameraPosition pos = new CameraPosition.Builder() .target(latLng) .bearing(bearing) .zoom(zoom) .tilt(googleMap.getCameraPosition().tilt) .build(); googleMap.animateCamera(CameraUpdateFactory.newCameraPosition(pos)); Polyline p = googleMap.addPolyline(new PolylineOptions() .add(latLng) .width(15) .color(Color.RED) .geodesic(true)); p.setPoints(locations); 

Is there any way to cancel the card?

Thank you for your help!

+4
source share
3 answers

Well, for those who have the same problem, there is a solution. The problem is that the update in GoogleMap is constantly updated, you need to change the camera position when the user goes beyond the borders.

 LatLngBounds bounds = this.googleMap.getProjection().getVisibleRegion().latLngBounds; if(!bounds.contains(new LatLng(gps.getLatitude(), gps.getLongitude()))) { //Move the camera to the user location if they are off-screen! CameraPosition cameraPosition = new CameraPosition.Builder() .target(new LatLng(gps.getLatitude(), gps.getLongitude())) .zoom(zoom) // Sets the zoom .bearing(bearing) .build(); // Creates a CameraPosition from the builder googleMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition)); } 
0
source

Use Thread.sleep (300); after updating the map using markers, overlays, etc. Google Maps uses its own internal streams and needs time to make changes. It is possible that adding a stream to a map blocks the Google Map stream. Sleep will give some time for updating.

0
source

I do not know if you have a problem. But I decided and wanted to share with you. You can use a handler and Thread.sleep (600). If you use only a handler, you take the same problem. Thread.sleep function was waiting for an update card and how to go to the marker.

0
source

All Articles