마커 맞춤설정하기
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
지도에 추가된 마커의 디자인과 분위기를 맞춤설정합니다. 지도에 추가된 마커의 디자인과 분위기를 다음과 같은 두 가지 방법으로 맞춤설정할 수 있습니다.
유형에 따라 마커 스타일 지정: 동일한 유형의 마커에 스타일을 지정하는 MarkerOptions
객체를 지정합니다. 지정한 변경사항은 각 마커가 생성된 후에 적용되어 기본 옵션을 덮어씁니다.
예를 보려면 이 가이드의 MarkerOptions
를 사용하여 마커 스타일 변경을 참고하세요.
데이터에 따라 마커 스타일 지정: 데이터에 따라 마커 스타일을 지정하는 맞춤설정 함수를 지정합니다. 이동 경로 공유 또는 외부 소스의 데이터를 기반으로 스타일을 지정할 수 있습니다.
이동 공유의 데이터: 이동 공유는 마커가 나타내는 객체 유형(차량, 출발지, 경유지 또는 목적지)을 비롯한 마커 데이터를 맞춤설정 함수에 전달합니다. 그러면 마커 요소의 현재 상태에 따라 마커 스타일이 변경됩니다. 예를 들어 차량이 이동을 완료할 때까지 남은 경유지 수입니다.
외부 소스: 이동 공유 데이터를 Fleet Engine 외부 소스의 데이터와 결합하고 해당 정보를 기반으로 마커의 스타일을 지정할 수도 있습니다.
예를 보려면 이 가이드의 맞춤설정 함수를 사용하여 마커 스타일 변경을 참고하세요.
마커에 클릭 처리 추가: 예는 클릭 처리 추가를 참고하세요.
마커 맞춤설정 옵션
두 옵션 모두 Google Maps JavaScript API의 FleetEngineTripLocationProviderOptions
아래에 있는 다음 맞춤설정 매개변수를 사용합니다.
MarkerOptions
를 사용하여 마커 스타일 변경
다음 예에서는 MarkerOptions
객체를 사용하여 차량 마커 스타일을 구성하는 방법을 보여줍니다. 이 패턴에 따라 마커 맞춤설정 옵션에 나열된 마커 맞춤설정을 사용하여 마커의 스타일을 맞춤설정합니다.
자바스크립트
deliveryVehicleMarkerCustomization = {
cursor: 'grab'
};
TypeScript
deliveryVehicleMarkerCustomization = {
cursor: 'grab'
};
맞춤설정 함수를 사용하여 마커 스타일 변경
다음 예에서는 맞춤설정 함수를 사용하여 차량 마커 스타일을 구성하는 방법을 보여줍니다. 이 패턴에 따라 마커 맞춤설정 옵션에 나열된 마커 맞춤설정 매개변수를 사용하여 마커의 스타일을 맞춤설정합니다.
자바스크립트
vehicleMarkerCustomization =
(params) => {
var distance = params.trip.remainingWaypoints.length;
params.marker.setLabel(`${distance}`);
};
TypeScript
vehicleMarkerCustomization =
(params: TripMarkerCustomizationFunctionParams) => {
const distance = params.trip.remainingWaypoints.length;
params.marker.setLabel(`${distance}`);
};
마커에 클릭 처리 추가
다음 예에서는 차량 마커에 클릭 핸들러를 추가하는 방법을 보여줍니다.
이 패턴에 따라 마커 맞춤설정 옵션에 나열된 마커 맞춤설정 매개변수를 사용하여 클릭 처리를 마커에 추가합니다.
자바스크립트
vehicleMarkerCustomization =
(params) => {
if (params.isNew) {
params.marker.addListener('click', () => {
// Perform desired action.
});
}
};
TypeScript
vehicleMarkerCustomization =
(params: TripMarkerCustomizationFunctionParams) => {
if (params.isNew) {
params.marker.addListener('click', () => {
// Perform desired action.
});
}
};
다음 단계
달리 명시되지 않는 한 이 페이지의 콘텐츠에는 Creative Commons Attribution 4.0 라이선스에 따라 라이선스가 부여되며, 코드 샘플에는 Apache 2.0 라이선스에 따라 라이선스가 부여됩니다. 자세한 내용은 Google Developers 사이트 정책을 참조하세요. 자바는 Oracle 및/또는 Oracle 계열사의 등록 상표입니다.
최종 업데이트: 2025-08-31(UTC)
[null,null,["최종 업데이트: 2025-08-31(UTC)"],[[["\u003cp\u003eCustomize the look and feel of markers on the map based on marker type or underlying data like trip progress.\u003c/p\u003e\n"],["\u003cp\u003eUse \u003ccode\u003eMarkerOptions\u003c/code\u003e objects to style markers by type, such as setting the cursor for delivery vehicle markers.\u003c/p\u003e\n"],["\u003cp\u003eUse customization functions to style markers dynamically based on trip data, like displaying remaining waypoints.\u003c/p\u003e\n"],["\u003cp\u003eImplement custom click handling for markers to trigger specific actions when a user interacts with them.\u003c/p\u003e\n"],["\u003cp\u003eLeverage \u003ccode\u003eFleetEngineTripLocationProviderOptions\u003c/code\u003e to access marker customization parameters like \u003ccode\u003evehicleMarkerCustomization\u003c/code\u003e.\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\nCustomize the look and feel of markers added to the map. Customize the look\nand feel of markers added to the map in two ways:\n\n1. **Style markers based on type** : Specify a\n [`MarkerOptions`](/maps/documentation/javascript/reference/marker#MarkerOptions)\n object to style markers of the same type. The changes you specify are\n then applied after each marker is created, overwriting any default options.\n For examples, see\n [Change the styling of markers using `MarkerOptions`](#markeropt) in this\n guide.\n\n2. **Style markers based on data**: Specify a customization function to\n style markers based on data. You can style based on data from journey\n sharing, or from outside sources:\n\n - **Data from trip sharing**: Trip sharing passes marker data to the\n customization function including the type of object the marker represents:\n vehicle, origin, waypoint or destination. Marker styling then changes\n based on the current state of the marker element. For example, the number\n of waypoints remaining until the vehicle finishes the trip.\n\n - **Outside sources**: You can combine the trip sharing data with\n data from sources outside Fleet Engine and style the marker based on that\n information as well.\n\n For examples, see\n [Change the styling of markers using customization functions](#vehicle-markers)\n in this guide.\n3. **Add click handling to markers** : For examples,\n see [Add click handling](#add-click).\n\nMarker customization options\n\nBoth options use the following customization parameters in the Google\nMaps JavaScript API under\n[`FleetEngineTripLocationProviderOptions`](/maps/documentation/javascript/reference/journey-sharing-trip-and-order-progress#FleetEngineTripLocationProviderOptions):\n\n- [`vehicleMarkerCustomization`](/maps/documentation/javascript/reference/journey-sharing-trip-and-order-progress#FleetEngineTripLocationProviderOptions.vehicleMarkerCustomization)\n- [`originMarkerCustomization`](/maps/documentation/javascript/reference/journey-sharing-trip-and-order-progress#FleetEngineTripLocationProviderOptions.originMarkerCustomization)\n- [`waypointMarkerCustomization`](/maps/documentation/javascript/reference/journey-sharing-trip-and-order-progress#FleetEngineTripLocationProviderOptions.waypointMarkerCustomization)\n- [`destinationMarkerCustomization`](/maps/documentation/javascript/reference/journey-sharing-trip-and-order-progress#FleetEngineTripLocationProviderOptions.destinationMarkerCustomization)\n\nChange the styling of markers using `MarkerOptions`\n\nThe following example shows how to configure vehicle marker styling with\na `MarkerOptions` object. Follow this pattern to customize the styling of any\nmarker using any of the marker customizations listed in\n[Marker customization options](#cust-options). \n\nJavaScript \n\n deliveryVehicleMarkerCustomization = {\n cursor: 'grab'\n };\n\nTypeScript \n\n deliveryVehicleMarkerCustomization = {\n cursor: 'grab'\n };\n\nChange the styling of markers using customization functions\n\nThe following example shows how to configure vehicle marker styling using\ncustomization functions. Follow this pattern to customize the styling of any\nmarker using any of the marker customization parameters listed in\n[Marker customization options](#cust-options). \n\nJavaScript \n\n vehicleMarkerCustomization =\n (params) =\u003e {\n var distance = params.trip.remainingWaypoints.length;\n params.marker.setLabel(`${distance}`);\n };\n\nTypeScript \n\n vehicleMarkerCustomization =\n (params: TripMarkerCustomizationFunctionParams) =\u003e {\n const distance = params.trip.remainingWaypoints.length;\n params.marker.setLabel(`${distance}`);\n };\n\nAdd click handling to markers\n\nThe following example shows how to add click handling to a vehicle marker.\nFollow this pattern to add click handling to any marker using any of the marker\ncustomization parameters listed in [Marker customization options](#cust-options). \n\nJavaScript \n\n vehicleMarkerCustomization =\n (params) =\u003e {\n if (params.isNew) {\n params.marker.addListener('click', () =\u003e {\n // Perform desired action.\n });\n }\n };\n\nTypeScript \n\n vehicleMarkerCustomization =\n (params: TripMarkerCustomizationFunctionParams) =\u003e {\n if (params.isNew) {\n params.marker.addListener('click', () =\u003e {\n // Perform desired action.\n });\n }\n };\n\nWhat's next\n\n- [Customize route polylines](/maps/documentation/mobility/journey-sharing/on-demand/javascript/customize-route-polylines)"]]