SanderE
SanderE

Reputation: 171

Google Maps v2 for Android loads tiles very slowly when at high speeds

I'm currently making an app that has some functionality that resembles navigation software (but no, I cannot use actual existing navigation software for this) and thus can track a person while they drive. For this I am trying to use google maps api v2, but it gets problematic once I go faster than approximately 50 km/hour.

At that point I basically drive off the map into the gray, and the loading of new tiles does not seem to keep nor catch up with my driving speed. At some points it goes ok for a while, I've even had moments on the highway where it kept up with 130 km/h, but these moments are very rare and generally my app becomes unusable after 50-60 km/h. This is all with the normal mapview, with Sat/Hybrid its of course even slower/worse. I've tried both 3g and 4g, my internet speed really is not the issue unless 15Mb/s is not fast enough.

Is there any way I can tell Google Maps to load tiles faster or cache more of its surroundings? Will a business license increase this speed? Or am I forced to start using OSM instead of Google Maps?

Upvotes: 1

Views: 1438

Answers (1)

Stijn
Stijn

Reputation: 858

This turned out not to be a performance problem. We profiled the application and could not find a significant CPU or memory load. This made us suspect a different problem. After a dozen test drives, enabling/disabling parts of code everytime, we found out what the problem was.

We animate the camera to the new GPS position every time a new position came in. This happened every ~500ms.

AnimateCamera() does not have a specified default duration when you don't specify it as an argument. However, we found out the default duration in our case is longer than 500ms.

While animating, the map will not load new tiles. So in our case, we started a new animation every 500ms, and the animation lasted longer than 500ms (we suspect 2000ms), and thus the map was always in the "animating" state.

When we specified a 300ms animation duration, all tiles loaded correctly, even at (very) high speeds.

Upvotes: 8

Related Questions