map_launcher

本项目基于 map_launcher 开发。

1. 安装与使用

1.1 安装方式

进入到工程目录并在 pubspec.yaml 中添加以下依赖:

pubspec.yaml

...

dependencies:
  map_launcher_ohos:
    git:
      url: https://gitcode.com/openharmony-sig/fluttertpc_map_launcher.git
      path: ohos
...

执行命令

flutter pub get

1.2 使用案例

使用案例详见 ohos/example

2. 约束与限制

2.1 兼容性

在以下版本中已测试通过

  1. Flutter: 3.7.12-ohos-1.0.6; SDK: 5.0.0(12); IDE: DevEco Studio: 5.0.13.200; ROM: 5.1.0.120 SP3;
  2. Flutter: 3.22.1-ohos-1.0.1; SDK: 5.0.0(12); IDE: DevEco Studio: 5.0.13.200; ROM: 5.1.0.120 SP3;

2.2 配置 querySchemes

在 entry 目录下的 module.json5 中添加 querySchemes

打开 entry/src/main/module.json5,添加:


...
 "querySchemes": [
      "alipays",
      "amapuri",
      "zhihu",
      "baidumap",
      'maps'
    ]

3. API

"ohos Support"列为 yes 表示 ohos 平台支持该属性;no 则表示不支持;partially 表示部分支持。使用方法跨平台一致,效果对标 iOS 或 Android 的效果。

Name Description Type Input Output ohos Support
installedMaps 获取设备上已安装的地图应用列表 function / Future<List> yes
showMarker 在指定地图应用中显示标记 function mapType: MapType, coords: Coords, title: String, description: String?, zoom: int?, extraParams: Map<String, String>? Future yes
showDirections 显示从起点到终点的导航路线 function mapType: MapType, destination: Coords, destinationTitle: String?, origin: Coords?, originTitle: String?, waypoints: List?, directionsMode: DirectionsMode?, extraParams: Map<String, String>? Future yes
isMapAvailable 检查指定地图应用是否可用 function mapType: MapType Future<bool?> yes

4. 属性

"ohos Support"列为 yes 表示 ohos 平台支持该属性;no 则表示不支持;partially 表示部分支持。使用方法跨平台一致,效果对标 iOS 或 Android 的效果。

DirectionsMode

Name Description Type Input Output ohos Support
driving 驾车模式 enum / / yes
walking 步行模式 enum / / yes
transit 公共交通模式 enum / / yes
bicycling 骑自行车模式 enum / / yes

Coords

Name Description Type Input Output ohos Support
latitude 纬度坐标值 double / / yes
longitude 经度坐标值 double / / yes

Waypoint

Name Description Type Input Output ohos Support
coords 包含经纬度的坐标对象 Coords / / yes
title 标注标题 String? / / yes

AvailableMap

Name Description Type Input Output ohos Support
mapName 地图名称 String / / yes
mapType 地图类型 MapType / / yes
icon 图标路径(SVG格式) String / / yes

showMarker

Name Description Type Input Output ohos Support
coords 标记的坐标位置 Coords / / yes
title 标记的标题 String / / yes
description 标记的描述信息 String? / / yes
zoom 地图缩放级别 int? / / yes
extraParams 额外的参数配置 Map<String, String>? / / yes

showDirections

Name Description Type Input Output ohos Support
destination 导航的目的地坐标 Coords / / yes
destinationTitle 目的地的标题 String? / / yes
origin 起点坐标 Coords? / / yes
originTitle 起点的标题 String? / / yes
waypoints 途经点列表 List? / / yes
directionsMode 导航模式(默认值:driving) DirectionsMode? / / yes
extraParams 额外的参数配置 Map<String, String>? / / yes

5. 遗留问题

6. 其他

支持的map类型:

高德 花瓣 百度 腾讯

7. 开源协议

本项目基于 The MIT License ,请自由地享受和参与开源。