Giter Site home page Giter Site logo

Comments (3)

mfazekas avatar mfazekas commented on May 7, 2024

@mattijsf thanks for the report. Not yet looked into, does ["literal", [...]] works?

from maps.

mattijsf avatar mattijsf commented on May 7, 2024

Yes @mfazekas that works! Good to have a workaround available!

I just checked the Android's RCTMGLStyleFactory there we use the following logic:

public static void setLineDasharray(LineLayer layer, RCTMGLStyleValue styleValue) {
  if (styleValue.isExpression()) {
    layer.setProperties(PropertyFactory.lineDasharray(styleValue.getExpression()));
  } else {
    layer.setProperties(PropertyFactory.lineDasharray(styleValue.getFloatArray(VALUE_KEY)));
  }
}

Seems like we could use a similar isExpression technique on iOS to map it towards a plain array instead.

from maps.

mattijsf avatar mattijsf commented on May 7, 2024
- (NSExpression *)mglStyleValue`
{
    ...
    ...
    } else if ([expressionJSON respondsToSelector:@selector(objectEnumerator)] && [[[(NSArray*)expressionJSON objectEnumerator] nextObject] isKindOfClass:[NSNumber class]]) {
        return [NSExpression expressionForConstantValue:expressionJSON];
    } else {
        return [NSExpression expressionWithMGLJSONObject:expressionJSON];
    }
}

This expressionForConstantValue:expressionJSON addition in RCTMGLStyleValue.m works for the lineDashPattern case. My idea was that when the first element of the expression (array) is a number we can safely assume it is an array of constant values.

iconTextFitPadding is special since it needs to be an instance of UIEdgeInsets so extending styleExtras in styleMap.js with a extra entry: iconTextFitPadding: { iosType: 'edgeinsets' } will do the trick.

If you would like. I could create a PR for these changes. I also noticed the edgeinsets check in RCTMGLStyleValue.mglStyleValue is broken. It should check for the presence of an array.

from maps.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.