terriajs
terriajs copied to clipboard
Refactor zoom for Cesium and Leaflet maps.
What this PR does
Fixes https://github.com/TerriaJS/terriajs/issues/6761
Changes:
- Refactor zoom code path by moving the implementation of zoom behaviour for Cesium and Leaflet maps to Cesium/Zooming.ts and Leaflet/Zooming.ts. We could use a similar pattern to refactor picking code path by separating it to
Map/Leaflet/Picking.ts
andMap/Cesium/Picking.ts
. - Separate code for 3D/2D zoom view computation from the actual zooming mechanism. We now have compute3dZoomView and compute2dZoomView functions that computes the zoom views for different target types. This makes it easier to understand and also improves extensibility without touching other parts of the code.
- Improved zooming to clamped DataSource entities: https://github.com/TerriaJS/terriajs/blob/0ba6212b0f5ffce40c8a1e85edd9272316b836f8/lib/Map/Cesium/compute3dZoomView.ts#L239-L250 This replicates a similar change to the Cesium Viewer. And here is a before and after example. See how when zooming to the Ducky, in the before example it is nowhere to be seen.
- Add option to zoom to an array of
MappableMixin.Instance
types. - More spec coverage
Test me
- Open this CI link and randomly test different types of items to see if they work as expected
Checklist
- [x] There are unit tests to verify my changes are correct or unit tests aren't applicable (if so, write quick reason why unit tests don't exist)
- [ ] I've updated relevant documentation in
doc/
. - [x] I've updated CHANGES.md with what I changed.
- [x] I've provided instructions in the PR description on how to test this PR.