SDK在此处导航Flutter-具有空值的机动对象 [英] SDK Here Navigate Flutter - Maneuver object with null values

查看:48
本文介绍了SDK在此处导航Flutter-具有空值的机动对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Flutter中使用SDK HERE导航版本4.5.4.

I use SDK HERE Navigation version 4.5.4 for Flutter.

在导航过程中,我通过 VisualNavigator 对象的 routeProgressListener 侦听器获取下一个机动索引,然后在我的route对象中获得该机动对象.

During navigation, I get the next maneuver index through routeProgressListener listener of VisualNavigator object, then I get the maneuver object in my route object.

但是对于我的路线的每次操作,这些参数都返回 null :

But for each maneuvers of my route those parameters return null :

  • roadName
  • roadNameLanguageCode
  • roadNumber
  • nextRoadName
  • nextRoadNameLanguageCode
  • nextRoadNumber
  • roadName
  • roadNameLanguageCode
  • roadNumber
  • nextRoadName
  • nextRoadNameLanguageCode
  • nextRoadNumber

但是参数 text 向我返回了正确的值.

But the parameter text return me a correct value.

我的日志:

flutter: NAV - nextHereManeuver :
action ManeuverAction.rightTurn 
text Turn right onto Rue Roquelaine. Go for 112 m. 
roadType null 
roadName null 
roadNameLanguageCode null 
roadNumber null 
nextRoadName null 
nextRoadNameLanguageCode null 
nextRoadNumber null

flutter: NAV - nextHereManeuver :
action ManeuverAction.rightTurn 
text Turn right onto Boulevard de Strasbourg. Go for 96 m. 
roadType null 
roadName null 
roadNameLanguageCode null 
roadNumber null 
nextRoadName null 
nextRoadNameLanguageCode null 
nextRoadNumber null

etc.

谢谢

推荐答案

基本上,在导航期间,您应该从 VisualNavigator的 RouteProgress ,而不是从 Route 对象获取它.取自 Route 的操作的 text 包含本地化的描述,但在 RouteProgress 中取相同的值为 null 导航.

Basically, during navigation you should take the Maneuver object from the VisualNavigator's RouteProgress, instead of taking it from the Route object instead. The maneuver's text taken from Route contains a localized description, but taking the same value from the RouteProgress is null during navigation.

通常,我使用路线概述页面的路线来绘制路线并显示机动清单-在导航过程中,我直接从导航器中取得机动-因为它们与您当前的位置实时同步.这里还有一些代码(在Dart中),展示了如何从 routeProgress 中获取内容.摘自HERE SDK的

Usually, I use the route for the route overview page to draw the route and show the maneuver list - and during navigation I take the maneuvers directly from navigator - as they are synced realtime with your current location. Here's some more code (in Dart) that shows how to get the content from routeProgress. It's taken from the HERE SDK's GitHub repo that contains some useful Flutter examples:

// Contains the progress for the next maneuver ahead and the next-next maneuvers, if any.
List<ManeuverProgress> nextManeuverList = routeProgress.maneuverProgress;

ManeuverProgress nextManeuverProgress = nextManeuverList.first;
if (nextManeuverProgress == null) {
  print('No next maneuver available.');
  return;
}

int nextManeuverIndex = nextManeuverProgress.maneuverIndex;
HERE.Maneuver nextManeuver = _visualNavigator.getManeuver(nextManeuverIndex);
if (nextManeuver == null) {
  // Should never happen as we retrieved the next maneuver progress above.
  return;
}

HERE.ManeuverAction action = nextManeuver.action;
String nextRoadName = nextManeuver.nextRoadName;
String road = nextRoadName ?? nextManeuver.nextRoadNumber;

if (action == HERE.ManeuverAction.arrive) {
  // We are approaching the destination, so there's no next road.
  String currentRoadName = nextManeuver.roadName;
  road = currentRoadName ?? nextManeuver.roadNumber;
}

// Happens only in rare cases, when also the fallback is null.
road ??= 'unnamed road';

因此,基本上,在导航过程中,您可以像这样获得 managever (忽略 route 实例,该实例也包含操作):

So, basically, during navigation, you can get the maneuver like this (ignoring the route instance, which also contains maneuvers):

Maneuver nextManeuver = visualNavigator.getManeuver(nextManeuverIndex);

我建议您也参考一下Android风格的用户指南,它包含相同的SDK逻辑,只是API接口在Java/Kotlin中而不是Dart中.

I would recommend to also take a look at the user guide for the Android flavor, it contains the same SDK logic, just the API interfaces are in Java/Kotlin instead of Dart. The explanations in user guide for Android are quite helpful. It seems Flutter is still in beta, so the user guide is a bit limited in comparison to the native flavors.

这篇关于SDK在此处导航Flutter-具有空值的机动对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆