พบกับแผนที่แบบใหม่ใน Google Maps Platform เร็วๆ นี้ การอัปเดตการจัดรูปแบบแผนที่นี้มีชุดสีเริ่มต้นใหม่ รวมถึงการปรับปรุงประสบการณ์และความสามารถในการใช้งานแผนที่ ระบบจะอัปเดตรูปแบบแผนที่ทั้งหมดโดยอัตโนมัติในเดือนมีนาคม 2025 หากต้องการทราบข้อมูลเพิ่มเติมเกี่ยวกับความพร้อมให้บริการและวิธีเลือกใช้ก่อนหน้านี้ โปรดดู
รูปแบบแผนที่ใหม่สำหรับ Google Maps Platform
จัดรูปแบบรูปหลายเหลี่ยมขอบเขต
หากต้องการจัดสไตล์การเติมและเส้นขอบสำหรับรูปหลายเหลี่ยมขอบเขต ให้ใช้การปิดสไตล์ที่รับ GMSPlaceFeature
และแสดงผล GMSFeatureStyle
เพื่อกำหนดแอตทริบิวต์สไตล์ จากนั้นตั้งค่าพร็อพเพอร์ตี้
style เป็น Closure การจัดรูปแบบซึ่งมีตรรกะการจัดรูปแบบ
สำคัญ: แม้ว่าจะไม่จำเป็นสำหรับความสามารถบางอย่าง แต่การจัดรูปแบบข้อมูล Places อาจต้องมีการผสานรวมกับ Places SDK สำหรับ iOS
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 }
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 ;
};
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-01-14 UTC
[null,null,["อัปเดตล่าสุด 2025-01-14 UTC"],[[["This documentation explains how to style the fill and stroke of boundary polygons using a styling closure that takes a `GMSPlaceFeature` and returns a `GMSFeatureStyle`."],["The styling closure defines the style attributes for the polygon, such as fill color, stroke color, and stroke width."],["Styling Places data might require integrating the Places SDK for iOS, although it's not always mandatory."],["Code examples in Swift and Objective-C demonstrate how to apply a purple style to a specific boundary polygon using its place ID."]]],[]]