privateFeatureLayerpostalCodeLayer; @OverridepublicvoidonMapReady(GoogleMapmap){// Get the POSTAL_CODE feature layer.postalCodeLayer=map.getFeatureLayer(newFeatureLayerOptions.Builder().featureType(FeatureType.POSTAL_CODE).build());...}
Kotlin
privatevarpostalCodeLayer:FeatureLayer?=null overridefunonMapReady(googleMap:GoogleMap){// Get the POSTAL_CODE feature layer.postalCodeLayer=googleMap.getFeatureLayer(newFeatureLayerOptions.Builder().featureType(FeatureType.POSTAL_CODE).build())...}
FeatureLayerOptions 객체를 getFeatureLayer()에 전달하여 피처 레이어의 유형을 지정합니다. 이 예시에서는 POSTAL_CODE 레이어에 액세스하려고 합니다. 스타일을 지정하려는 각 레이어에 대해 다른 FeatureLayer 객체를 만듭니다.
FeatureLayer 객체가 있으면 해당 지형지물의 경계 다각형에 스타일을 적용할 수 있습니다.
지도 기능 확인(필수)
경계에 대한 데이터 기반 스타일 지정에는 지도 ID가 필요합니다. 지도 ID가 누락되었거나 잘못된 지도 ID가 전달된 경우 경계의 데이터 기반 스타일을 로드할 수 없습니다. 문제 해결 단계로 MapCapabilities를 사용하여 경계의 데이터 기반 스타일 지정이 지원되는지 확인할 수 있습니다.
Kotlin
valcapabilities:MapCapabilities=googleMap.getMapCapabilities()System.out.println("Data-driven Styling is available: "+capabilities.isDataDrivenStylingAvailable())
Java
MapCapabilitiescapabilities=googleMap.getMapCapabilities();System.out.println("Data-driven Styling is available: "+capabilities.isDataDrivenStylingAvailable());
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["필요한 정보가 없음","missingTheInformationINeed","thumb-down"],["너무 복잡함/단계 수가 너무 많음","tooComplicatedTooManySteps","thumb-down"],["오래됨","outOfDate","thumb-down"],["번역 문제","translationIssue","thumb-down"],["샘플/코드 문제","samplesCodeIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-09-10(UTC)"],[[["\u003cp\u003eData-driven styling for boundaries requires using the upgraded map renderer (available since Maps SDK for Android v18.0.0) and creating a map ID with an associated map style.\u003c/p\u003e\n"],["\u003cp\u003eYou can select specific boundary feature layers (like Postal Code or Locality) to display on your map by customizing your map style in the Google Cloud Console, optimizing for performance by choosing only necessary layers.\u003c/p\u003e\n"],["\u003cp\u003eTo apply data-driven styling, get access to feature layers via \u003ccode\u003eGoogleMap.getFeatureLayer()\u003c/code\u003e with \u003ccode\u003eFeatureLayerOptions\u003c/code\u003e defining the desired layer type, and style them individually.\u003c/p\u003e\n"],["\u003cp\u003eBefore implementing data-driven styling, it's crucial to check for device compatibility using \u003ccode\u003eMapCapabilities.isDataDrivenStylingAvailable()\u003c/code\u003e at runtime and provide a fallback in case it's not supported.\u003c/p\u003e\n"]]],[],null,[]]