Maps SDK for iOS 3.10.0 Beta 版

Maps SDK for iOS 3.10.0 Beta 版推出了以下新功能,您可以試試:

  • 雲端式地圖樣式/地圖自訂功能
  • 自訂折線:戳記折線

雲端式地圖樣式設定/地圖自訂功能 (Beta 版)

您現在可以建立自訂樣式,並使用符記將樣式指派給應用程式和網站中的地圖。相關詳情請參閱這篇簡介 iOS 地圖自訂功能一文。

自訂折線:戳記折線

您可以使用 GMSTextureStyle,將折線的外觀設為重複的點陣圖紋理。圖片會完全覆蓋線條,但是會在端點和端點周圍截斷。

如要建立戳記折線,請建立 GMSTextureStyleGMSStampStyle。 接著,使用 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;
      

執行範例

GitHub 上的 Google 範例存放區提供範例應用程式,示範 iOS 3.10.0 Beta 版的 Navigation SDK 使用方式。