Customize map view

The default behavior of the Consumer SDK Map View is to auto-set bounds on the Driver's location and the Destination. This way, as the Driver moves closer to the Destination, the zoom level increases.

If your use-case requires a different behavior, you can use the following methods.

Show start location

The default behavior of the map fragment is to set the bounds with the driver's location and the destination. If you want the bounds to include start location as well, you need to enable the visibility of Source Marker by overriding showSourceMarkerForTaskID method and then overriding disableDynamicZoom method of HTMapAdapterclass.

With this, the start location will be visible in the bounds, along with the driver's location and the destination.

@Override
public boolean showSourceMarkerForTaskID(HTMapFragment htMapFragment, String taskID) {
  return true;
}

@Override
public boolean disableDynamicZoom(HTMapFragment mapFragment) {
  return false;
}

Auto-bounds for map

By default, the map view automatically re-focuses the map bounds as the location of the marker changes.

Disabling Map Auto-bounds

To disable auto-bounds, and keep the map bounds stationary when the marker moves, use the disableMapBounds method on the map fragment.

public void disableBounds() {
  mapFragment.disableMapBounds();
}

Reset Map Auto-bounds

By calling resetMapBounds you can reset the behavior of map auto-bounds, to change bounds as the marker location changes. If dynamicZoom is disabled, the start location will also be included in the map bounds.

public void resetBounds() {
  mapFragment.resetMapBounds();
}

[success] Customising bounds and zoom level

With this and the previous guide, you can customise the look and feel of the Consumer UI, to suit your use-case.

results matching ""

    No results matching ""