-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
move markers to the best world for the current view #4452
move markers to the best world for the current view #4452
Conversation
133dd6b
to
fdd3f18
Compare
src/util/util.js
Outdated
@@ -4,6 +4,7 @@ | |||
const UnitBezier = require('@mapbox/unitbezier'); | |||
const Coordinate = require('../geo/coordinate'); | |||
const Point = require('point-geometry'); | |||
const LngLat = require('../geo/lng_lat'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This creates a circular dependency between util/util.js and geo/lng_lat.js (which uses util.wrap). Which seems to be causing an issue. Investigating...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've removed the circular dependency by moving the bestWorld
function out of util/util.
Alternatively, instead of a separate util file, we could add a |
Tagging @mourner for review on this one as he's the most familiar with this part of the code & similar code in Leaflet. |
4a927b2
to
1a16a70
Compare
@mourner Agreed, it feels much cleaner and better style this way. I've made the change and squashed commits. |
I wanted to add a unit test, but it it didn't seem very easy as I'd need to check the DOM Element CSS transform. |
1a16a70
to
d538b07
Compare
d538b07
to
c75bca9
Compare
10b5a7f
to
db5b218
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Launch Checklist
DOM Elements like Markers and Popups are only drawn in world 0. However when you're close to the anti-meridian, DOM Elements which should appear might not, and in some cases it makes sense to draw the DOM elements in world -1 and 1.
This aims to address #3770. However until #2071 is fixed, this PR only addresses issues when the view is in world 0.
public LngLat.wrapToWorld(center) added JS doc.
I did some manual testing of this, with both a marker and popup around long 170 and at long -170, and it works well for world -1, 0 and 1, so long as the camera always wraps to world 0 this is enough.
When zoomed out the marker/popup will jump which might be a poor UX, but I think it's okay and probably better than the alternative of it disappearing off the view.