File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed
packages/react-google-maps-api/src/components/drawing Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -113,6 +113,8 @@ export interface PolygonProps {
113
113
onLoad ?: ( ( polygon : google . maps . Polygon ) => void ) | undefined
114
114
/** This callback is called when the component unmounts. It is called with the polygon instance. */
115
115
onUnmount ?: ( ( polygon : google . maps . Polygon ) => void ) | undefined
116
+ /** This callback is called when the components editing is finished */
117
+ onEdit ?: ( ( polygon : google . maps . Polygon ) => void ) | undefined
116
118
}
117
119
118
120
function PolygonFunctional ( {
@@ -135,6 +137,7 @@ function PolygonFunctional({
135
137
onDrag,
136
138
onLoad,
137
139
onUnmount,
140
+ onEdit,
138
141
} : PolygonProps ) : null {
139
142
const map = useContext < google . maps . Map | null > ( MapContext )
140
143
@@ -207,6 +210,18 @@ function PolygonFunctional({
207
210
}
208
211
} , [ onDblClick ] )
209
212
213
+ useEffect ( ( ) => {
214
+ if ( instance ) {
215
+ google . maps . event . addListener ( instance . getPath ( ) , 'insert_at' , ( ) => {
216
+ onEdit ?.( instance )
217
+ } ) ;
218
+
219
+ google . maps . event . addListener ( instance . getPath ( ) , 'set_at' , ( ) => {
220
+ onEdit ?.( instance )
221
+ } ) ;
222
+ }
223
+ } , [ instance , onEdit ] )
224
+
210
225
useEffect ( ( ) => {
211
226
if ( instance && onDragEnd ) {
212
227
if ( dragendListener !== null ) {
You can’t perform that action at this time.
0 commit comments