-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Popups automatically wrap with multiple world views #4577
Comments
This is the intended behavior as of #4452. Can you say more about why it's an issue for you? |
The intended behaviour was to ensure that markers and popups (which aren't duplicated) appear in the best world based on the current view, see #4452 (comment). |
@ryanbaumann The intention for the popup wrapping feature was driven for when popups are attached to a geographic location based on data. In your use case you're attaching a popup based on the cursor location. I think the solution here might be to add an option to Popup to differentiate these two use cases, as in the former the wrapping is desired but the latter it is not. Thoughts? |
@andrewharvey Correct - I want to place a popup under the user's mouse pointer (for large polygon features). An option in the popup to control world wrap behaviour would work great. |
Rather than adding another option, could we adjust the wrapping so that it happens only when a move event occurs and the prior location of the popup would now be outside the viewport? |
I think when Markers or Popups are newly positioned programatically, it's reasonable to respect the given initial position (as long it's actually visible on screen). In cases where multiple world copies are visible, and someone desires placement in a particular copy, they can perform the appropriate wrapping/unwrapping before placing the control. |
This would change the behaviour introduced in #4452 which placed Markers more centrally within the viewport by default which avoided placing markers or popups on the viewport edge pixels (which would mean that the marker might be cut off the screen even when there is another place in the viewport it could be at which isn't cut off). I this this is best handled in the core since
But I don't see how both of these use cases can be supported together without a flag to indicate if the placement should be "best" (when not linked to the cursor) or "as provided" (when linked to the cursor). |
The behavior in 2c1615e feels pretty good to me.
If everyone likes this then we can port the behavior to markers as well and hopefully have these positioning nuances finally nailed. |
I tried to test out https://github.com/mapbox/mapbox-gl-js/compare/fix-4577 too ensure I understand the behaviour you're proposing but it doesn't seem this._wrappedLngLat is being set by calling Popup.setLngLat eg. http://jsbin.com/wapuyen/edit?html,output I'm still feeling it's better to place markers and popups centrally within the viewport rather than on the edge pixels where it has a choice as I think this is a better user experience, and it seems this suggestion would miss that? |
Good catch, fixed in 9979710.
For me, it feels better to preserve object constancy when possible, and only move markers and popups when necessary to keep them on screen. And with this solution, if you do desire to wrap them more aggressively, you can add your own event handler that does so using |
I see what you mean. You have my 👍 on this approach. |
mapbox-gl-js version: 0.35.0 (does not exist on 0.34.0)
Steps to Trigger Behavior
Possible culprit
It looks like this commit https://github.com/mapbox/mapbox-gl-js/pull/4555/files may be automatically be wrapping popup.setLngLat()
Expected Behavior
The popup appears at unwrapped world location under the mouse cursor.
Actual Behavior
The popup appears at wrapped world location
The text was updated successfully, but these errors were encountered: