La version 3.10.0 bêta du SDK Maps pour iOS vous permet d'essayer les nouvelles fonctionnalités suivantes:
- Styles de cartes basés dans le cloud/Personnalisation de Maps
- Personnalisation des polylignes: polylignes à motif
Styles de cartes basés 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 à des cartes dans vos applications et sites Web. Pour en savoir plus, consultez la 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 qui se répète en utilisant GMSTextureStyle
.
Les images couvrent l'intégralité de la ligne, mais sont coupées autour des extrémités et des sommets.
Pour créer une polyligne à motif, créez un 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;
Exécuter les exemples
Le dépôt Google Samples sur GitHub inclut des exemples d'applications qui illustrent l'utilisation du SDK Navigation pour iOS v3.10.0 BÊTA.