views:

43

answers:

2

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?

+1  A: 

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.

CommonsWare
A: 

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.

yann.debonnel