Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
This repository was archived by the owner on Aug 8, 2023. It is now read-only.

MGLShapeSource should have a shape array convenience initializer #7453

Closed

Description

@1ec5

Despite -[MGLShapeSource initWithIdentifier:shape:options:] documentation mentioning the possibility of using an MGLShapeCollectionFeature to manage multiple features, developers unfamiliar with the Simple Features specification are unlikely to discover this capability and will assume that a shape source can only be used with one shape. We should add the following convenience initializers to MGLShapeSource so developers don’t have to go through MGLShapeCollection explicitly:

  • -initWithIdentifier:shapes:options: would wrap the shapes in an MGLShapeCollection.
  • -initWithIdentifier:features:options: would wrap the features in an MGLShapeCollectionFeature.

If we encounter a shapes array that contains an MGLFeature, should we treat it as an ordinary shape, or should we upgrade to an MGLShapeCollectionFeature and wrap the other shapes in features?

I’d prefer not to add a shapes or features property, since that blurs the definition of the kind of data this source actually holds.

/cc @boundsj @frederoni @bsudekum

Activity

  1. added
    iOS
    macOS
    on Dec 15, 2016
  2. added this to the ios-v3.4.0 milestone on Dec 15, 2016
  3. self-assigned this
    on Jan 8, 2017
  4. boundsj commented on Jan 10, 2017

    @boundsj
    Contributor

    If we encounter a shapes array that contains an MGLFeature, should we treat it as an ordinary shape, or should we upgrade to an MGLShapeCollectionFeature and wrap the other shapes in features?

    This is a good question. I think that developers who are unfamiliar with the Simple Features specification will also be unfamiliar with the distinction between geometry objects (shapes) and feature objects.

    Since creating an MGLFeature is as easy as creating an MGLShape (even if the meta data properties of MGLFeature are not used) and because most developers will eventually realize they want to create feature objects to unlock the full power of runtime and data driven styling, I think that offering only -initWithIdentifier:features:options: and directing developers to that API in documentation and examples could help simplify one of the most initially confusing parts of the runtime styling API and reduce the support workload a bit.

    The existing APIs (and a new -initWithIdentifier:shapes:options: that treats any MGLFeatureas an ordinary shape) should suffice for developers who really want or need to work with geometries for some reason.

  5. boundsj commented on Jan 12, 2017

    @boundsj
    Contributor

    Fixed in #7665 on the release-ios-v3.4.0 branch.

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

Metadata

Metadata

Assignees

Labels

iOSmacOSruntime styling

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions