Search code examples
androidhere-api

HERE Android SDK NavigateManager simulate without Map is not giving maneuvers


I am using the HERE Android SDK embedded in a QT application, and am trying to do turn by turn directions simulated, but without a map display. There is no Map or MapFragment in my app, I'm using the MapEngine and NavigationManager directly. And I am initializing the map engine on the main UI thread, as that is recommended (not sure if that could be an issue here).

I am able to initialize the map engine, create the route and dump it successfully. However, when I use NavigationManager to simulate the route, I can see navigation movement (the coordinates in position updates progressing). However, I have ManeuverEventListeners and NewInstructionEventListeners, and they are never called.

And in my position listener, if I call getNextManeuverDistance() or getETA() I get error responses. All other functions had success, and the simulated navigation will complete eventually (at the expected time) but without ever delivering any instructions.

I have the same code working fine in a sample app, but running in the QT framework I'm never getting valid distances or maneuvers. In the API reference it says getNextManeuver() will return null (and get distance returns MAX_INT) if the next maneuver is not available yet. What can be causing this?

Is it valid to run this in an app without a Map nor a MapFragment? Any ideas why NavigateManager simulate would act this way?


Solution

  • Yes, I eventually figured out that the map data must be manually preloaded. Seems that calculating the route is not enough, and the data fetching is normally done by the map view, and the navigation manager is just waiting for the map data.

    In my case, as soon as I have a calculated route I start the mMapDataPrefetcher.fetchMapData(route,radius), and then immediately start the mNavigationManager.simulate(route,speed). The navigation is a little wonky until the map data is loaded, but starts responding immediately after the map loading is complete. The loading can be slow in some of my testing, not sure why. But in frequent uses, the map data is often already present, so works better in that case.

    I'm not sure what a good radius is; I tried 500m and the call failed; 2000m is working for me right now.

    See the pages here:

    These features are described as beta, so I'm not sure if there is any way to do this in a supported, production fashion.