Projected coordinates are not being unprojected back to the same coordinates
unproject() seems to be returning the incorrect coordinates when point is off screen. This issue becomes more apparent on higher zoom levels. The objective is to draw multiple lines between two points using only two sets of coordinates.
In the example below, I've removed all calculations I was performing on each zoom event and only projecting then unprojecting the same coordinates.
mapbox-gl-js version: version: v2.6.0
browser: Tested on Chrome, Safari, Firefox
Steps to Trigger Behavior
- Draw a line between using two sets of coordinates by adding a source with a line layer
- On zoom event, project the each coordinate then unproject each coordinate and update source with resulting coordinates.
Expected Behavior
Zoomed out

Zoomed in at level 16

Actual Behavior
Zoomed in at level 16

I manually added the line at zoom 16 then zoomed out to see the resulting line:

@Diegodlt Can you share a minimal example of what you're seeing? I can only partially replicate it when the line is really far offscreen and no longer visible and the changes are very minimal.
@ryanhamley Sure thing.

Can you provide a code example using a site like JSFiddle or CodePen?
I was trying to replicate the issue on JS Bin. The issue doesn’t happen when the same source id is used to draw the same line. It only seems to happen when the source id is generated on each zoom event.
In the code example I have both dynamically generated source ids (green line) and a static source id (red line). In the GIF I provided in the original example, I'm removing the sources and layers on every zoom event. I'm not doing that in the code example to show the lines being drawn at each zoom level.
https://jsbin.com/napazequyu/edit?html,console,output

This example is great @Diegodlt Thanks so much for providing that
This seems to be a regression introduced in v2.0.0.