Skip to content
This repository has been 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
boundsj opened this issue Dec 7, 2016 · 1 comment
Assignees
Labels
bug iOS Mapbox Maps SDK for iOS macOS Mapbox Maps SDK for macOS release blocker Blocks the next final release runtime styling
Milestone

Comments

@boundsj
Copy link
Contributor

boundsj commented Dec 7, 2016

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

@boundsj boundsj added bug iOS Mapbox Maps SDK for iOS macOS Mapbox Maps SDK for macOS release blocker Blocks the next final release labels Dec 7, 2016
@boundsj boundsj added this to the ios-v3.4.0 milestone Dec 7, 2016
@boundsj boundsj self-assigned this Dec 7, 2016
@boundsj
Copy link
Contributor Author

boundsj commented Dec 12, 2016

This was fixed by #7339

@boundsj boundsj closed this as completed Dec 12, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug iOS Mapbox Maps SDK for iOS macOS Mapbox Maps SDK for macOS release blocker Blocks the next final release runtime styling
Projects
None yet
Development

No branches or pull requests

1 participant