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.

GeoJSON (Shape) sources initialized with MGLShape objects should work with predicate filters #7336

Closed

Description

@boundsj

In #7145 we modified MGLGeoJSONSource so that it can be created with an MGLShape. However, since MGLShape does not convey a feature's identifier and attributes properties, we lost the ability to apply a NSPredicate filter to a layer for the source created with a shape.

For instance, this used to work:

    MGLPolygonFeature *feature = [MGLPolygonFeature polygonWithCoordinates:leafCoords count:coordsCount];
    feature.identifier = @"leaf-feature";
    feature.attributes = @{@"color": @"red"};
    
    MGLGeoJSONSource *source = [[MGLGeoJSONSource alloc] initWithIdentifier:@"leaf-source" shape:feature options:nil];
    [self.mapView.style addSource:source];
    
    MGLFillStyleLayer *layer = [[MGLFillStyleLayer alloc] initWithIdentifier:@"leaf-fill-layer" source:source];
    layer.predicate = [NSPredicate predicateWithFormat:@"color = %@", @"red"];
    MGLStyleValue *fillColor = [MGLStyleValue<UIColor *> valueWithRawValue:[UIColor redColor]];
    layer.fillColor = fillColor;
    [self.mapView.style addLayer:layer];

Now, If the layer.predicate is set, the feature is not visible since the attributes cannot be found on the object (shape).

cc @frederoni @1ec5

Activity

  1. added
    iOS
    macOS
    release blocker
    on Dec 7, 2016
  2. added this to the ios-v3.4.0 milestone on Dec 7, 2016
  3. self-assigned this
    on Dec 7, 2016
  4. boundsj commented on Dec 12, 2016

    @boundsj
    ContributorAuthor

    This was fixed by #7339

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

Metadata

Metadata

Assignees

Labels

bugiOSmacOSrelease blockerruntime styling

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions