Maps SDK for iOS v3.10.0 Beta 版引入了以下新功能供您试用:
- 云端地图样式设置/地图自定义
- 多段线自定义:印花多段线
云端地图样式设置/地图自定义(Beta 版)
您现在可以创建自定义样式,并使用令牌将其分配给应用和网站中的地图。如需了解详情,请参阅 iOS 地图自定义概览。
多段线自定义:印花多段线
您可以使用 GMSTextureStyle
将多段线的外观设置为重复显示的位图纹理。图片会完全覆盖线条,但会在端点和顶点周围被截断。
如需创建印刷多段线,请创建 GMSTextureStyle
的 GMSStampStyle
。然后,使用 stampStyle
在形状的 options 对象上设置此属性,如下所示:
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;