Sewerbird Sewerbird - 1 year ago 296
Javascript Question

Does a Google Maps coordinate map to the same location in Baidu Maps?

I'm implementing a map view in Baidu Maps (China's primary map service) using latitude & longitude originating from Google Maps. I am finding that my locations (primarily around Shanghai) are consistently 'off' by about a kilometer, though!

Doing a linear adjustment makes the Baidu locations appear in roughly (+- a few meters) the right spot:

//Declaring my Baidu map marker's properties
lat : + 0.00575,
lng : gm_location.lng + 0.00668,

Although this will do for my particular needs, I dislike these magic numbers. Anyone have any insight where this offset is emerging from?

Answer Source

Which Google Maps do you use,, or Satellite or street view? In all cases, the answer is no - coordinates won't correspond to the Baidu Map POI, but for slightly different reasons.

First off, since Baidu doesn't offer any useful maps outside of China, let's focus on the question being,

Does a Google Maps coordinate within China, map to the same location in Baidu Maps?

The answer is no. Baidu Maps uses its own BD-09 coordinate system, while Google Maps uses either the Chinese GCJ-02 standard (for street maps on either or .cn), or WGS-84 for satellite imagery on satellite view maps.

GPS coordinates (WGS-84) and Google Street Map coordinates (GCJ-02) do not map to the same location on Baidu Maps, as this snippet demonstrates (I didn't include the snippet in the answer because it doesn't work due to the way SO includes scripts - but you can see the code in this other answer I gave).

enter image description here

Using a linear correction around Shanghai might work, but the values will change for other regions in China.

How to compensate for the offset

The official method for converting Google coordinates to Baidu Map coordinates is to use the Baidu Map API for doing so.

There are two versions of the API:

  1. An allegedly "server" version documented at that requires obtaining an application key

  2. A version at that's used by the Baidu Map coordinates conversion demo via and doesn't need an application key.

Let's take the Google Street Map (GCJ-02) coordinates of The People's Heroes Monument in Shanghai and convert them to Baidu Maps coordinates:

curl ""

will output


The coordinates are base64-encoded, and decode to

121.49799987338, 31.247975840196

If allowed you to enter lat/lon coordinates, you'd land at the Popele's Heroes Monument.

Baidu's API only offers conversion to BD-09.

The conversion can also be run offline, and formulas can be found on Chinese blogs. Conversion between GCJ-02, WGS-84 and B-09 can be performed using libraries like geoChina or eviltransform.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download