Map.onChangeCenter
Restez organisé à l'aide des collections
Enregistrez et classez les contenus selon vos préférences.
Enregistre un rappel qui est déclenché lorsque le centre de la carte change. Cet événement est déclenché lors d'un panoramique ou lorsque le centre de la carte est modifié de manière programmatique.
Renvoie un ID qui peut être transmis à unlisten() pour annuler l'enregistrement du rappel.
Utilisation | Renvoie |
---|
Map.onChangeCenter(callback) | Chaîne |
Argument | Type | Détails |
---|
callback | Fonction | Rappel à déclencher lorsque le centre de la carte change. Le rappel reçoit deux paramètres : un objet contenant les coordonnées du nouveau centre (avec les clés "lon" et "lat") et le widget de carte lui-même. |
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/07/26 (UTC).
[null,null,["Dernière mise à jour le 2025/07/26 (UTC)."],[[["\u003cp\u003eThe \u003ccode\u003eonChangeCenter\u003c/code\u003e function registers a callback that is triggered when the map's center is changed, either through panning or programmatically.\u003c/p\u003e\n"],["\u003cp\u003eThis function returns a unique ID that can be used with \u003ccode\u003eunlisten()\u003c/code\u003e to remove the registered callback.\u003c/p\u003e\n"],["\u003cp\u003eThe provided callback function receives the new center coordinates (longitude and latitude) and the map widget as arguments.\u003c/p\u003e\n"]]],["Registers a callback function triggered when the map's center changes, either through panning or programmatic modification. The `onChangeCenter` method takes a callback as an argument, providing it with the new center's coordinates (lon and lat) and the map widget. It returns a unique string ID, used to unregister the callback later. The provided callback function is executed each time the map center shifts.\n"],null,["# Map.onChangeCenter\n\n\u003cbr /\u003e\n\nRegisters a callback that's fired when the map center changes. This is fired during pan or when the map's center is changed programmatically.\n\n\u003cbr /\u003e\n\nReturns an ID which can be passed to unlisten() to unregister the callback.\n\n| Usage | Returns |\n|--------------------------------|---------|\n| `Map.onChangeCenter(callback)` | String |\n\n| Argument | Type | Details |\n|------------|----------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `callback` | Function | The callback to fire when the map center changes. The callback is passed two parameters: an object containing the coordinates of the new center (with keys lon and lat) and the map widget itself. |"]]