Repository navigation
Add CameraForBoxAndBearing function - #6894
Conversation
|
Thanks @taraadiseshan, this is awesome! I followed up with some small stuff:
🤔 At first I was thinking that we didn't need to document the change to @mourner you might be able to make suggestions about whether this is a good way to expand the API?
|
mourner
left a comment
There was a problem hiding this comment.
This is great! One thing I'm not sure about though — why would zooming to a box and bearing require only two points? It's enough for the box zoom case because you're zooming to the same bearing as the current one, but seems not enough in the general case — I'd expect it two accept 4 points.
Also nit: box vs bounds terminology inconsistency.
|
Yeah, I think we can figure out better terminology, but I don't have a great idea yet. "bounds" is already taken to mean (aligned-to-north) "LatLngBounds", and I don't think we want to change that. Two points and a bearing do define a specific box -- once you're axis-aligned to the bearing, any two points fit to a single box (right?). If you added more points, that would introduce the possibility of the points not fitting any box (or at least not to the corners). But maybe the right way to talk about this is something that sounds more like "fit these two points (to a box)".
|
|
@taraadiseshan I talked with @mourner about the terminology a bit this morning. His concern (which makes sense to me) is that while it's easy to imagine the box created by two onscreen points in the "box zoom" case, it's hard to imagine the "box" made by two arbitrary points and an arbitrary bearing. So for the "fit to Kenya at bearing X" case, it would be kind of hard to do a good job of choosing the right two points. He proposed something like "fit to a geojson feature" as a more natural API for that. But we don't have to solve that problem now -- just fixing the "box zoom" case is a great improvement on its own. We can sidestep/defer the naming problem by just not making |
#6208 introduces a |
- Factor common code into _fitInternal method - Accept LatLngLike in cameraForBoxAndBearing
Also: restore previous import order in camera.js.
fixes #4221
Working with @ChrisLoer on adding CameraForBoxAndBearing() and fitScreenCoordinates() to have box zoom behavior without reset map bearing. We tested this manually on the debug page and ran the unit and integration tests. Still working on tests for new functionality and documentation for changes.
Launch Checklist
post benchmark scores