Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Google Maps and Baidu Maps in same app

I'm wondering if there are anyone out that have implemented Google Maps V2 and Baidu Maps in the same version; because GM doesn't work as intended in China?

Or should I split the project into two branches instead? However it would be nice to skip having two branches to maintain.

like image 956
Henric Avatar asked Sep 20 '13 06:09

Henric


People also ask

Can Chinese use Google Maps?

Does Google Maps Work In China? Google Maps is perhaps the best online map application available on smartphones. However, unless you have a VPN installed (learn more about using your cell phone and the internet in China here), all Google services, including Google Maps, are blocked by the "Great Firewall" of China.

Is Google Maps blocked in China?

The simple answer is no. Google and Google Maps do not work in China. Google, and all its affiliate pages and apps, is blocked in China, which means that when you're in China and using regular WiFi or data, you cannot access any data from Google, including Google Maps.

Can I integrate Google Maps in my app?

Android allows us to integrate google maps in our application. You can show any location on the map , or can show different routes on the map e.t.c. You can also customize the map according to your choices.

Does Baidu Maps work outside China?

Baidu Maps is available only in the Chinese language and, before 2016, it offered only maps of mainland China, Hong Kong, Macau and Taiwan, with the rest of the world appearing unexplored. Currently Baidu Maps also offers maps of various other countries.


1 Answers

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.

like image 192
Henric Avatar answered Sep 27 '22 18:09

Henric