Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Map onDragStart/onDragEnd not firing #323

Open
joeyfigaro opened this issue Mar 5, 2019 · 4 comments
Open

Map onDragStart/onDragEnd not firing #323

joeyfigaro opened this issue Mar 5, 2019 · 4 comments

Comments

@joeyfigaro
Copy link

version: 9.4.5

Map doesn't seem to support onDragEnd or onDragStart-they aren't being called no matter what I try.

<GoogleMap
          disableDefaultUI={this.props.disableDefaultUI}
          google={this.props.google}
          initialCenter={this.props.initialCenter}
          zoom={this.props.zoom}
          mapTypeId={this.props.google.maps.MapTypeId.HYBRID}
          onClick={this.handleClick}
          onReady={this.handleMapReady}
          onDragEnd={this.handleDragEnd}
          onDragStart={(x, y) => {
            console.log('drag started');
            console.log(x);
            console.log(y);
          }}
/>

onMapReady and onClick both seem to work.

@joeyfigaro
Copy link
Author

For anyone else who ends up here, I'm currently getting around this by setting up event listeners by hand inside my onReady handler:

  handleMapReady = (mapProps, map) => {
    map.addListener('projection_changed', () => {
      Map.instance = map;
      this.setState({ projectionAvailable: true });
    });

    map.addListener('dragend', () => {
      console.log({ lat: map.center.lat(), lng: map.center.lng() });
    });

    console.warn('Map is ready. Setting projection and map type.');

    return map.setMapTypeId && map.setMapTypeId(this.props.type);
  };

@nitelite
Copy link

nitelite commented Apr 9, 2019

The event prop is called onDragend, not onDragEnd, isn't it?

@BorjaL
Copy link
Contributor

BorjaL commented Sep 13, 2019

There is an error in the code. All events are camelized but only taking whitespaces in account.
Events like bounds_changed or zoom_changed have to be called onBounds_changed and onZoom_changed respectively.

@ivan133
Copy link

ivan133 commented Oct 28, 2021

Please see my comment how to use it here #518

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants