【问题标题】:Incompatible pointer types assigning to MGLStyleValue from NSExpression从 NSExpression 分配给 MGLStyleValue 的不兼容指针类型
【发布时间】:2018-11-17 08:21:05
【问题描述】:

我在我的应用中实现了 MAPBOX。我在自定义折线颜色和宽度时遇到问题。这是我已经实现的代码。

MGLPolyline *polylineFirst = [MGLPolyline polylineWithCoordinates:routeCoordinates count:routeFirst.coordinateCount];

MGLShapeSource *source = [[MGLShapeSource alloc] initWithIdentifier:@"polyline" shape:polyline options:nil];
MGLLineStyleLayer *lineStyle = [[MGLLineStyleLayer alloc] initWithIdentifier:@"polyline" source:source];

lineStyle.lineColor = [NSExpression expressionForConstantValue:[UIColor yellowColor]];
lineStyle.lineWidth = [NSExpression expressionForConstantValue:@5];

[self.mapView.style addSource:source];
[self.mapView.style addLayer:lineStyle];

【问题讨论】:

    标签: ios mapbox polyline


    【解决方案1】:

    表达式替换了 v4.0 中的 style functions,看起来您使用的是较早版本的 Maps SDK。

    与您的代码等效的样式函数是:

       lineStyle.lineColor = [MGLStyleValue valueWithRawValue:[UIColor yellowColor]];
       lineStyle.lineWidth = [MGLStyleValue valueWithRawValue:@5];
    

    您可能会发现this sample code 很有帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-04-29
      • 2014-06-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多