mapbox / mapbox/mapbox-gl-js

MapMouseEvent misses lngLat property on drag

Open
#8,011 2 comments 0 reactions 1 assignee View on GitHub

@mourner is already working on this.

Since Jul 9, 2021.

bug :lady_beetle: docs :scroll:
Dominant language
TypeScript
Stars
12.4k
Forks
2.4k
PR merge metrics
No merged PRs in 30d

Description

**browser**:
Chrome@72.0

### Steps to Trigger Behavior

1.Listento drag Event
2. Try access Latlng property from MapMouseEvent
3.

### Link to Demonstration

[demonstration](https://jsbin.com/tizemukuna/edit?html,console,output )
```

Display a map

body { margin:0; padding:0; }
#map { position:absolute; top:0; bottom:0; width:100%; }


mapboxgl.accessToken = 'pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejY4M29iazA2Z2gycXA4N2pmbDZmangifQ.-g_vE53SD2WrJ6tFX7QHmA';
var map = new mapboxgl.Map({
container: 'map', // container id
style: 'mapbox://styles/mapbox/streets-v9', // stylesheet location
center: [-74.50, 40], // starting position [lng, lat]
zoom: 9 // starting zoom
});

map.on('drag', function(e){
console.log(e)
});

```

### Expected Behavior
According to the [docs](https://docs.mapbox.com/mapbox-gl-js/api/#mapmouseevent)
the MapMouseEvent Object should contain following properties:
- type
- target
- originalEvent
- point
- lngLat
- preventDefault()
- defaultPrevented
### Actual Behavior
- type
- originalEvent
- target
**accessing lngLat would result in** `undefined`

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.