# Baidu Maps

Canonical HTML: https://p-hatan.com/deeplink-x/apps/baidu-maps/

DeeplinkX 1.5.8.

## Platforms and setup

Native platforms: **ios, android**.



## Public actions

### BaiduMaps.open


```dart
factory BaiduMaps.open({ final bool fallbackToStore = false, final String sourceApplication = _defaultSourceApplication, })
```

Launch with `DeeplinkX.launchApp`. Native platforms: **ios, android**. Action web fallback: **available**. Store-fallback flag: **supported; opt in explicitly**.

| Parameter | Type | Required | Default |
| --- | --- | --- | --- |
| `fallbackToStore` | `bool` | No | `false` |
| `sourceApplication` | `String` | No | `_defaultSourceApplication` |

[Exact source](https://github.com/DeepLinkX/DeeplinkX/blob/00d9d2c7c1affe4e2ee459a01afeba82a1480eac/lib/src/apps/downloadable_apps/baidu_maps.dart#L18)

### BaiduMaps.view


```dart
static BaiduMapsViewAction view({ required final Coordinate coordinate, final String? title, final String? content, final int? zoom, final BaiduMapsCoordType coordType = BaiduMapsCoordType.bd09ll, final bool traffic = false, final String sourceApplication = _defaultSourceApplication, final bool fallbackToStore = false, })
```

Launch with `DeeplinkX.launchAction`. Native platforms: **ios, android**. Action web fallback: **available**. Store-fallback flag: **supported; opt in explicitly**.

| Parameter | Type | Required | Default |
| --- | --- | --- | --- |
| `coordinate` | `Coordinate` | Yes | — |
| `title` | `String?` | No | — |
| `content` | `String?` | No | — |
| `zoom` | `int?` | No | — |
| `coordType` | `BaiduMapsCoordType` | No | `BaiduMapsCoordType.bd09ll` |
| `traffic` | `bool` | No | `false` |
| `sourceApplication` | `String` | No | `_defaultSourceApplication` |
| `fallbackToStore` | `bool` | No | `false` |

[Exact source](https://github.com/DeepLinkX/DeeplinkX/blob/00d9d2c7c1affe4e2ee459a01afeba82a1480eac/lib/src/apps/downloadable_apps/baidu_maps.dart#L62)

### BaiduMaps.search


```dart
static BaiduMapsSearchAction search({ required final String query, final String? region, final Coordinate? center, final BaiduMapsBounds? bounds, final int? radius, final int? zoom, final BaiduMapsCoordType coordType = BaiduMapsCoordType.bd09ll, final String sourceApplication = _defaultSourceApplication, final bool fallbackToStore = false, })
```

Launch with `DeeplinkX.launchAction`. Native platforms: **ios, android**. Action web fallback: **available**. Store-fallback flag: **supported; opt in explicitly**.

| Parameter | Type | Required | Default |
| --- | --- | --- | --- |
| `query` | `String` | Yes | — |
| `region` | `String?` | No | — |
| `center` | `Coordinate?` | No | — |
| `bounds` | `BaiduMapsBounds?` | No | — |
| `radius` | `int?` | No | — |
| `zoom` | `int?` | No | — |
| `coordType` | `BaiduMapsCoordType` | No | `BaiduMapsCoordType.bd09ll` |
| `sourceApplication` | `String` | No | `_defaultSourceApplication` |
| `fallbackToStore` | `bool` | No | `false` |

[Exact source](https://github.com/DeepLinkX/DeeplinkX/blob/00d9d2c7c1affe4e2ee459a01afeba82a1480eac/lib/src/apps/downloadable_apps/baidu_maps.dart#L84)

### BaiduMaps.nearbySearch


```dart
static BaiduMapsNearbySearchAction nearbySearch({ required final String query, final Coordinate? center, final int? radius, final BaiduMapsCoordType coordType = BaiduMapsCoordType.bd09ll, final String sourceApplication = _defaultSourceApplication, final bool fallbackToStore = false, })
```

Launch with `DeeplinkX.launchAction`. Native platforms: **ios, android**. Action web fallback: **available**. Store-fallback flag: **supported; opt in explicitly**.

| Parameter | Type | Required | Default |
| --- | --- | --- | --- |
| `query` | `String` | Yes | — |
| `center` | `Coordinate?` | No | — |
| `radius` | `int?` | No | — |
| `coordType` | `BaiduMapsCoordType` | No | `BaiduMapsCoordType.bd09ll` |
| `sourceApplication` | `String` | No | `_defaultSourceApplication` |
| `fallbackToStore` | `bool` | No | `false` |

[Exact source](https://github.com/DeepLinkX/DeeplinkX/blob/00d9d2c7c1affe4e2ee459a01afeba82a1480eac/lib/src/apps/downloadable_apps/baidu_maps.dart#L108)

### BaiduMaps.line


```dart
static BaiduMapsLineAction line({ required final String name, final String? region, final int? zoom, final String sourceApplication = _defaultSourceApplication, final bool fallbackToStore = false, })
```

Launch with `DeeplinkX.launchAction`. Native platforms: **ios, android**. Action web fallback: **available**. Store-fallback flag: **supported; opt in explicitly**.

| Parameter | Type | Required | Default |
| --- | --- | --- | --- |
| `name` | `String` | Yes | — |
| `region` | `String?` | No | — |
| `zoom` | `int?` | No | — |
| `sourceApplication` | `String` | No | `_defaultSourceApplication` |
| `fallbackToStore` | `bool` | No | `false` |

[Exact source](https://github.com/DeepLinkX/DeeplinkX/blob/00d9d2c7c1affe4e2ee459a01afeba82a1480eac/lib/src/apps/downloadable_apps/baidu_maps.dart#L126)

### BaiduMaps.directions


```dart
static BaiduMapsDirectionsAction directions({ required final String destination, final String? origin, final String? region, final BaiduMapsTravelMode mode = BaiduMapsTravelMode.driving, final BaiduMapsCoordType coordType = BaiduMapsCoordType.bd09ll, final String sourceApplication = _defaultSourceApplication, final bool fallbackToStore = false, })
```

Launch with `DeeplinkX.launchAction`. Native platforms: **ios, android**. Action web fallback: **available**. Store-fallback flag: **supported; opt in explicitly**.

| Parameter | Type | Required | Default |
| --- | --- | --- | --- |
| `destination` | `String` | Yes | — |
| `origin` | `String?` | No | — |
| `region` | `String?` | No | — |
| `mode` | `BaiduMapsTravelMode` | No | `BaiduMapsTravelMode.driving` |
| `coordType` | `BaiduMapsCoordType` | No | `BaiduMapsCoordType.bd09ll` |
| `sourceApplication` | `String` | No | `_defaultSourceApplication` |
| `fallbackToStore` | `bool` | No | `false` |

[Exact source](https://github.com/DeepLinkX/DeeplinkX/blob/00d9d2c7c1affe4e2ee459a01afeba82a1480eac/lib/src/apps/downloadable_apps/baidu_maps.dart#L142)

### BaiduMaps.directionsWithCoords


```dart
static BaiduMapsDirectionsWithCoordsAction directionsWithCoords({ required final Coordinate destination, final Coordinate? origin, final String? destinationTitle, final String? originTitle, final String? region, final BaiduMapsTravelMode mode = BaiduMapsTravelMode.driving, final BaiduMapsCoordType coordType = BaiduMapsCoordType.bd09ll, final String sourceApplication = _defaultSourceApplication, final bool fallbackToStore = false, })
```

Launch with `DeeplinkX.launchAction`. Native platforms: **ios, android**. Action web fallback: **available**. Store-fallback flag: **supported; opt in explicitly**.

| Parameter | Type | Required | Default |
| --- | --- | --- | --- |
| `destination` | `Coordinate` | Yes | — |
| `origin` | `Coordinate?` | No | — |
| `destinationTitle` | `String?` | No | — |
| `originTitle` | `String?` | No | — |
| `region` | `String?` | No | — |
| `mode` | `BaiduMapsTravelMode` | No | `BaiduMapsTravelMode.driving` |
| `coordType` | `BaiduMapsCoordType` | No | `BaiduMapsCoordType.bd09ll` |
| `sourceApplication` | `String` | No | `_defaultSourceApplication` |
| `fallbackToStore` | `bool` | No | `false` |

[Exact source](https://github.com/DeepLinkX/DeeplinkX/blob/00d9d2c7c1affe4e2ee459a01afeba82a1480eac/lib/src/apps/downloadable_apps/baidu_maps.dart#L162)

### BaiduMaps.navigate


```dart
static BaiduMapsNavigateAction navigate({ required final Coordinate destination, final String? destinationTitle, final BaiduMapsNavigationMode mode = BaiduMapsNavigationMode.driving, final BaiduMapsCoordType coordType = BaiduMapsCoordType.bd09ll, final String sourceApplication = _defaultSourceApplication, final bool fallbackToStore = false, })
```

Launch with `DeeplinkX.launchAction`. Native platforms: **ios, android**. Action web fallback: **available**. Store-fallback flag: **supported; opt in explicitly**.

| Parameter | Type | Required | Default |
| --- | --- | --- | --- |
| `destination` | `Coordinate` | Yes | — |
| `destinationTitle` | `String?` | No | — |
| `mode` | `BaiduMapsNavigationMode` | No | `BaiduMapsNavigationMode.driving` |
| `coordType` | `BaiduMapsCoordType` | No | `BaiduMapsCoordType.bd09ll` |
| `sourceApplication` | `String` | No | `_defaultSourceApplication` |
| `fallbackToStore` | `bool` | No | `false` |

[Exact source](https://github.com/DeepLinkX/DeeplinkX/blob/00d9d2c7c1affe4e2ee459a01afeba82a1480eac/lib/src/apps/downloadable_apps/baidu_maps.dart#L186)


## Provider setup and examples
DeeplinkX supports Baidu Maps URI actions on Android and iOS. The integration uses the `baidumap` scheme and Android package-targeted intents so launch attempts can prefer the native app before falling back.

## References

- Baidu Maps Android URI API: <https://lbs.baidu.com/faq/api?title=webapi%2Furi%2Fandriod>
- Baidu Maps iOS URI API: <https://lbs.baidu.com/docs/webapi?title=mapadjustment%2Furi%2Fios>

## Usage

### Launch Baidu Maps

```dart
final deeplinkX = DeeplinkX();

await deeplinkX.launchApp(BaiduMaps.open());
```

### View A Marker

```dart
await deeplinkX.launchAction(
  BaiduMaps.view(
    coordinate: const Coordinate(latitude: 39.915, longitude: 116.404),
    title: 'Tiananmen',
    content: 'Beijing landmark',
    zoom: 16,
    coordType: BaiduMapsCoordType.wgs84,
    sourceApplication: 'my_flutter_app',
  ),
);
```

### Search

```dart
await deeplinkX.launchAction(
  BaiduMaps.search(
    query: 'coffee',
    region: 'Beijing',
    center: const Coordinate(latitude: 39.915, longitude: 116.404),
    radius: 1000,
  ),
);
```

### Nearby Search

```dart
await deeplinkX.launchAction(
  BaiduMaps.nearbySearch(
    query: 'hotel',
    center: const Coordinate(latitude: 31.2304, longitude: 121.4737),
    radius: 2500,
  ),
);
```

### Transit Line

```dart
await deeplinkX.launchAction(
  BaiduMaps.line(
    name: 'Line 1',
    region: 'Beijing',
  ),
);
```

### Directions By Text

```dart
await deeplinkX.launchAction(
  BaiduMaps.directions(
    origin: 'Beijing Railway Station',
    destination: 'Tiananmen',
    region: 'Beijing',
    mode: BaiduMapsTravelMode.transit,
  ),
);
```

If `origin` is omitted, DeeplinkX uses Baidu Maps' current-location token.

### Directions By Coordinates

```dart
await deeplinkX.launchAction(
  BaiduMaps.directionsWithCoords(
    origin: const Coordinate(latitude: 39.9042, longitude: 116.4074),
    originTitle: 'Start',
    destination: const Coordinate(latitude: 39.915, longitude: 116.404),
    destinationTitle: 'Tiananmen',
    region: 'Beijing',
    mode: BaiduMapsTravelMode.walking,
    coordType: BaiduMapsCoordType.wgs84,
  ),
);
```

### Native Navigation

```dart
await deeplinkX.launchAction(
  BaiduMaps.navigate(
    destination: const Coordinate(latitude: 39.915, longitude: 116.404),
    destinationTitle: 'Tiananmen',
    mode: BaiduMapsNavigationMode.walking,
  ),
);
```

## Shared Map Interfaces

These actions implement shared map-action abstractions:

| Interface                       | Baidu Maps action                  |
| ------------------------------- | ---------------------------------- |
| `MapViewAction`                 | `BaiduMaps.view`                   |
| `MapSearchAction`               | `BaiduMaps.search`                 |
| `MapDirectionsAction`           | `BaiduMaps.directions`             |
| `MapDirectionsWithCoordsAction` | `BaiduMaps.directionsWithCoords`   |

The `nearbySearch`, `line`, and `navigate` actions are Baidu-specific extras.

## Platform Configuration

### iOS

Add the Baidu Maps scheme to `LSApplicationQueriesSchemes` in `ios/Runner/Info.plist`:

```xml
<key>LSApplicationQueriesSchemes</key>
<array>
  <string>baidumap</string>
</array>
```

### Android

Add Baidu Maps to package visibility in `android/app/src/main/AndroidManifest.xml`:

```xml
<queries>
  <package android:name="com.baidu.BaiduMap" />
  <intent>
    <action android:name="android.intent.action.VIEW" />
    <data android:scheme="baidumap" />
  </intent>
</queries>
```

## URI Formats

| Action             | URI format                              |
| ------------------ | --------------------------------------- |
| View marker        | `baidumap://map/marker`                 |
| Search             | `baidumap://map/place/search`           |
| Nearby search      | Android `place/nearby`; iOS `nearbysearch` |
| Transit line       | `baidumap://map/line`                   |
| Directions         | `baidumap://map/direction`              |
| Driving navigation | `baidumap://map/navi`                   |
| Walking navigation | `baidumap://map/walknavi`               |
| Riding navigation  | Android `bikenavi`, iOS `ridenavi`      |

Every action accepts an optional `sourceApplication`, defaulting to
`deeplink_x`; the generated `src` is prefixed with `andr.` or `ios.` for the
target platform. Omitted marker text uses `Pin` and `Description`. Transit line
lookups require a nonblank `region`, and iOS driving navigation accepts an
optional `destinationTitle` for its required query label.

DeeplinkX uses familiar marker defaults and Baidu's
`name:...|latlng:...` route-point format while enforcing provider-required
transit regions and distinct Android and iOS nearby-search paths and parameter
names.

## Fallbacks

| Condition                         | Behavior                                   |
| --------------------------------- | ------------------------------------------ |
| Baidu Maps installed             | Opens Baidu Maps using URI/intents         |
| Baidu Maps missing, store enabled | Opens Google Play or the iOS App Store     |
| Baidu Maps missing, store off     | Falls back to `https://map.baidu.com`      |

