Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android app's map pins not appearing until screen is touched

I am experiencing a problem with my app. The 1st screen that appears is a map that displays pins that are located based on an XML file that is loaded from our server.

Sometimes the app loads as expected. Other times, the map loads but none of the pins appear until you touch the screen.

Any ideas why this may be happening and what can be done to fix the problem?

like image 271
Chris Avatar asked Oct 05 '10 20:10

Chris


2 Answers

Sometimes the app loads as expected. Other times, the map loads but none of the pins appear until you touch the screen.

If I had to guess, it's a timing thing -- sometimes, your server responds fast enough that the pins get picked up in the initial map rendering, sometimes not. I do not know how you have implemented the server-fetch and pin-popluation, but call populate() on your ItemizedOverlay (assuming that is what you are using) after your pins are ready, then if needed call invalidate() on the MapView.

like image 193
CommonsWare Avatar answered Nov 08 '22 15:11

CommonsWare


I had a similar problem in one of my projects. The Overlay would draw itself properly on my test phone (Samsung G5) but, on the emulator the overlay would only appear after an action on my part (like a screen touch). I later tested the same project on a Nexus One and the behavior was the same then on the emulator.

I now force a redraw of the MapView by calling invalidate() on the mapview once the Overlay is populated as mentioned by CommonsWare.

like image 43
yann.debonnel Avatar answered Nov 08 '22 16:11

yann.debonnel