maplibre / maplibre-navigation-android

Maplibre Navigation SDK for Android
MIT License
86 stars 44 forks source link

[No issue] Info about show Instructions and Maneuvers #70

Open moiatto opened 1 year ago

moiatto commented 1 year ago

Can you tell me how show instructions and maneuvers as standalone UI components?

Because I use the library for routing, not to show map. I have a valid DirectionsRoute and MapboxNavigation variables.

boldtrn commented 1 year ago

I don't think this library works standalone, or at least would quite some refactoring. I think it would be great if it would work independent from the map implementation, but this would quite some changes.

moiatto commented 1 year ago

Understood

moiatto commented 1 year ago

We use the the onMilestoneEvent in the Kurviger App, there is an arrival milestone, milestones are triggered for Banner Instructions (IIRC).

I tried a lot but without success.

Can you tell me what's wrong?

// Custom Milestone for DESTINATION
navigation.addMilestone(new RouteMilestone.Builder()
        .setIdentifier(1002)
        .setInstruction(new Instruction() {
                            @Override
                            public String buildInstruction(RouteProgress routeProgress) {
                                return "Destination";
                            }
                        })
        .setTrigger(Trigger.all(
                            Trigger.eq(TriggerProperty.LAST_LEG, TriggerProperty.TRUE),
                            Trigger.eq(TriggerProperty.LAST_STEP, TriggerProperty.TRUE)
                    ))
        .build());

// Custom Milestone for WAYPOINT
navigation.addMilestone(new StepMilestone.Builder()
        .setIdentifier(1001)
        .setInstruction(new Instruction() {
                          @Override
                          public String buildInstruction(RouteProgress routeProgress) {
                              return "Waypoint";
                          }
                      })
        .setTrigger(Trigger.all(
                            Trigger.eq(TriggerProperty.LAST_LEG, TriggerProperty.FALSE),
                            Trigger.eq(TriggerProperty.LAST_STEP, TriggerProperty.TRUE)
                    ))
        .build());

About Trigger.eq(TriggerProperty.LAST_STEP, TriggerProperty.TRUE) can you tell me why in TriggerProperty.java:

statementObjects.put(TriggerProperty.LAST_STEP,
  new Number[] {routeProgress.currentLegProgress().stepIndex(),
    (routeProgress.currentLeg().steps().size() - 2)});

(routeProgress.currentLeg().steps().size() - 2) I don't understand -2 ?