Restez organisé à l'aide des collections
Enregistrez et classez les contenus selon vos préférences.
La caméra vous permet de modifier le point de vue de l'utilisateur sur la carte. Vous pouvez utiliser les modes de caméra pour contrôler le comportement de la vue de la carte pendant la navigation.
Pour définir le mode de la caméra, appelez l'une des méthodes suivantes associées à la caméra :
Suivre ma position (GoogleMap.followMyLocation) : mode caméra par défaut pour la navigation. Ce mode définit la caméra sur l'appareil ou le véhicule.
Pendant la navigation, la caméra est automatiquement orientée dans le sens de déplacement.
Épinglé à un emplacement (GoogleMap.animateCamera et GoogleMap.moveCamera) : fixe la caméra à un emplacement spécifique. Lorsque vous utilisez ce mode, vous pouvez définir l'emplacement de la caméra ainsi que d'autres propriétés de la caméra, comme la direction, l'inclinaison, le zoom, etc. Lorsque cette vue est sélectionnée et que le navigateur a été initialisé, le bouton Recentrer est visible.
Afficher un aperçu de l'itinéraire (NavigationView.showRouteOverview ou SupportNavigationFragment.showRouteOverview) : affiche un aperçu de l'itinéraire restant (jusqu'aux 45 prochaines minutes de trajet), en effectuant un panoramique et un zoom si nécessaire pour adapter l'itinéraire à la vue de la carte. Lorsque cette vue est sélectionnée, le bouton Recentrer est visible.
Si vous cliquez sur le bouton Recentrer, la caméra passe en mode followMyLocation.
Mode "Suivre ma position"
Le paramètre de caméra le plus courant consiste à définir la caméra sur l'appareil ou le véhicule, en affichant sa position actuelle au cours du trajet. Dans ce mode, vous pouvez afficher l'itinéraire avec la voiture toujours orientée vers le haut de l'écran avec une perspective inclinée (CameraPerspective.TILTED), ou vous pouvez voir la voiture se déplacer avec le nord (CameraPerspective.TOP_DOWN_NORTH_UP) ou le cap (CameraPerspective.TOP_DOWN_HEADING_UP)) toujours en haut de l'écran.
Le fragment de code suivant utilise la perspective TILTED :
// Set the camera to follow the device (vehicle):mNavFragment.getMapAsync(googleMap->googleMap.followMyLocation(CameraPerspective.TILTED))
Épinglé au mode Lieu
Le mode Pinned vous offre le plus de contrôle sur la caméra. Dans ce mode, vous placez la caméra à un endroit spécifique, vous lui attribuez un cap pour orienter la vue, vous modifiez l'inclinaison pour définir l'angle de vue et vous définissez le niveau de zoom de la caméra.
L'extrait de code suivant illustre quelques-unes des méthodes les plus utilisées pour déplacer la caméra.
privatestaticfinalLatLngSYDNEY=newLatLng(-33.88,151.21);privatestaticfinalLatLngMOUNTAIN_VIEW=newLatLng(37.4,-122.1);privateGoogleMapmap;...// Obtain the map from a SupportNavigationFragment or NavigationView.// Move the camera instantly to Sydney with a zoom of 15.map.moveCamera(CameraUpdateFactory.newLatLngZoom(SYDNEY,15));// Zoom in, animating the camera.map.animateCamera(CameraUpdateFactory.zoomIn());// Zoom out to zoom level 10, animating with a duration of 2 seconds.map.animateCamera(CameraUpdateFactory.zoomTo(10),2000,null);// Construct a CameraPosition focusing on Mountain View and animate the camera to that position.CameraPositioncameraPosition=newCameraPosition.Builder().target(MOUNTAIN_VIEW)// Sets the center of the map to Mountain View.zoom(17)// Sets the zoom.bearing(90)// Sets the orientation of the camera to east.tilt(30)// Sets the tilt of the camera to 30 degrees.build();// Creates a CameraPosition from the buildermap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
Afficher le mode Aperçu de l'itinéraire
Le paramètre de caméra showRouteOverview affiche l'intégralité du trajet.
Pour les trajets à plusieurs destinations, ce mode affiche la partie de l'itinéraire qui n'a pas encore été parcourue.
// Place the camera to see the remaining route:mNavFragment.showRouteOverview();
Étape suivante
Consultez Personnaliser l'UI de navigation pour découvrir comment personnaliser la façon dont les utilisateurs interagissent avec votre carte en déterminant quels composants d'UI intégrés apparaissent sur la carte.
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/04 (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/04 (UTC)."],[[["\u003cp\u003eThe Navigation SDK offers three camera modes: \u003ccode\u003efollowMyLocation\u003c/code\u003e, \u003ccode\u003ePinned to location\u003c/code\u003e, and \u003ccode\u003eshowRouteOverview\u003c/code\u003e to control the user's viewpoint of the map during navigation.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003efollowMyLocation\u003c/code\u003e mode centers the map on the user's location and automatically adjusts during navigation, while \u003ccode\u003ePinned to location\u003c/code\u003e mode fixes the camera at a specific location with customizable properties.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eshowRouteOverview\u003c/code\u003e mode displays the entire route or remaining route, adjusting the view to fit the route on the screen.\u003c/p\u003e\n"],["\u003cp\u003eYou can customize the camera's perspective, zoom level, bearing, and tilt to enhance the user experience.\u003c/p\u003e\n"],["\u003cp\u003eHigh detail setting, when enabled, displays 2-D building outlines when the zoom level is 19 or higher, which can be further customized using \u003ccode\u003eFollowMyLocationOptions\u003c/code\u003e.\u003c/p\u003e\n"]]],[],null,["# Adjust the camera\n\nThe camera allows you to change the user's viewpoint of the map. You can\nuse camera modes to control the behavior of the map view during navigation.\nTo set the camera mode, call one of the following methods associated\nwith the camera:\n\n- Follow my location (`GoogleMap.followMyLocation`) --- The default camera\n mode for navigation. This mode sets the camera to the device or vehicle.\n During navigation, the camera automatically faces the direction of travel.\n\n- Pinned to location (`GoogleMap.animateCamera` and `GoogleMap.moveCamera`)\n --- Fixes the camera at a specific location. When using this mode, you can\n set the camera location along with other camera properties like bearing, tilt,\n zoom, etc. When this view is selected and the Navigator has been initialized,\n the **Re-center** button is visible.\n\n- Show route overview (`NavigationView.showRouteOverview` or\n `SupportNavigationFragment.showRouteOverview`) --- Displays an overview\n of the remaining route (up to the next 45 minutes of driving time), panning and zooming as needed to fit the route\n into the map view. When this view is selected, the **Re-center** button\n is visible.\n\nClicking the **Re-center** button sets the camera to `followMyLocation` mode.\n\nFollow my location mode\n-----------------------\n\nThe most common camera setting is to have the camera set to the\ndevice or vehicle, showing its current position within the journey. In\nthis camera mode, you can view the route with the car always headed up\nthe screen with an angled perspective (`CameraPerspective.TILTED`), or\nyou can see the car traveling with north (`CameraPerspective.TOP_DOWN_NORTH_UP`)\nor with heading (`CameraPerspective.TOP_DOWN_HEADING_UP)` always at the top of\nthe screen.\n\nThe following code fragment uses the `TILTED` perspective: \n\n // Set the camera to follow the device (vehicle):\n mNavFragment.getMapAsync(googleMap -\u003e googleMap.followMyLocation(CameraPerspective.TILTED))\n\nPinned to location mode\n-----------------------\n\nThe `Pinned` mode provides you with the most control of the\ncamera. In this mode, you place the camera in a specific location, assign\na bearing to orient the camera view, change the tilt to set the viewing angle, and\nset the camera's zoom level.\n\nThe following code snippet demonstrates some of the common ways to move the\ncamera. \n\n private static final LatLng SYDNEY = new LatLng(-33.88, 151.21);\n private static final LatLng MOUNTAIN_VIEW = new LatLng(37.4, -122.1);\n\n private GoogleMap map;\n ... // Obtain the map from a SupportNavigationFragment or NavigationView.\n\n // Move the camera instantly to Sydney with a zoom of 15.\n map.moveCamera(CameraUpdateFactory.newLatLngZoom(SYDNEY, 15));\n\n // Zoom in, animating the camera.\n map.animateCamera(CameraUpdateFactory.zoomIn());\n\n // Zoom out to zoom level 10, animating with a duration of 2 seconds.\n map.animateCamera(CameraUpdateFactory.zoomTo(10), 2000, null);\n\n // Construct a CameraPosition focusing on Mountain View and animate the camera to that position.\n CameraPosition cameraPosition = new CameraPosition.Builder()\n .target(MOUNTAIN_VIEW) // Sets the center of the map to Mountain View\n .zoom(17) // Sets the zoom\n .bearing(90) // Sets the orientation of the camera to east\n .tilt(30) // Sets the tilt of the camera to 30 degrees\n .build(); // Creates a CameraPosition from the builder\n map.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));\n\nShow route overview mode\n------------------------\n\nThe `showRouteOverview` camera setting displays the entire journey.\nFor multiple-destination journeys, this mode displays the untraveled\nportion of the route. \n\n // Place the camera to see the remaining route:\n mNavFragment.showRouteOverview();\n\nNext step\n---------\n\nSee [Customize the Navigation UI](/maps/documentation/navigation/android-sdk/controls)\nto learn how to customize the way in which users interact with your map\nby determining which of the built-in UI components appear on the map."]]