Le SDK Maps pour iOS vous permet de personnaliser la façon dont les utilisateurs interagissent avec votre carte, en définissant quels composants intégrés de l'interface utilisateur apparaissent sur la carte et quels sont les gestes autorisés.
Commandes de carte
Le SDK Maps pour iOS fournit des commandes d'interface utilisateur intégrées qui sont similaires à celles que l'on trouve dans l'application Google Maps pour iOS. Vous pouvez activer et désactiver la visibilité de ces commandes à l'aide de la classe GMSUISettings.
Les modifications apportées à cette classe se reflètent immédiatement sur la carte.
Boussole
Le SDK Maps pour iOS fournit une image de boussole qui apparaît dans l'angle supérieur droit de la carte, dans certaines circonstances. La boussole apparaît uniquement lorsque la caméra est orientée de sorte que sa direction est différente de zéro. Lorsque l'utilisateur clique sur la boussole, la caméra s'anime pour revenir à une direction de zéro (orientation par défaut) et la boussole disparaît progressivement juste après.
La boussole est désactivée par défaut. Vous pouvez activer le compas en définissant la propriété compassButton de GMSUISettings sur YES. En revanche, vous ne pouvez pas forcer l'affichage permanent de la boussole.
Le bouton "Ma position" apparaît en bas à droite de l'écran uniquement lorsque le bouton "Ma position" est activé. Lorsqu'un utilisateur clique sur le bouton, la caméra s'anime pour se concentrer sur sa position actuelle si celle-ci est connue. Vous pouvez activer le bouton en définissant la propriété myLocationButton de GMSUISettings sur YES.
Swift
mapView.settings.myLocationButton=true
Objective-C
mapView.settings.myLocationButton=YES;
Sélecteur d'étage
Le sélecteur d'étage apparaît en bas à droite de l'écran chaque fois qu'un plan d'intérieur est mis en avant. Lorsqu'au moins deux plans d'intérieur sont visibles, le sélecteur d'étage est associé au bâtiment le plus proche du centre de l'écran. Chaque bâtiment possède un étage par défaut qui est sélectionné la première fois que le sélecteur s'affiche. Vous pouvez choisir un autre étage en le sélectionnant via le sélecteur.
Vous pouvez désactiver le sélecteur d'étage en définissant la propriété indoorPicker de GMSUISettings sur NO.
Swift
mapView.settings.indoorPicker=false
Objective-C
mapView.settings.indoorPicker=NO;
Gestes dans Google Maps
Vous pouvez désactiver les gestes par défaut sur la carte en définissant les propriétés de la classe GMSUISettings, qui est disponible en tant que propriété de GMSMapView.
Les gestes suivants peuvent être activés et désactivés par programmation. Notez que la désactivation du geste ne limite pas l'accès par programmation aux paramètres de la caméra.
scrollGestures : détermine si les gestes de défilement sont activés ou désactivés. Si ces gestes sont activés, les utilisateurs peuvent balayer l'écran afin d'effectuer un panorama avec l'appareil photo.
zoomGestures : contrôle si les gestes de zoom sont activés ou désactivés. Si cette option est activée, les utilisateurs peuvent appuyer deux fois, appuyer avec deux doigts ou pincer l'écran pour zoomer sur la caméra. Notez que le fait d'appuyer deux fois ou de pincer l'écran lorsque scrollGestures est activé peut déplacer la caméra vers le point spécifié.
tiltGestures : contrôle si les gestes d'inclinaison sont activés ou désactivés. Si cette option est activée, les utilisateurs peuvent incliner la caméra en balayant l'écran vers le haut ou vers le bas avec deux doigts.
rotateGestures : contrôle si les gestes de rotation sont activés ou désactivés. Si cette option est activée, les utilisateurs peuvent faire pivoter la caméra à l'aide d'un geste de rotation à deux doigts.
Dans l'exemple ci-dessous, les gestes de panorama et de zoom ont été désactivés.
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
Dernière mise à jour le 2025/09/05 (UTC).
[[["Facile à comprendre","easyToUnderstand","thumb-up"],["J'ai pu résoudre mon problème","solvedMyProblem","thumb-up"],["Autre","otherUp","thumb-up"]],[["Il n'y a pas l'information dont j'ai besoin","missingTheInformationINeed","thumb-down"],["Trop compliqué/Trop d'étapes","tooComplicatedTooManySteps","thumb-down"],["Obsolète","outOfDate","thumb-down"],["Problème de traduction","translationIssue","thumb-down"],["Mauvais exemple/Erreur de code","samplesCodeIssue","thumb-down"],["Autre","otherDown","thumb-down"]],["Dernière mise à jour le 2025/09/05 (UTC)."],[[["\u003cp\u003eThis documentation outlines how to customize user interaction with the Google Maps SDK for iOS, focusing on controlling built-in UI components and map gestures.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers can enable or disable UI controls like the compass, My Location button, and floor picker using the \u003ccode\u003eGMSUISettings\u003c/code\u003e class.\u003c/p\u003e\n"],["\u003cp\u003eMap gestures such as scrolling, zooming, tilting, and rotating can be individually enabled or disabled through properties of the \u003ccode\u003eGMSUISettings\u003c/code\u003e class.\u003c/p\u003e\n"],["\u003cp\u003eDisabling a gesture does not restrict programmatic access to camera settings, only user interaction.\u003c/p\u003e\n"],["\u003cp\u003eThese customizations provide developers with flexibility to tailor the map experience within their iOS applications.\u003c/p\u003e\n"]]],["The Maps SDK for iOS allows customization of user interaction with the map via the `GMSUISettings` class. Built-in UI controls, like the compass, My Location button, and floor picker, can be toggled on or off. The compass is enabled by setting `compassButton` to `YES`, the My Location button with `myLocationButton = YES`, and the floor picker is disabled by `indoorPicker = NO`. Map gestures (scroll, zoom, tilt, rotate) can be enabled or disabled by setting the properties of the same name to `YES` or `NO` respectively.\n"],null,["\u003cbr /\u003e\n\nSelect platform: [Android](/maps/documentation/android-sdk/controls \"View this page for the Android platform docs.\") [iOS](/maps/documentation/ios-sdk/controls \"View this page for the iOS platform docs.\") [JavaScript](/maps/documentation/javascript/controls \"View this page for the JavaScript platform docs.\")\n\n\u003cbr /\u003e\n\nUsing the Maps SDK for iOS, you can customize the way in which users\ninteract with your map, by determining which of the built in UI components\nappear on the map and which gestures are allowed.\n\nMap controls\n\nThe Maps SDK for iOS provides some built-in UI controls that are\nsimilar to those found in the Google Maps for iOS application. You can\ntoggle the visibility of these controls using the `GMSUISettings` class.\nChanges made on this class are immediately reflected on the map.\n| **Note:** Each control has a predetermined position relative to the edge of the map. You can move the controls away from the edges by [padding](/maps/documentation/ios-sdk/map#map_padding) the map.\n\nCompass \n\nThe Maps SDK for iOS provides a compass graphic which appears in the\ntop right corner of the map under certain circumstances. The compass will only\nappear when the camera is oriented such that it has a non-zero bearing. When the\nuser clicks on the compass, the camera animates back to a position with bearing\nof zero (the default orientation) and the compass fades away shortly afterwards.\n\nThe compass is disabled by default. You can enable the compass by setting the\n`compassButton` property of `GMSUISettings` to `YES`. However, you cannot\nforce the compass to always be shown.\n\n\nSwift \n\n```swift\nlet camera = GMSCameraPosition(latitude: 37.757815, longitude: -122.50764, zoom: 12)\nlet mapView = GMSMapView(frame: .zero, camera: camera)\nmapView.settings.compassButton = true\n \n```\n\nObjective-C \n\n```objective-c\nGMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:37.757815\n longitude:-122.50764\n zoom:12];\nGMSMapView *mapView = [GMSMapView mapWithFrame:CGRectZero camera:camera];\nmapView.settings.compassButton = YES;\n \n```\n\n\u003cbr /\u003e\n\nMy Location button \n\nThe My Location button appears in the bottom right corner of the screen *only*\nwhen the My Location button is enabled. When a user clicks the button, the\ncamera animates to focus on the user's current location if the user's location\nis known. You can enable the button by setting the\n`myLocationButton` property of `GMSUISettings` to `YES`.\n\n\nSwift \n\n```swift\nmapView.settings.myLocationButton = true\n \n```\n\nObjective-C \n\n```objective-c\nmapView.settings.myLocationButton = YES;\n \n```\n\n\u003cbr /\u003e\n\nFloor picker \n\nThe floor picker control appears near the bottom right of the screen whenever an\nindoor map is featured prominently. When two or more indoor maps are visible the\nfloor picker relates to the building nearest to the center of the screen. Each\nbuilding has a default floor which is selected when the picker is first\ndisplayed. You can choose a different floor by selecting it from the picker.\n\nYou can disable the floor picker control by setting the `indoorPicker` property\nof `GMSUISettings` to `NO`.\n\n\nSwift \n\n```swift\nmapView.settings.indoorPicker = false\n \n```\n\nObjective-C \n\n```objective-c\nmapView.settings.indoorPicker = NO;\n \n```\n\n\u003cbr /\u003e\n\nMap gestures\n\nYou can disable the default gestures on the map by setting properties of the\n`GMSUISettings` class, which is available as a property of the `GMSMapView`.\nThe following gestures can be enabled and disabled programmatically. Note that\ndisabling the gesture won't limit programmatic access to the camera\nsettings.\n\n- `scrollGestures` --- controls whether scroll gestures are enabled or disabled. If enabled, users may swipe to pan the camera.\n- `zoomGestures` --- controls whether zoom gestures are enabled or disabled. If enabled, users may double tap, two-finger tap, or pinch to zoom the camera. Note that double tapping or pinching when `scrollGestures` are enabled may pan the camera to the specified point.\n- `tiltGestures` --- controls whether tilt gestures are enabled or disabled. If enabled, users may use a two-finger vertical down or up swipe to tilt the camera.\n- `rotateGestures` --- controls whether rotate gestures are enabled or disabled. If enabled, users may use a two-finger rotate gesture to rotate the camera.\n\nIn the example below, both pan and zoom gestures have been disabled.\n\n\nSwift \n\n```swift\noverride func loadView() {\n let camera = GMSCameraPosition.camera(\n withLatitude: 1.285,\n longitude: 103.848,\n zoom: 12\n )\n\n let mapView = GMSMapView.map(withFrame: .zero, camera: camera)\n mapView.settings.scrollGestures = false\n mapView.settings.zoomGestures = false\n self.view = mapView\n}\n \n```\n\nObjective-C \n\n```objective-c\n- (void)loadView {\n GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:1.285\n longitude:103.848\n zoom:12];\n GMSMapView *mapView = [GMSMapView mapWithFrame:CGRectZero camera:camera];\n mapView.settings.scrollGestures = NO;\n mapView.settings.zoomGestures = NO;\n self.view = mapView;\n}\n \n```\n\n\u003cbr /\u003e"]]