Lớp ConsumerMapStyle cung cấp các phương thức setter và getter có khả năng tuỳ chỉnh linh hoạt cho các điểm đánh dấu và đường nhiều đoạn. Bạn sẽ hiển thị lớp này không đồng bộ bằng phương thức ConsumerController.getConsumerMapStyle().
Chế độ tuỳ chỉnh giao diện người dùng vẫn duy trì trong quá trình xoay thiết bị và vẫn có hiệu lực cho đến khi bạn tháo ConsumerController.
Tuỳ chỉnh điểm đánh dấu
Để đặt loại điểm đánh dấu và các thuộc tính của loại điểm đánh dấu, hãy sử dụng phương thức ConsumerMapStyle.setMarkerStyleOptions(). Các lựa chọn về điểm đánh dấu tuỳ chỉnh sẽ ghi đè các giá trị mặc định do Consumer SDK cung cấp.
Để khôi phục các giá trị mặc định, hãy gọi setMarkerStyleOptions() bằng cách sử dụng null cho tham số MarkerOptions. Truy xuất MarkerOptions đang hoạt động bằng cách dùng getMarkerStyleOptions().
Chọn loại điểm đánh dấu
Bạn có thể sử dụng và tuỳ chỉnh các biểu tượng điểm đánh dấu sau:
TRIP_PICKUP_POINT – Xuất hiện khi bạn đang theo dõi một chuyến đi
TRIP_DROPOFF_POINT – Xuất hiện khi bạn đang theo dõi một chuyến đi
TRIP_INTERMEDIATE_DESTINATION
TRIP_VEHICLE – Xuất hiện khi bạn đang theo dõi một chuyến đi
Consumer SDK cập nhật hướng xoay của biểu tượng TRIP_VEHICLE trong quá trình giám sát chuyến đi để mô phỏng hành vi của xe thực tế khi xe di chuyển trên tuyến đường.
Chọn các lựa chọn về điểm đánh dấu
Bạn có thể tuỳ chỉnh điểm đánh dấu cho ứng dụng người tiêu dùng bằng cách làm theo các bước sau:
Sử dụng các thuộc tính cho từng điểm đánh dấu do Google Maps MarkerOptions cung cấp.
Tạo MarkerOptions bằng hàm khởi tạo tương ứng.
Chỉ định các thuộc tính tuỳ chỉnh bằng cách sử dụng các phương thức theo kiểu "Setter".
Nếu muốn, hãy sử dụng phần tử giao diện người dùng của riêng bạn bằng cách mô phỏng các mẫu do hàm khởi tạo MarkerOptions cung cấp.
Để tắt một điểm đánh dấu, hãy đặt thuộc tính visible thành false. Sau đó, bạn có thể sử dụng phần tử trên giao diện người dùng của riêng mình thay cho phần tử này.
Để biết thêm thông tin, hãy xem Google Maps
MarkerOptions.
Ví dụ về cách tuỳ chỉnh điểm đánh dấu
Java
// Initializing marker options.consumerController.getConsumerMapStyle().addOnSuccessListener(consumerMapStyle->{consumerMapStyle.setMarkerStyleOptions(MarkerType.TRIP_VEHICLE,newMarkerOptions().visible(false));});// Reset marker options to default values.consumerMapStyle.setMarkerStyleOptions(MarkerType.TRIP_VEHICLE,null);
[null,null,["Cập nhật lần gần đây nhất: 2025-08-31 UTC."],[[["\u003cp\u003eThe \u003ccode\u003eConsumerMapStyle\u003c/code\u003e class allows you to customize markers and polylines for the consumer experience using setter and getter methods.\u003c/p\u003e\n"],["\u003cp\u003eYou can customize the marker type, appearance, and visibility using the \u003ccode\u003esetMarkerStyleOptions()\u003c/code\u003e method and restore defaults by passing \u003ccode\u003enull\u003c/code\u003e as the \u003ccode\u003eMarkerOptions\u003c/code\u003e parameter.\u003c/p\u003e\n"],["\u003cp\u003eThe available marker types include \u003ccode\u003eTRIP_PICKUP_POINT\u003c/code\u003e, \u003ccode\u003eTRIP_DROPOFF_POINT\u003c/code\u003e, \u003ccode\u003eTRIP_INTERMEDIATE_DESTINATION\u003c/code\u003e, and \u003ccode\u003eTRIP_VEHICLE\u003c/code\u003e, which dynamically rotates during trip monitoring.\u003c/p\u003e\n"],["\u003cp\u003eUse the Google Maps \u003ccode\u003eMarkerOptions\u003c/code\u003e properties to customize marker appearance and set \u003ccode\u003evisible\u003c/code\u003e to \u003ccode\u003efalse\u003c/code\u003e to hide a marker and potentially replace it with your own UI element.\u003c/p\u003e\n"],["\u003cp\u003eUI customizations persist across device rotations and remain in effect until the \u003ccode\u003eConsumerController\u003c/code\u003e is detached.\u003c/p\u003e\n"]]],[],null,["Select platform: [Android](/maps/documentation/mobility/journey-sharing/on-demand/android/customize-markers \"View this page for the Android platform docs.\") [iOS](/maps/documentation/mobility/journey-sharing/on-demand/ios/customize-markers \"View this page for the iOS platform docs.\") [JavaScript](/maps/documentation/mobility/journey-sharing/on-demand/javascript/customize-markers \"View this page for the JavaScript platform docs.\")\n\n\u003cbr /\u003e\n\nThe [`ConsumerMapStyle`](/maps/documentation/mobility/journey-sharing/on-demand/reference/consumer_2/android/reference/com/google/android/libraries/mapsplatform/transportation/consumer/view/ConsumerMapStyle)\nclass provides setter and getter methods with dynamic customization\nfor markers and polylines. You expose this class asynchronously using the\n[`ConsumerController.getConsumerMapStyle()`](/maps/documentation/mobility/journey-sharing/on-demand/reference/consumer_2/android/reference/com/google/android/libraries/mapsplatform/transportation/consumer/view/ConsumerController#getConsumerMapStyle())\nmethod.\n\nUI customization persists across device rotations and remains in effect until\nyou detach the\n[`ConsumerController`](/maps/documentation/mobility/journey-sharing/on-demand/reference/consumer_2/android/reference/com/google/android/libraries/mapsplatform/transportation/consumer/view/ConsumerController).\n\nCustomize markers\n\nTo set the marker type and its properties, use the\n[`ConsumerMapStyle.setMarkerStyleOptions()`](/maps/documentation/mobility/journey-sharing/on-demand/reference/consumer_2/android/reference/com/google/android/libraries/mapsplatform/transportation/consumer/view/ConsumerMapStyle#setMarkerStyleOptions(int,%20com.google.android.gms.maps.model.MarkerOptions))\nmethod. Your custom\nmarker options override the default values provided by the Consumer SDK.\nTo restore the default values, call `setMarkerStyleOptions()` using `null`\nfor the `MarkerOptions` parameter. Retrieve the active `MarkerOptions`\nusing\n[`getMarkerStyleOptions()`](/maps/documentation/mobility/journey-sharing/on-demand/reference/consumer_2/android/reference/com/google/android/libraries/mapsplatform/transportation/consumer/view/ConsumerMapStyle#getMarkerStyleOptions(int)).\n\nSelect a marker type\n\nYou can use and customize the following marker icons:\n\n- `TRIP_PICKUP_POINT` - Displays while following a trip\n- `TRIP_DROPOFF_POINT` - Displays while following a trip\n- `TRIP_INTERMEDIATE_DESTINATION`\n- `TRIP_VEHICLE` - Displays while following a trip\n\n The Consumer SDK updates\n the rotation of the `TRIP_VEHICLE` icon during trip monitoring to mimic the\n behavior of the actual vehicle as it travels the route.\n\n| **Note:** For the most realistic animation results, use a top view perspective for `TRIP_VEHICLE`, with the front of the vehicle oriented upwards.\n| **Note:** The marker icon doesn't change according to the actual vehicle type for the trip.\n\nSelect marker options\n\nYou can customize markers for your consumer app by following these steps:\n\n1. Use the properties for each marker provided by Google Maps `MarkerOptions`.\n\n2. Build `MarkerOptions` using its constructor.\n\n3. Specify custom properties using 'Setter' style methods.\n\n | **Note:** Since the SDK provides default values for each marker property, only specify custom properties for the values you want to change.\n4. If you prefer, use your own UI element by mimicking the patterns\n provided by the `MarkerOptions` constructor.\n\n5. To turn off a marker, set the `visible` property to `false`. You can then\n use your own UI element in its place.\n\nFor more information, see Google Maps\n[`MarkerOptions`](https://developers.google.com/android/reference/com/google/android/gms/maps/model/MarkerOptions).\n\nExample marker customizations \n\nJava \n\n // Initializing marker options.\n consumerController\n .getConsumerMapStyle()\n .addOnSuccessListener(\n consumerMapStyle -\u003e {\n consumerMapStyle.setMarkerStyleOptions(\n MarkerType.TRIP_VEHICLE,\n new MarkerOptions()\n .visible(false));\n });\n\n // Reset marker options to default values.\n consumerMapStyle.setMarkerStyleOptions(MarkerType.TRIP_VEHICLE, null);\n\nKotlin \n\n // Initializing marker options.\n consumerController\n .getConsumerMapStyle()\n .addOnSuccessListener({ consumerMapStyle -\u003e\n consumerMapStyle.setMarkerStyleOptions(MarkerType.TRIP_VEHICLE, MarkerOptions().visible(false))\n })\n\n // Reset marker options to default values.\n consumerMapStyle.setMarkerStyleOptions(MarkerType.TRIP_VEHICLE, null)\n\nWhat's next\n\n- [Customize route polylines](/maps/documentation/mobility/journey-sharing/on-demand/android/customize-polylines)"]]