-
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
Add a global "padding" option #4268
Comments
A Another important aspect is that it becomes all the more important to provide a method that returns the current CameraOptions, accepting a padding option. The developer should be able to call something like |
I don't think it makes sense to have a global
|
It's been a while since I brought up this issue referring then to it as 'shifted center'. I am now trying to establish what current status is. I note that in the meantime padding is added, but am I right that then you would have to set all flyTo etc kind of operation explicitly with offset to the 'shifted center', whereas this issue would have this setup instantly for all kinds of zoom operations? So maybe just wait a little till this is implemented? |
@musicformellons yes, that's right. I still think a global map padding option makes more sense than individual |
I would also prefer global map padding as this would also apply to box zooming. |
Thanks @mourner for noticing this duplicate. Copying my text in from that issue since I think it covers another use case, with much the same proposed solution: Currently a map's A concrete example:
Proposed solution: allow some kind of |
Hey, Updates on this? |
Since you use the thumbs-up to track the priority of these items, and since the parent issue from which this item was split had 26 thumbs up plus the 9 above I hope that makes for a total of 35 thumbs-up! ;) |
Any update on this ? What I'm trying to build is a "virtual center" for my map, which covers every animations / fitBounds / zoom etc. The point is we have a semi-transparent control-panel overlay, and trying to distinguish the "visible zone" of the "useful zone" on the canvas. Thus, we're trying to make every (programmatic) interractions respecting a padding corresponding to the "useful zone" |
It is now 2 years, 8 months, 17 days since the original issue was raised: #1740 Any hope or updates for those of us holding out for this feature? #3890 (padding options for fit bounds) doesn't help for this use-case because it assumes a bearing of 0º and a pitch of 90º. i.e. it is absolute and not relative to already existing transformations of the map. A request: Is there please some way to keep track of thumbs-ups from closed issues when splitting into new issues. The issues priority list doesn't take into account that the original issue also has 32 thumbs-up and 9 hearts, plus the 19 (albeit some duplicates no-doubt) from this issue. i.e. this issue is arguably the highest priority feature request yet this is not reflected. |
Team, would be great to have an update here. Is it even on the road map for the nearby future? |
Since this feature looks unlikely to be implemented, is there any workaround on that? |
I have a map where I have the UI covering 1/3 to 1/2 of the screen. I started out by having padding to always offset the center position, but it was a pain as I had so much logic revolving around center point, I found the performance was much better by just resizing the map and not drawing it under the UI. But if your UI doesn't allow that my previous solution might work. What's your specific needs when it comes to interaction between UI and map? |
https://codepen.io/bruno-vaz/full/vQLBGX/ The indigo div is the map, the main interface could be scrolled to see more or less of the map, in the application I'll have code that snaps the scroll position to one of 3 options:
So I would have 2 center settings, one for the "fullscreen" map and another for the "halfscreen" map. |
I work in React, and I just stored center in state, along with the ui dimensions, and then always fed it padding according to the state of the UI. No matter if user or code initiated a move. That said, I felt it got complicated, if you don't have any transparency on the UI you might as well just resize the map, or at least try that function and see how it performs. |
@bruno-vaz So you don't have 'ordinary zoom in / out' (by pinching or scrollmouse or via the + - widget) then? This can easily be forgotten, but it is also weird when you zoom and the parts of the map you are interested in 'walk out of your screen' (so especially on zoom in). As a user you always assume that the center of you map 'stays' in view. |
@khollund It got complicated, but it worked fine? If so, I might try your approach. |
I would say it depends on the complexity you already have around it. Basically everything that panned to a polygon or centered to a point by code I would pipe through a set bounds function that added padding and then I would set bounds instead of setCenter. In broad terms. |
Only pinch and scroll to zoom, but then it zooms where the user pinches/scrolls so it won't be a problem. |
I was looking for a 'proper' solution which led me here, but I have a CSS hack / workaround. See attached screenshot in case it's useful to others. This is a fullscreen PWA. Note the CSS on the #map div. Set 'top' to 0 and 'bottom' to -200px. This moves the centre point to 200px below the centre of the screen because you've basically drawing an unused extra 200px of map at the bottom that's never seen by the user. It's a waste of cpu (rendering 200px of unseen map) but means no other coding necessary because all rotate, zoom, etc. functions now focus around this lower center-point. My app does this to simulate the standard "follow me" kind of view of a sat-nav where the centre point is lower down the map. If your interface is sometimes over the bottom of the screen, I suspect you'll want to have top:-200px, bottom:0 or similar (to move the center point up the screen). |
I used to have an offset center and had the map under the UI, but I ended up rewriting it to have the map drawn only where it is visible, and then I resize the map on window.resize etc. Seems to work better for me tbh. |
You can use the turf distance function (http://turfjs.org/docs/#destination) to calculate a virtual new center. const point = cameraOptions.center.toArray(); This sets the new center 100 meters in front of your regular center, so the marker gets closer to the viewer. PS: the only thing that has to be done is to take the zoom into the distance calculation. Did not find a proper way to do so.... |
Addressed by #8638 |
We allow users to pass an
around
option to some camera methods.This ticket proposes a
around
option be added toMap
as a constructor option, getter, and setter.This option would specify a default value for
around
on all camera mutations so thataround
for implicit camera mutation, such as those triggered by use of theNavigationControl
around
value for all camera mutationsOpen Questions
around
make sense semantically in this case? Many users will be using this feature because they have a translucent element over the map. In that use case,padding
is a more intuitive option.around
andcenter
? Can we find a naming convention that eliminates that confusion?The text was updated successfully, but these errors were encountered: