Skip to content

Map ignores zoom/center state changes after user pans map with built-in controls #176

Description

@worldlyjohn

I have a basic map example with a button that on click will change map zoom and center. The button works as intended on load.

However, once you pan the map or use the built-in zoom controls the map stops listening to the state events. When you try the button event after zooming in with controls, the map fails to respond and update.

Anyone else experience this? Some sample code to reproduce is below...

handleClick() {
  this.setState(update(this.state, {
    zoom: 12,
    center: {lat: 44, lng: 13}
  }));
},
render() {
  <div onClick={this.handleClick}>re-zoom</div>
  <GoogleMap
    center={this.state.center}
    zoom={this.state.zoom}>
  </GoogleMap>
}

Activity

  1. istarkov commented on Jun 23, 2016

    @istarkov
    Member

    Please provide jsbin examples https://jsbin.com/roqutisoqu/1/edit?js,console,output
    Otherwise I have no idea how to help with information u provide.

  2. worldlyjohn commented on Jun 28, 2016

    @worldlyjohn
    Author

    ahh, thank you. looks like i need to capture the onChange and set state from those changes as well, otherwise it stops working.

    that said, now im seeing more of the problems with "GoogleMap bounds not eq" referenced by https://github.com/istarkov/google-map-react-examples/issues/8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions