I have the following problem.
I am able to receive my latitude and longitude via a ForegroundService, however, the more I roam around, the more LatLng I get (what is pretty clear so far!).
Now, if I turn off my phone and roam a little bit around and then I turn it back on again, the MapView always returns a ANR because of too many LatLng to load and display it.
So, I would like to know whether there is any possibility or API with which I can load the whole polyline in a reasonable time? Maybe, there is some possibility with which I can display only the GeoPoints on Google Maps that are visible to the user so that all the other points that are outside of the map do not need to be shown?
This is how I load the polyline:
private void createListenerAndfillPolyPoints(double lastLat, double lastLng, List<LatLng> polylinePoints) {
boolean isServiceRunning = isServiceRunning(getString(R.string.serviceName));
if(!isServiceRunning) {
mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(lastLat, lastLng), 0));
toolbar_title.setText("Distance: 0.0 Km" + "\nSpeed: 0.0");
} else {
LatLng latLng = new LatLng(lastLat, lastLng);
mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(latLng, 16));
if(startingPoint) {
mMap.addMarker(new MarkerOptions().position(latLng).title(getResources().getString(R.string.current_location))).showInfoWindow();
startingPoint = false;
} else {
toolbar_title.setText("Distance: " + String.format("%.2f", coveredDistance) + "\nSpeed: " + speed);
polyline = mMap.addPolyline(new PolylineOptions().addAll(polylinePoints).color(Color.MAGENTA).jointType(JointType.ROUND).width(15.0f));
}
}
}