Я пытаюсь получить центр круга после перетаскивания его в другое место.Из примера кода, приведенного в документации реагировать на google-map, который они используют для поиска мест:
lifecycle({
componentWillMount() {
const refs = {}
this.setState({
bounds: null,
center: {
lat: 41.9, lng: -87.624
},
markers: [],
onMapMounted: ref => {
refs.map = ref;
},
onBoundsChanged: () => {
this.setState({
bounds: refs.map.getBounds(),
center: refs.map.getCenter(),
})
},
onSearchBoxMounted: ref => {
refs.searchBox = ref;
},
onPlacesChanged: () => {
const places = refs.searchBox.getPlaces();
const bounds = new google.maps.LatLngBounds();
Я также использую его, чтобы получить центр круга:
lifecycle({
componentWillMount () {
const refs = {}
this.setState({
onCircleMounted: ref => {
refs.circle = ref
},
onCenterChanged: () => {
console.log(refs.circle.getCenter())
}
})
}
}),
withScriptjs,
withGoogleMap
)((props) =>
<GoogleMap
defaultZoom={props.zoomValue}
defaultCenter={props.centerFocus}
>
<Circle
key={marker.id}
center={{ lat: marker.lat, lng: marker.lng }}
radius={500}
draggable={true}
editable={true}
ref={props.onCircleMounted}
onCenterChanged={props.onCenterChanged}
/>
)
</GoogleMap>
)
Но я не мог получить это.Он вернул ноль для refs.circle.getCenter()
.
Кто-нибудь знает, что случилось?