Skip to content
This repository has been archived by the owner on Jun 14, 2024. It is now read-only.

[WIP] Add Line Gradient Example #232

Closed
wants to merge 3 commits into from
Closed

[WIP] Add Line Gradient Example #232

wants to merge 3 commits into from

Conversation

riastrad
Copy link
Contributor

@riastrad riastrad commented Oct 2, 2018

Closes #203

- (void)mapView:(MGLMapView *)mapView didFinishLoadingStyle:(MGLStyle *)style {

NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"line-gradient" ofType:@"geojson"]];
MGLShapeSource *source = [[MGLShapeSource alloc] initWithIdentifier:@"line-source" URL:url options:nil];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that the clarification that will happen in mapbox/mapbox-gl-native#13000 should allow you to switch back to using an MGLPolyline like you did in 100c88d.

@1: UIColor.redColor
};

NSExpression *gradientExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($lineProgress, 'linear', nil, %@)", stops];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noting that we might be seeing this crash in its current state because of mapbox/mapbox-gl-native#12917.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can try using MGL_FUNCTION("line-progress") until mapbox/mapbox-gl-native#12917 is resolved.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm getting the following error when trying to implement that workaround @captainbarbosa:

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Unable to parse function name 'MGL_Function:' into supported selector (MGL_Function:) '

Am I doing something wrong here:

NSExpression *gradientExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(MGL_Function('line-progress'), 'linear', nil, %@)", stops];

@riastrad
Copy link
Contributor Author

Now that mapbox/mapbox-gl-native#13192 has landed, I believe this example can be picked back up.

@riastrad
Copy link
Contributor Author

Closing in favor of #368

@riastrad riastrad closed this Oct 17, 2019
@jmkiley jmkiley deleted the je-line-gradient branch April 29, 2020 08:09
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Using Line-Gradient Property
2 participants