The ConsumerMapStyle
class provides setter and getter methods with dynamic customization
for markers and polylines. You expose this class asynchronously using the
ConsumerController.getConsumerMapStyle()
method.
UI customization persists across device rotations and remains in effect until
you detach the
ConsumerController
.
Customize markers
To set the marker type and its properties, use the
ConsumerMapStyle.setMarkerStyleOptions()
method. Your custom
marker options override the default values provided by the Consumer SDK.
To restore the default values, call setMarkerStyleOptions()
using null
for the MarkerOptions
parameter. Retrieve the active MarkerOptions
using
getMarkerStyleOptions()
.
Select a marker type
You can use and customize the following marker icons:
TRIP_PICKUP_POINT
- Displays while following a tripTRIP_DROPOFF_POINT
- Displays while following a tripTRIP_INTERMEDIATE_DESTINATION
TRIP_VEHICLE
- Displays while following a tripThe Consumer SDK updates the rotation of the
TRIP_VEHICLE
icon during trip monitoring to mimic the behavior of the actual vehicle as it travels the route.
Select marker options
You can customize markers for your consumer app by following these steps:
Use the properties for each marker provided by Google Maps
MarkerOptions
.Build
MarkerOptions
using its constructor.Specify custom properties using 'Setter' style methods.
If you prefer, use your own UI element by mimicking the patterns provided by the
MarkerOptions
constructor.To turn off a marker, set the
visible
property tofalse
. You can then use your own UI element in its place.
For more information, see Google Maps
MarkerOptions
.
Example marker customizations
Java
// Initializing marker options.
consumerController
.getConsumerMapStyle()
.addOnSuccessListener(
consumerMapStyle -> {
consumerMapStyle.setMarkerStyleOptions(
MarkerType.TRIP_VEHICLE,
new MarkerOptions()
.visible(false));
});
// Reset marker options to default values.
consumerMapStyle.setMarkerStyleOptions(MarkerType.TRIP_VEHICLE, null);
Kotlin
// Initializing marker options.
consumerController
.getConsumerMapStyle()
.addOnSuccessListener({ consumerMapStyle ->
consumerMapStyle.setMarkerStyleOptions(MarkerType.TRIP_VEHICLE, MarkerOptions().visible(false))
})
// Reset marker options to default values.
consumerMapStyle.setMarkerStyleOptions(MarkerType.TRIP_VEHICLE, null)