Get new center and radius for Circle component on Google Map #2879
-
I'm using So how can I get the new value of |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
After reading again the documentation and a lot of tries, I found the solution to get the new values of location and radius from the new position/size of the Circle. I added I found those values and here was the code. const [ circle, setCircle ] = useState(null)
<Circle
center={mapCenter}
radius={radius}
options={circleOptions}
onLoad={(circle) => setCircle(circle)}
onUnmount={(circle) => setCircle(null)}
onCenterChanged={() => circle && setCircleCenter({ lat: circle['center'].lat(), lng: circle['center'].lng() })}
onRadiusChanged={() => circle && setRadius(parseInt(circle['radius']))}
/> |
Beta Was this translation helpful? Give feedback.
After reading again the documentation and a lot of tries, I found the solution to get the new values of location and radius from the new position/size of the Circle.
I added
onLoad
prop and set the circle using it.Then I printed the
circle
state value to check whether there were lat, lng, and radius values or not.I found those values and here was the code.