Skip to content

Get new center and radius for Circle component on Google Map #2879

Answered by jaballogian
jaballogian asked this question in Q&A
Discussion options

You must be logged in to vote

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.

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={() 

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by jaballogian
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant