Skip to content

Add fitFeature method #2245

Open
Open

Description

@lucaswoj

"bounds" is an ill-defined concept in mapbox-gl-js due to pitch and rotation. A less ambiguous and more useful API would fit the map to an arbitrary GeoJSON feature.

ref #2112

Activity

  1. 1ec5 commented on Mar 10, 2016

    @1ec5
    Contributor

    "bounds" is an ill-defined concept in mapbox-gl-js due to pitch and rotation.

    It doesn’t have to be: #1338. But a fitFeature feature would be useful too, by analogy with the -showAnnotations: function in the Mapbox iOS SDK that developers apparently prefer over -setVisibleCoordinateBounds: for many use cases.

  2. changed the title [-]Replace fitBounds with fitFeature[/-] [+]Add fitFeature method[/+] on Mar 10, 2016
  3. mourner commented on Mar 11, 2016

    @mourner
    Member

    A less ambiguous and more useful API would fit the map to an arbitrary GeoJSON feature.

    How would fitFeature work? Would it try to auto-pick a bearing value that minimizes the bounding box around a feature? Or would it preserve the current bearing unless specified? The name fitFeature also doesn't fit the cases where you would pass it a GeoJSON geometry or a feature collection. Maybe fitData, by analogy with setData?

  4. 1ec5 commented on Mar 11, 2016

    @1ec5
    Contributor

    Ideally, it would minimize the bounding box around a feature while preserving the current bearing, but I don't think that's strictly necessary for this feature. Again for comparison, the iOS SDK fits to the unrotated bounding box when calling -showAnnotations: but you can get a more optimal fit by passing the feature's array of coordinates directly into -setVisibleCoordinates:count:. In either case, the current bearing is preserved.

  5. added
    GL native → GL JS
    on Feb 15, 2017
  6. iplanwebsites commented on Nov 15, 2017

    @iplanwebsites

    Do you have an idea of the timeline for this feature?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    GL native → GL JSfeature 🍏

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions