Android Consumer SDK v1.0 맞춤설정 맞춤설정

마커 맞춤설정

이전 버전의 Consumer SDK에서는 Consumer SDK의 MarkerStyleOptions 객체를 사용하여 마커 스타일 속성을 맞춤설정했습니다. Consumer SDK v1.0에서는 Maps SDK의 MarkerOptions 객체를 직접 사용합니다.

// Centering the marker anchor at (0.5, 0.5) is recommended.
// For vehicle markers, set flat to true to allow the vehicle marker to freely
// rotate flat on the map (rather than always have it face the camera).
MarkerOptions vehicleMarkerOptions = new MarkerOptions()
    .flat(true)
    .anchor(0.5f, 0.5f)
    .icon(vehicleIcon)
    .zIndex(1.0f);
consumerMapStyle.setMarkerStyleOptions(MarkerType.TRIP_VEHICLE);

ConsumerMapStyle은 스타일이 아직 설정되지 않았거나 스타일 옵션이 null로 설정된 경우 지정된 마커 유형에 대해 SDK에서 지정한 기본 스타일 옵션을 반환합니다.

// ConsumerMapStyle returns the SDK-set default style options if none has been set yet.
MarkerOptions defaultPickupPointStyleOptions = consumerMapStyle.getMarkerStyleOptions(MarkerType.PICKUP_POINT);

// Setting the style to null reverts the style back to the SDK-set default properties.
consumerMapStyle.setMarkerStyleOptions(MarkerType.PICKUP_POINT, /* markerStyleOptions= */ null);
MarkerOptions defaultPickupPointStyleOptions = consumerMapStyle.getMarkerStyleOptions(MarkerType.PICKUP_POINT);

새 스타일을 처음부터 만들지 않으려면 기본 스타일을 수정하면 됩니다. 다음 예에서는 픽업 아이콘만 수정하고 나머지 마커 옵션에 SDK의 기본 설정을 사용합니다.

// getMarkerStyleOptions returns the default pickup point style options, since
// the custom style hasn't been set yet.
MarkerOptions pickupPointStyleOptions =
  consumerMapStyle.getMarkerStyleOptions(MarkerType.PICKUP_POINT);
// Modify the icon value and set the style.
consumerMapStyle.setMarkerStyleOptions(
  pickupPointStyleOptions.icon(pickupPointIcon));

다중선 맞춤설정

이전 버전의 Consumer SDK에서는 Consumer SDK의 PolylineStyleOptions 객체를 사용하여 다중선 스타일 속성을 맞춤설정했습니다. Consumer SDK v1.0에서는 Maps SDK의 PolylineOptions 객체를 사용하여 기본 다중선 스타일 속성을 맞춤설정하고 TrafficStyle 객체를 사용하여 다중선 교통정보 색상을 맞춤설정합니다.

교통정보 다중선은 Consumer SDK v1.0의 알파 변형에서 사용할 수 있습니다. 교통정보가 표시되면 기본 다중선 색상이 교통정보 색상으로 재정의됩니다. 트래픽은 기본적으로 표시되지 않습니다. 설정되지 않은 TrafficStyle의 필드는 SDK에서 지정한 기본값으로 채워집니다.

// PolylineOptions is from Maps SDK
PolylineOptions polylineOptions = new PolylineOptions()
  .color(color)
  .width(width)
  .geodesic(geodesic)
  .startCap(startCap)
  .endCap(endCap)
  .zIndex(zIndex);
consumerMapStyle.setPolylineStyleOptions(
  PolylineType.ACTIVE_ROUTE, polylineOptions);

// TrafficStyle is from ConsumerSDK
TrafficStyle trafficStyle = TrafficStyle.builder()
  .setTrafficVisibility(true)
  .setTrafficColor(SpeedType.NO_DATA, Color.GREY)
  .setTrafficColor(SpeedType.NORMAL_VALUE, Color.BLUE)
  .setTrafficColor(SpeedType.SLOW_VALUE, Color.ORANGE)
  .setTrafficColor(SpeedType.TRAFFIC_JAM, Color.RED)
  .build();
consumerMapStyle.setPolylineTrafficStyle(PolylineType.ACTIVE_ROUTE, trafficStyle);

ConsumerMapStyle는 지정된 다중선 유형에 대해 SDK의 기본 스타일 옵션을 반환합니다(아직 설정되지 않은 경우 또는 스타일 옵션이 null로 설정된 경우). 이는 기본 PolylineOptionsTrafficStyle에 모두 적용됩니다.

// ConsumerMapStyle returns the SDK's default style options if none has been set yet.
PolylineOptions defaultActiveRouteStyleOptions = consumerMapStyle.getPolylineStyleOptions(PolylineType.ACTIVE_ROUTE);

// Setting the style to null reverts the style back to the SDK-set default properties.
consumerMapStyle.setPolylineStyleOptions(
  PolylineType.ACTIVE_ROUTE, /* polylineStyleOptions= */ null);
PolylineOptions defaultActiveRouteStyleOptions =
  consumerMapStyle.getPolylineStyleOptions(PolylineType.ACTIVE_ROUTE);

새 스타일을 처음부터 만들지 않으려면 기본 스타일을 수정하면 됩니다. 다음 예에서는 기본 활성 경로 다중선 색상만 수정하고 나머지 마커 옵션에 SDK의 기본 스타일 설정을 사용합니다.

// Only customize the remaining route polyline color.
PolylineOptions remainingRouteStyleOptions =
     consumerMapStyle.getPolylineStyleOptions(PolylineType.REMAINING_ROUTE);
consumerMapStyle.setPolylineStyleOptions(
  remainingRouteStyleOptions.color(Color.DARK_BLUE));