Le SDK Maps pour iOS v3.10.0 bêta vous permet d'essayer les nouvelles fonctionnalités suivantes:
- Personnalisation de cartes/styles de cartes basés dans le cloud
- Personnalisation des polylignes: polylignes à motif
Style de carte basé dans le cloud/Personnalisation de Maps (bêta)
Vous pouvez désormais créer des styles personnalisés et utiliser des jetons pour les attribuer aux cartes dans votre applications et sites Web. Pour en savoir plus, consultez les Présentation de la personnalisation de Maps pour iOS
Personnalisation des polylignes: polylignes à motif
Vous pouvez définir l'apparence d'une polyligne sur une texture bitmap répétitive à l'aide de GMSTextureStyle
.
Les images couvrent entièrement la ligne, mais seront tronquées autour des extrémités et des sommets.
Pour créer une polyligne à motif, créez une GMSStampStyle
de GMSTextureStyle
.
Définissez ensuite cette propriété sur l'objet d'options de la forme à l'aide de stampStyle
, comme indiqué ci-dessous:
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;