Maps SDK for iOS 3.10.0 Beta 版推出下列新功能,歡迎您試用:
- 雲端式地圖樣式設定/地圖自訂
- 折線自訂功能:戳記折線
雲端式地圖樣式設定/地圖自訂功能 (Beta 版)
您現在可以建立自訂樣式,並使用符記將其指派給應用程式和網站中的地圖。詳情請參閱「iOS 地圖自訂功能總覽」。
折線自訂功能:戳記折線
您可以使用 GMSTextureStyle
,將折線的外觀設為重複的點陣圖紋理。圖片會完全覆蓋線條,但會在端點和頂點附近截斷。
如要建立戳記折線,請建立 GMSTextureStyle
的 GMSStampStyle
。接著,使用 stampStyle
在形狀選項物件上設定這個屬性,如下所示:
Swift
let path = GMSMutablePath() path.addLatitude(-37.81319, longitude: 144.96298) path.addLatitude(-31.95285, longitude: 115.85734) let polyline = GMSPolyline(path: path) let redWithStamp = GMSStrokeStyle.solidColor(.red) let image = UIImage(named: "imageFromBundleOrAsset")! // Image could be from anywhere redWithStamp.stampStyle = GMSTextureStyle(image: image) let span = GMSStyleSpan(style: redWithStamp) polyline.spans = [span] polyline.map = mapView
Objective-C
GMSMutablePath *path = [GMSMutablePath path]; [path addLatitude:-37.81319 longitude:144.96298]; [path addLatitude:-31.95285 longitude:115.85734]; GMSPolyline *polyline = [GMSPolyline polylineWithPath:path]; GMSStrokeStyle *redWithStamp = [GMSStrokeStyle solidColor:[UIColor redColor]]; UIImage *image = [UIImage imageNamed:@"imageFromBundleOrAsset"]; // Image could be from anywhere redWithStamp.stampStyle = [GMSTextureStyle textureStyleWithImage:image]; GMSStyleSpan *span = [GMSStyleSpan spanWithStyle:redWithStamp]; polyline.spans = @[span]; polyline.map = mapView;