ui.Map.DrawingTools.onLayerSelect
Zadbaj o dobrą organizację dzięki kolekcji
Zapisuj i kategoryzuj treści zgodnie ze swoimi preferencjami.
Rejestruje wywołanie zwrotne, które jest wywoływane po wybraniu warstwy.
Zwraca identyfikator, który można przekazać do funkcji unlisten(), aby wyrejestrować wywołanie zwrotne.
Wykorzystanie | Zwroty |
---|
DrawingTools.onLayerSelect(callback) | Ciąg znaków |
Argument | Typ | Szczegóły |
---|
to: ui.map.drawingtools | ui.Map.DrawingTools | Instancja ui.Map.DrawingTools. |
callback | Funkcja | Funkcja zwrotna, która ma zostać wywołana po wybraniu kształtu. Funkcja zwrotna otrzymuje 2 parametry: wybraną warstwę GeometryLayer (lub wartość null w przypadku odznaczenia) oraz widżet ui.Map.DrawingTools, z którym powiązany jest detektor zdarzeń. |
O ile nie stwierdzono inaczej, treść tej strony jest objęta licencją Creative Commons – uznanie autorstwa 4.0, a fragmenty kodu są dostępne na licencji Apache 2.0. Szczegółowe informacje na ten temat zawierają zasady dotyczące witryny Google Developers. Java jest zastrzeżonym znakiem towarowym firmy Oracle i jej podmiotów stowarzyszonych.
Ostatnia aktualizacja: 2025-07-26 UTC.
[null,null,["Ostatnia aktualizacja: 2025-07-26 UTC."],[[["\u003cp\u003eRegisters a callback function that is executed when a layer is selected within the DrawingTools.\u003c/p\u003e\n"],["\u003cp\u003eProvides a method, \u003ccode\u003eonLayerSelect\u003c/code\u003e, to register the callback, accepting the callback function as an argument and returning a unique ID.\u003c/p\u003e\n"],["\u003cp\u003eThe callback function receives the selected GeometryLayer (or null if deselected) and the DrawingTools widget as parameters.\u003c/p\u003e\n"],["\u003cp\u003eThe returned ID can be utilized with the \u003ccode\u003eunlisten()\u003c/code\u003e method to unregister the callback when it's no longer needed.\u003c/p\u003e\n"]]],["A callback function is registered to be executed upon layer selection. The `onLayerSelect` method takes a callback as an argument, which receives the selected `GeometryLayer` (or null if deselected) and the `ui.Map.DrawingTools` instance. This method returns a unique string ID, enabling the callback to be unregistered later via the `unlisten()` method. The method's `ui.Map.DrawingTools` instance is implicitly bound to this.\n"],null,["# ui.Map.DrawingTools.onLayerSelect\n\n\u003cbr /\u003e\n\nRegisters a callback that's fired when a layer is selected.\n\n\u003cbr /\u003e\n\nReturns an ID which can be passed to unlisten() to unregister the callback.\n\n| Usage | Returns |\n|----------------------------------------|---------|\n| DrawingTools.onLayerSelect`(callback)` | String |\n\n| Argument | Type | Details |\n|-----------------------------|---------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| this: `ui.map.drawingtools` | ui.Map.DrawingTools | The ui.Map.DrawingTools instance. |\n| `callback` | Function | The callback to fire when a shape is selected. The callback is passed two parameters: the selected GeometryLayer (or null for deselect) and the ui.Map.DrawingTools widget that the event listener is bound to. |"]]