Tag Archives: android

Android Google Map V2 – Use Multiple Maps in Application

Hi All,

Since last few days I was facing serious problem with using multiple Google Maps in a Android application project I am currently working on. The application is a true copy of already existing app and used same source code to build with some changes as per client requirement.

Recently I came to know that Google has stopped user from generating Map API keys for Google Map V1  hence I forced to use the latest available version. The application I am working on needed to look same as its iPhone counterpart so I used Tab Host/Activity in it.

The application started throwing issues when I used the latest version of Google Maps for Android. The problem was I had two map in the application and when I switched to 2nd Map screen from first one, the 2nd map did not work and showed same screen (map location) as 1st map screen. It accepted no user input i.e. no location change, zoom or pan.

It took me a lot of time to figure out a solution for this issue (almost 7 days), in between I found many people said it was due to Tab Host/Activity (I am not sure of it), some also suggested to use TabFragments but that did not work for me.

Solution

Finally I cam across an article on Google documents that discussed adding Maps on Android from code instead of XML and that did the trick for me. I added maps on both screen from code behind, but with this I also had to remove the map on the “OnPause” event of the Activity and re-initialize it on the “OnResume” event

I have created a sample android application that uses the solution, download it here

Note: You will need to change the Map API Key in the manifest file

Feel free to contact me in case of any problem

Cheers,

Ankit