Using Google Maps and Baidu Maps in same app

My solution for this was to implement GM as usual, however if the user has China set (via settings) static maps is to be used, BUT the static map is fetched from Baidu instead of google.

staticUrl = "http://api.map.baidu.com/staticimage?center=" 
                + location.getLongitude() + "," + location.getLatitude() 
                + "&width=" + width + "&height=" + width + "&zoom=15"
                + "&markers=" + location.getLongitude() + "," + location.getLatitude();

Result of https://api.map.baidu.com/staticimage?center=121,31&width=300&height=300&zoom=15:

Baidu map tile

This method is NOT recommended if trying to implement a real map solution. Since I have different locations only used by different countries, this solution could be used.

So, that is how I solved it. Hope someone finds this helpful.


Also, I have found that if you use http://ditu.google.cn while in China, it does work.

When using on-line maps in China for your application, whether it's Google Maps or Baidu, there is a transformation of latitude and longitude for legal reasons.

The satellite view in Google Maps uses "Earth" (WGS-84) coordinates. The map view of GMaps in China uses "Mars" coordinates (GCJ-02), and there is code to convert between the two. Baidu maps use the "Bearpaw" coordinates, with a different offset. The Baidu Map API has a demo converting between Google's coordinates and its own systems.

In China, GPS, like everything, has an extra layer of complication :)

If you have built this app, please post the details. Having an English interface to Baidu maps would be great.