Giter Club home page Giter Club logo

flutter_baidu_navi_null_safety's Introduction

flutter_baidu_navi

Flutter baidu map navigation - Flutter百度地图导航

更新

2021.05.21

移除手动添加的TTS静态库和资源包,避免文件过大无法上传的问题,可用git source的方式使用插件

使用

添加依赖

或下载源码到本地,使用本地依赖插件的方式,在pubspec.yaml中配置插件目录路径

flutter_baidu_navi:
	path: ../plugin/flutter_baidu_navi	# 路劲根据自己的存放目录而定

IOS配置

    需要在ios/Runner/Info.plist文件中配置
    <key>CFBundleDisplayName</key>
    <string>应用名称</string>


初始化百度地图定位

/// 在适当位置调用初始化,由于使用内置TTS,返回mapSuccess即可
/// 参数依次为百度地图AppKey,TTS的AppId、ApiKey、SecretKey
/// TTS相关的Key为可选参数,如果不传默认为空,导航没声音
FlutterBaiduNavi.init(
  "2GF3O2BTHxYHlMnoEuSFvyLo6c0xBn1h",
  ttsAppId: "24147217",
  ttsApiKey: "vewI9TV5VQRoOGPypStObVL3",
  ttsSecretKey: "QaFknadW5sPlNEicIcrdFV4VeGG0KZvo",
);

初始化返回结果为BaiduNaviInitResult, 具体可查看源码

/// 百度导航初始化结果
enum BaiduNaviInitResult {
  /// 导航Appkey和TTS授权均成功
  success,
  /// 导航Appkey和TTS授权均失败【导航AppKey失败导航一定会失败,且会弹出未授权提示框,所以请确保地图应用的AppKey准确无误】
  fail,
  /// 导航AppKey成功,TTS失败
  /// 注:实践证明,使用内置的TTS语音,有TTS相关Key,及时使用这些KeyTTS授权失败也会有导航声音,而且给包名完全不一样的Android使用也行!
  /// 如果TTS相关的Key为空或者不是AI平台申请的Key,导航就很有可能没有声音
  mapSuccessTtsFail,
  /// 导航AppKey失败,TTS成功【导航AppKey失败导航一定会失败,且会弹出未授权提示框,所以请确保地图应用的AppKey准确无误】
  mapFailTtsSuccess,
}

开始导航

/// 开始导航,参数依次为起点经度、起点纬度、终点经度、终点纬度
FlutterBaiduNavi.startNavi(
  104.078063,
  30.66664,
  104.122785,
  30.727933,
);

发起导航返回结果为BaiduNaviResult, 具体可查看源码

/// 百度导航结果
/// 注:选取了一些常见的错误,如需其他错误类型,需更改插件代码返回相应的值
enum BaiduNaviResult {
  /// 成功开启导航
  success,
  /// 定位权限未开启或受限
  locationUnauthorized,
  /// 导航服务未初始化完成
  naviServiceNotInited,
  /// 网络不可用
  networkError,
  /// 起点与终点距离太近
  tooNear,
  /// 其他原因-导航失败
  otherError,
}

TODO:

  • Android端功能开发
  • 最终完善,发布到pub

更多

其他更多开发细节和说明可以查看博客百度地图导航Flutter插件(iOS端)

flutter_baidu_navi_null_safety's People

Contributors

smiacter avatar miuxiu avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.