mapbox / mapbox/mapbox-gl-js

Popup is displayed at wrong position when multiple world copies are visible, even when the Popup is attached to the Marker

Open
#9,775 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

**mapbox-gl-js version**: 1.7.0

**browser**: Safari 13.1.1

### Steps to Trigger Behavior

Add Markers with attached `Popup`.
```javascript
// Add markers to the map
features.forEach(function (marker: any, i: number) {

const popUpContent = '

Sample
'

// Create the popup
const popup = new mapboxgl.Popup({ offset: 25 })
.setHTML(popUpContent)
.on('open', function (event: any) {
const activePoi = document.getElementsByClassName(poiId)[0]
activePoi.classList.add('active')
})
.on('close', function () {
const activePoi = document.getElementsByClassName(poiId)[0]
if (activePoi) {
activePoi.classList.remove('active')
}
})

let mark = new mapboxgl.Marker(markerElement)
.setLngLat(marker.geometry.coordinates)
.setPopup(popup)
.addTo(map)
})
```

Zoom out so multiple world copies are visible, and then open popup:

Skjermbilde 2020-06-10 kl  16 26 57

### Link to Demonstration

Example can be seen here: https://www.walleniuswilhelmsen.com/schedules

### Expected Behavior

Popup appears 25px above clicked Marker.

### Actual Behavior

Popup appears at wrong world copy.

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.

Research direction

Start by reproducing the issue at the linked demonstration with multiple world copies visible, using a Marker with an attached Popup and setLngLat coordinates. Trace how Marker, Popup, setPopup, and addTo determine the popup's world copy; done means the popup appears 25px above the clicked Marker in the visible copy.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.