Maps SDK for iOS v3.10.0 ベータ版では、次の新機能をお試しいただけます。
- Cloud ベースのマップのスタイル設定/マップのカスタマイズ
- ポリラインのカスタマイズ: スタンプ型ポリライン
Cloud ベースのマップのスタイル設定とマップのカスタマイズ(ベータ版)
カスタム スタイルを作成し、トークンを使用して アプリとウェブサイトです。詳細については、 iOS 向け Google マップのカスタマイズの概要
ポリラインのカスタマイズ: スタンプ型ポリライン
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;