Repository navigation
add initial bounds as map constructor option #1970 - #5518
Conversation
| options.center = tr.unproject(nw.add(se).div(2)); | ||
| options.zoom = Math.min(tr.scaleZoom(tr.scale * Math.min(scaleX, scaleY)), options.maxZoom); | ||
| } | ||
|
|
There was a problem hiding this comment.
Can we reuse the code from fitBounds somehow and avoid copying it?
There was a problem hiding this comment.
Actually, we can try to use fitBounds(bounds, { duration: 0 }) instead of manually reproducing fitBounds logic, but we have to resize the map before.
this.resize();
this.fitBounds(options.bounds, { duration: 0 });
Unfortunately, the problem with the test is still there.
There was a problem hiding this comment.
I have updated the PR using fitBounds
|
|
||
| t.end(); | ||
| }); | ||
|
|
There was a problem hiding this comment.
But the same steps reproduced in test somehow outcomes with different zoom level
The zoom level depends on the size of the map container.
There was a problem hiding this comment.
I took https://github.com/mapbox/mapbox-gl-js/blob/master/test/unit/ui/camera.test.js#L1355 as an example. And it works fine with the zoom level.
5f83282 to
fed794d
Compare
|
@stepankuzmin let's get this shipped. Can you rebase on master and fix the build? |
|
Oh, well, It seems that I mixed up rebasing. Should I create separate PR on top of the current master branch? |
|
@stepankuzmin I think you can reset the PR branch to the master ( |
|
Thanks for help, @mourner! It seems that tests are passing now. |
| pitch: options.pitch | ||
| }); | ||
| if (options.bounds) { | ||
| this.resize(); |
There was a problem hiding this comment.
Why do we need the resize here?
There was a problem hiding this comment.
Without resize, Transform's pixelMatrixInverse is undefined here:
mapbox-gl-js/src/geo/transform.js
Line 372 in 11d09c7
Maybe we can move following resize call before condition?
Line 379 in 11d09c7
There was a problem hiding this comment.
@stepankuzmin yes, let's do that — seems to be more logical.
|
Hmm, now the query tests fail for some reason :( |
|
That's strange, because |
|
@stepankuzmin maybe let's rebase on top of the current master and revisit this? |
|
I've rebased on top of the current master branch, but the tests are still failing. And the problem is that I can't reproduce it locally — all 14 376 tests are passing. |
|
@stepankuzmin the unit tests are passing; it's the query and render tests that fail. I can reproduce failures locally, e.g. by running |
|
Can we pick this back up? I'd love to close out as many PRs as possible. I was just testing it out and rebasing it against I did notice after rebasing that I had to change the expected zoom value in the test from |
|
Hey @mourner and @ryanhamley! Sorry for the late reply, I've updated the PR according to the last comment — moved resize back to conditional and set expected zoom value in the test to |
|
@mourner Just stumbled upon this new feature which would be quite useful to us. When is the next release planned for this to be included as it's not in the current latest 0.50.0? Thank you! |
|
@GeovationMax This will be included in v0.51.0. The beta will be released next week and the final version will be released the following week, around November 7th. |
|
I am using the latest version js and css v0.51.0. Can someone please help me understand how to initialize the map with bounds? Doesn't work for me and I get no errors. It just doesn't seem to work. |
See https://www.mapbox.com/mapbox-gl-js/api/#map there is a map option called |
|
So, I'm misunderstood. How can I set a bunch of LngLat markers than have the map show with them centered in there by default? Instead of setting center property to a Lng,Lat. |
|
Ok thank you, I have created a question here: https://stackoverflow.com/questions/53330202/set-map-bounds-based-on-multiple-marker-lng-lat |
|
This is great, but is missing a way to provide the padding that @mourner would you be open to accepting a PR that adds a Added #7681 |
Complements mapbox#5518 by allowing additional options (notably padding) to be provided for the initial bounds for a map.
Complements mapbox#5518 by allowing additional options (notably padding) to be provided for the initial bounds for a map.
Complements mapbox#5518 by allowing additional options (notably padding) to be provided for the initial bounds for a map.
Complements mapbox#5518 by allowing additional options (notably padding) to be provided for the initial bounds for a map.
Complements mapbox#5518 by allowing additional options (notably padding) to be provided for the initial bounds for a map.
Complements #5518 by allowing additional options (notably padding) to be provided for the initial bounds for a map.
This PR will add initial bounds as map constructor option according to #1970.
I have a problem implementing the test for this case. Then I manually test new functionality using the debug page, I'm getting the expected result. But the same steps reproduced in test somehow outcomes with different zoom level in the result (
1.113instead of2.469). What can cause this?