You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I set to the maximum zoom and to the maximum Pitch, I get the camera height, and then set the same height. At this time, I find the camera height is inconsistent with that of the front and rear cameras.
here is my code:
map.on('click', () => {
const camera = map.getFreeCameraOptions();
const coord = new mapboxgl.MercatorCoordinate(camera._position.x, camera._position.y,
camera._position.z).toLngLat();
const height = new mapboxgl.MercatorCoordinate(camera._position.x, camera._position.y,camera._position.z).toAltitude();
console.log(height);
camera.position = mapboxgl.MercatorCoordinate.fromLngLat([coord.lng, coord.lat],
height);
map.setFreeCameraOptions(camera);
const camera2 = map.getFreeCameraOptions();
const height_new = new mapboxgl.MercatorCoordinate(camera2._position.x, camera2._position.y,camera2._position.z).toAltitude();
console.log(height_new);
})
and then the result:
Solution
I found there was a problem calculating the camera height in this method and distToCenter didn't take camera.forward() into account, so I changed it to this,And it worked:
The text was updated successfully, but these errors were encountered:
mapbox-gl-js version: 2.6.0
browser: Chrome 101.0.4951.54
Question
When I set to the maximum zoom and to the maximum Pitch, I get the camera height, and then set the same height. At this time, I find the camera height is inconsistent with that of the front and rear cameras.
here is my code:
and then the result:
Solution
I found there was a problem calculating the camera height in this method and distToCenter didn't take camera.forward() into account, so I changed it to this,And it worked:
The text was updated successfully, but these errors were encountered: