-
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 initial bounds as map constructor option #1970 #5518
Changes from all commits
a3e46e4
71400b2
6513cd1
670b6c1
cbb825d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,6 +53,20 @@ test('Map', (t) => { | |
t.end(); | ||
}); | ||
|
||
t.test('initial bounds in constructor options', (t) => { | ||
const container = window.document.createElement('div'); | ||
Object.defineProperty(container, 'offsetWidth', {value: 512}); | ||
Object.defineProperty(container, 'offsetHeight', {value: 512}); | ||
|
||
const bounds = [[-133, 16], [-68, 50]]; | ||
const map = createMap(t, {container, bounds}); | ||
|
||
t.deepEqual(fixedLngLat(map.getCenter(), 4), { lng: -100.5, lat: 34.7171 }); | ||
t.equal(fixedNum(map.getZoom(), 3), 2.113); | ||
|
||
t.end(); | ||
}); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The zoom level depends on the size of the map container. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 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. |
||
t.test('disables handlers', (t) => { | ||
t.test('disables all handlers', (t) => { | ||
const map = createMap(t, {interactive: false}); | ||
|
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.
Why do we need the
resize
here?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.
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?
mapbox-gl-js/src/ui/map.js
Line 379 in 11d09c7
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.
@stepankuzmin yes, let's do that — seems to be more logical.
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.
Done!