Y Anderson
Y Anderson

Reputation: 445

react-mapbox-gl accessing lat and lon on click

I am using the react-mapbox-gl library and I am trying to access the lon/lat from the Mapbox Api on triggering an event on the map. I don't really understand where/how to access that info. I know that React has ref for accessing child states but am not sure how that fits in with this library.

The Mapbox Api

an example

    <Map
      style={mapStyle}
      center={mapCenter}
      containerStyle={mapContainerStyle}

      //onDblClick access the lon lat somehow. 

    >
    </Map>

Upvotes: 0

Views: 2149

Answers (1)

Mike Horn
Mike Horn

Reputation: 173

As of [email protected].

<Map onDblClick={handleClick} />

which points to

function handleClick(map, event) {
  var lngLat = event.lngLat;
}

Upvotes: 1

Related Questions