Baidu Map Logo
Example of a node with a Baidu Map displaying Markers and other Geometries
Baidu Map Geofield display formatter settings form

It is sometimes said to be more accurate than the Google Maps in China, more complete than Ali Maps, the Baidu Map module allows geographic and location information to be displayed through the Baidu Map API.
See a live example of Baidu Maps or the map control screenshot.

In short, this module allows to obtain geographic coordinates from textual addresses in China (Geocode) and display any geographic information through Baidu Maps.

Capabilities of the module would be limited to China, since Baidu Map currently only provides support for Mainland China, but that's still a tremendously vast market of more than 500 million internauts, opening doors to great applications ranging from Logistics, to Tourism/Hospitality, going through E-Commerce or Real Estates.

Features

The Baidu Map module is an API wrapper which currently only stores a Baidu Map API key (see Implementation, below for more information).
All of the features are actually provided by the Baidu Map Geofield sub-module integrated with the Geocoder and Geofield modules APIs.

Baidu Geocoder: (Currently supports Geocoding API v2.0)
Integrates with Geofield (Geocode from field) through a Geocoder Plugin that returns geo-coordinates from any address in China.

  • Geocode address or location data from numerous types of fields: text, addressfield, location, computed, taxonomy_term_reference, etc...
  • Improved handling of addressfield values to match with China's addresses format and support for China address field.
  • Filter geocoding results based on precision level.

Baidu Map Display Formatter: (Currently supports Map Javascript API v2.0)
Provides a display formatter for Geofield values to be displayed through Baidu Maps.

  • Supports all Geometries provided by GeoPHP (Polygon, linestring, multilinestring, etc...) and Geofield Widgets (WKT, Bounds, Longitude/Latitude, GeoJSON and geocoding from field).
  • Provides numerous Baidu Map display formatter settings such as size, default zoom, map control types and many other display properties (see the screenshot of the formatter form).
  • Overridding Marker Bubbles (InfoWindow) from Theme.
  • Automatic adjustment of Map's center and zoom to display all available data in the same viewport.
  • Supports display of multiple field values.
  • Integration with Views and Variable API.

Implementation:

The idea behind the Baidu Map module is to provide an API wrapper that would allow other modules or APIs to potentially integrate with Baidu Map. After further investigation, it would seem the Baidu Map API key could potentially be used by other modules that would extend its logic to be integrated with other Drupal modules' APIs, that's why it was kept as an independent wrapper module.

Then, the integration with Geofield and Geocoder already provides all the necessary logic related with Field and Storage concerns.
The Baidu Map Geofield module's code was greatly inspired and adapted from the excellent Geocoder (7.x-1.x branch, see google.inc) and Geofield (7.x-2.x branch, see geofield_map) modules and their integration with Google Maps. Several features provided by Google Geocoder and Maps APIs had to be adjusted since Baidu has its own (slightly different) ways, methods and API to provide a similar set of features.

The Baidu Map Geofield module provides a Baidu Geocoder to geocode textual addresses in China and a display formatter to display any Geofield values through Baidu Maps.

Main differences with the Google Geocoder and Geofield implementations:
For the Geocoder, although Google certainly provides more advanced features, Baidu is probably more accurate or would provide perhaps more data when geocoding requests in Chinese for China.
In terms of features, the major difference is that Baidu would return at most a single location result, no matter how generic the request could be (for example, 火车站 / Train station), when Google Geocoder could return multiple results with various precision/approximation/filtering parameters or Geometries. With a single point returned at most, fewer supported properties, unfortunately, Geometry Types, such as Bounds or Viewport and other filtering parameters provided by Google don't seem to be currently supported by Baidu Geocoder.

For the Baidu Map display formatter, the entire Geofield Map module could be re-used almost "as is".
In terms of JS Map API, Google still seems to provide more advanced features than Baidu, which mostly resulted in fewer properties for the field formatter settings form (customization of the display). Another notable difference was found in the way Google Map API handles complex paths, such as multiple polygons, as a single path, which is not the case for Baidu Map API, requiring each different polygon to be treated as a specific path/group/overlay (see GeoJSON to Google Maps for more information).

Otherwise, overall, GeoJSON to Google, formatter settings form, Views support, Google Geocoder, geofield_map JS code, etc... had all to be slightly adapted to match closer with Baidu's APIs, but in general, most of Google Maps features could cross-over very nicely with a great amount of similarities (Some parts could even be re-used almost exactly "as is", such as for the formatter form or the views display style plugin).

Installation and configuration

All this information could also be found in the Baidu Map README.TXT or Baidu Map Geofield README.TXT files.

Baidu Map:
1 - Download the module and copy it into your contributed modules folder:
[for example, your_drupal_path/sites/all/modules] and enable it from the modules administration/management page.
More information at: Installing contributed modules (Drupal 7).

2 - Configuration:
a. After successful installation, browse to the Baidu Map Settings form page under:
Home » Administration » Configuration » Web services » Baidu Map
Path: admin/config/services/baidu_map or use the "Configure" link displayed on the Modules management page.

b. To start using Baidu Map fill in the Baidu Map API Key as described in field's help text (first field of the admin settings form). If you don't already have an API Key, feel free to apply for one on the Baidu API website.

Baidu Map Geofield:
0 - Prerequisites:
Requires Geocoder, Geofield and Baidu Map modules to be installed.

1 - Same as Step 1 above, for Baidu Map.

2 - Configuration:
After successful installation, two new components should be made available for configuration:

a. Baidu Geocoder:
For any existing or newly created Geofield field, with the widget type "Geocode from another field", the Baidu Geocoder could be selected from the main field configuration settings form, in the required dropdown field "Geocoder" (see screenshot of a geofield settings page).
For example: the page content type:
Home » Administration » Structure » Content types » Page » Manage fields

b. Baidu Map display formatter:
Browse to the "Manage Display" settings page, for the entity (Node content type, for example) with a Geofield field, to configure the formatter (See attached screenshot of the formatter settings form).
For example: the page content type:
Home » Administration » Structure » Content types » Page » Manage display

Useful Resources

For any questions and problems, you may find some help on the official Baidu Map developer's site:

  1. Baidu Geocoder API documentation
  2. Baidu Map JS API documentation
  3. Baidu Map Forum:
    For general discussions, inquiries, future developments or API changes, etc...
  4. Baidu Geocoder and Map API general service agreement (TOS)
  5. Make sure you read module's JS examples to extend the Baidu Map JS API.
  6. For further readings and features extensions: Baidu Place API v2.0 documentation

Future developments

Module is subject to changes and restrictions from the Baidu Geocoder and Map Javascript APIs.

Among some of the features that could probably be supported but haven't been tested/developed yet, giving the possibility to configure a JS callback function for the Baidu Geocoder, could perhaps be added in the future depending on the interest and testing capabilities. Also, further extending formatter display settings to provide more customization of the Baidu Maps displayed, could certainly result in a more concrete/visible evolution of the module for most users.

Lastly, efforts could be made and hopefully sustained on the overall maintenance, with improved documentation (especially in Chinese), tutorials/presentations of how module's features could be leveraged, module's translations, more simpletests (Automated Test Cases) and of course the usual bug fixes.

Contributions are welcome!!

Feel free to follow up in the issue queue for any contributions, bug reports, feature requests.
Tests, feedback or comments (and of course, patches) in general are highly appreciated.

This module was approved through the Project Application issue queue process at:
#2128839: [D7] Baidu Map

Credits

First and foremost we are particularly grateful to the Drupal community behind the Geofield and Geocoder modules, their contributors (especially Patrick Hayes @phayes, Brandon Morrison @Brandonian and all other committers) and amazing work, without which this module would perhaps be very far from the level of maturity and supported features it has today.
Hopefully, new features, patches or tests added to this module might as well be ported/adapted to be contributed and shared back with the Geofield Map module.
Special thanks to my mentor David Suissa @DYdave for his tremendous help, keeping the project on the right track, reviewing, documenting, testing and so much more.

This module was sponsored by DAVYIN | 上海戴文.

Supporting organizations: 
Development and maintenance of the module.

Project information

Releases