Sunday, December 16, 2012

Centering maps app on user

So now that I have a maps app working on my phone I want it to draw a little icon where my location is and center the map on it.  Getting the icon to draw wasn't too bad.  I basically just followed the code here:

SA google-maps-android-api-v2-and-current-location

It's a horrendous amount of nasty looking code but being a newbie I'm just happy to get it working.  Maybe I can find cleaner implementations once I'm a bit more comfortable.

The problem now is that I get an icon but the map centers on Africa.  Let's see if I can get it to center on the user...

Turns out this wasn't too bad.  Just had to add a couple more lines of horrible verbose code.  Here are the important lines:

The final result for looks like:

Seems to work OK.

No comments:

Post a Comment