경계 다각형 스타일 지정
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
경계 다각형의 채우기 및 획의 스타일을 지정하려면 GMSPlaceFeature
을 허용하고 GMSFeatureStyle
을 반환하는 스타일 지정 클로저를 사용하여 스타일 속성을 정의하세요. 그런 다음 스타일 속성을 스타일 지정 클로저로 설정합니다. 스타일 지정 클로저에는 스타일 지정 로직이 포함됩니다.
Swift
let mapView = GMSMapView(frame: .zero, mapID: GMSMapID(identifier: "YOUR_MAP_ID"), camera: GMSCameraPosition(latitude: 20.773, longitude: -156.01, zoom: 12))
let layer = mapView.featureLayer(of: .locality)
// Define a style with purple
let style = FeatureStyle(fill: .purple.withAlphaComponent(0.5), stroke: .purple, strokeWidth: 3.0)
// Apply the style to a single boundary.
layer.style = { ($0.placeID == "ChIJ0zQtYiWsVHkRk8lRoB1RNPo"/* Hana, HI */) ? style : nil }
Objective-C
GMSMapView *mapView = [GMSMapView mapWithFrame:CGRectZero mapID:[GMSMapID mapIDWithIdentifier:@"MAP_ID"] camera:[GMSCameraPosition cameraWithLatitude: 20.773 longitude: -156.01 zoom:12]];
GMSFeatureLayer<GMSPlaceFeature *> *layer = [mapView featureLayerOfFeatureType:GMSFeatureTypeLocality];
// Define a style with purple fill and border.
GMSFeatureStyle *style = [GMSFeatureStyle styleWithFillColor:[[UIColor purpleColor] colorWithAlphaComponent:0.5] strokeColor:[UIColor purpleColor] strokeWidth:3.0];
// Apply the style to a single boundary.
layer.style = ^(GMSPlaceFeature *feature) {
return [feature.placeID isEqual:@"ChIJ0zQtYiWsVHkRk8lRoB1RNPo"/* Hana, HI */] ? style : nil;
};
달리 명시되지 않는 한 이 페이지의 콘텐츠에는 Creative Commons Attribution 4.0 라이선스에 따라 라이선스가 부여되며, 코드 샘플에는 Apache 2.0 라이선스에 따라 라이선스가 부여됩니다. 자세한 내용은 Google Developers 사이트 정책을 참조하세요. 자바는 Oracle 및/또는 Oracle 계열사의 등록 상표입니다.
최종 업데이트: 2025-08-31(UTC)
[null,null,["최종 업데이트: 2025-08-31(UTC)"],[[["\u003cp\u003eThis documentation explains how to style the fill and stroke of boundary polygons using a styling closure that takes a \u003ccode\u003eGMSPlaceFeature\u003c/code\u003e and returns a \u003ccode\u003eGMSFeatureStyle\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eThe styling closure defines the style attributes for the polygon, such as fill color, stroke color, and stroke width.\u003c/p\u003e\n"],["\u003cp\u003eStyling Places data might require integrating the Places SDK for iOS, although it's not always mandatory.\u003c/p\u003e\n"],["\u003cp\u003eCode examples in Swift and Objective-C demonstrate how to apply a purple style to a specific boundary polygon using its place ID.\u003c/p\u003e\n"]]],[],null,["Select platform: [Android](/maps/documentation/android-sdk/dds-boundaries/style-polygon \"View this page for the Android platform docs.\") [iOS](/maps/documentation/ios-sdk/dds-boundaries/style-polygon \"View this page for the iOS platform docs.\") [JavaScript](/maps/documentation/javascript/dds-boundaries/style-polygon \"View this page for the JavaScript platform docs.\")\n\n\u003cbr /\u003e\n\nTo style the fill and stroke for a boundary polygon, use a styling closure that\naccepts a [`GMSPlaceFeature`](/maps/documentation/ios-sdk/reference/objc/Classes/GMSPlaceFeature) and returns a\n[`GMSFeatureStyle`](/maps/documentation/ios-sdk/reference/objc/Classes/GMSFeatureStyle) to define style attributes. Then set the\nstyle property to a styling closure, which contains styling logic.\n\n**Important:** While not required for all capabilities, styling of Places data may require integration with the [Places SDK for iOS](/maps/documentation/places/ios-sdk). \n\nSwift \n\n```swift\nlet mapView = GMSMapView(frame: .zero, mapID: GMSMapID(identifier: \"YOUR_MAP_ID\"), camera: GMSCameraPosition(latitude: 20.773, longitude: -156.01, zoom: 12))\n\nlet layer = mapView.featureLayer(of: .locality)\n\n// Define a style with purple\nlet style = FeatureStyle(fill: .purple.withAlphaComponent(0.5), stroke: .purple, strokeWidth: 3.0)\n\n// Apply the style to a single boundary.\nlayer.style = { ($0.placeID == \"ChIJ0zQtYiWsVHkRk8lRoB1RNPo\"/* Hana, HI */) ? style : nil }\n```\n\nObjective-C \n\n```objective-c\nGMSMapView *mapView = [GMSMapView mapWithFrame:CGRectZero mapID:[GMSMapID mapIDWithIdentifier:@\"MAP_ID\"] camera:[GMSCameraPosition cameraWithLatitude: 20.773 longitude: -156.01 zoom:12]];\n\nGMSFeatureLayer\u003cGMSPlaceFeature *\u003e *layer = [mapView featureLayerOfFeatureType:GMSFeatureTypeLocality];\n\n// Define a style with purple fill and border.\nGMSFeatureStyle *style = [GMSFeatureStyle styleWithFillColor:[[UIColor purpleColor] colorWithAlphaComponent:0.5] strokeColor:[UIColor purpleColor] strokeWidth:3.0];\n\n// Apply the style to a single boundary.\nlayer.style = ^(GMSPlaceFeature *feature) {\n return [feature.placeID isEqual:@\"ChIJ0zQtYiWsVHkRk8lRoB1RNPo\"/* Hana, HI */] ? style : nil;\n};\n```"]]