• Baidu Map displays only in Chinese language • Visiting http://pan.baidu.com/# is the first step to create your account in baidu.com • Create new application in Baidu (http://lbsyun.baidu.com/apiconsole/key). • Generate SHA key and add it to your application. Implementation: 1. Create Project→ New Project → Empty activity → finish 2. Add following dependencies in gradle file.
Dependencies { compile files('libs/baidumapapi_v3_1_0.jar') compile files('libs/locSDK_4.2.jar') }
3. Add the Baidu Map in Xml Layout like below
<com.baidu.mapapi.map.MapView android:id="@+id/bmapView" android:layout_width="fill_parent" android:layout_height="fill_parent" android:clickable="true" />
4. Add Baidu API key in Manifest and add Permission like bellow
<meta-data android:name="com.baidu.lbsapi.API_KEY" android:value="Use Your Key Here" /> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"> </uses-permission> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"> </uses-permission> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"> </uses-permission> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"> </uses-permission> <uses-permission android:name="android.permission.CHANGE_WIFI_STATE"> </uses-permission></strong> <uses-permission android:name="android.permission.READ_PHONE_STATE"> </uses-permission> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"> </uses-permission> <uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"> </uses-permission></strong> <uses-permission android:name="android.permission.READ_LOGS"> </uses-permission> <uses-permission android:name="android.permission.VIBRATE" /> <uses-permission android:name="android.permission.WAKE_LOCK" /> <uses-permission android:name="android.permission.WRITE_SETTINGS" /> <permission android:name="android.permission.BAIDU_LOCATION_SERVICE"></permission> <uses-permission android:name="android.permission.BAIDU_LOCATION_SERVICE"> </uses-permission> <uses-permission android:name="android.permission.ACCESS_GPS" /> <uses-permission android:name="android.permission.READ_PHONE_STATE" /> <uses-permission android:name="android.permission.GET_TASKS" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"> </uses-permission> <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> <uses-permission android:name="android.permission.WRITE_SETTINGS" /> <uses-permission android:name="android.permission.READ_PHONE_STATE" />
5. Initialize Map view in related activity like below
mMapView = (MapView) findViewById(R.id.bmapView); mBaiduMap = mMapView.getMap();
6. Creating application in Baidu API console looks like the below screen-shot 7. Now run your app and get the Baidu map as shown below