arnaudleclerc / AzureMapsControl.Components

Razor Components for azure-maps-control
MIT License
34 stars 12 forks source link

LineLayer doesn't apply strokeColor expression #49

Closed hamishfagg closed 3 years ago

hamishfagg commented 3 years ago

Describe the bug I can't get an expression like ['get', 'color'] to get a line's color from a property.

To Reproduce Using the LineLayerOnReady sample as a starting point,

  1. Edit the line definition to read like this:

    await dataSource.AddAsync(new AzureMapsControl.Components.Atlas.Shape<AzureMapsControl.Components.Atlas.LineString>(
        new AzureMapsControl.Components.Atlas.LineString(new[] {
            new AzureMapsControl.Components.Atlas.Position(11.575454, 48.137392),
            new AzureMapsControl.Components.Atlas.Position(11.576029, 48.137094),
            new AzureMapsControl.Components.Atlas.Position(11.577248, 48.138912),
            new AzureMapsControl.Components.Atlas.Position(11.578434, 48.138737),
            new AzureMapsControl.Components.Atlas.Position(11.578826, 48.139409),
            new AzureMapsControl.Components.Atlas.Position(11.580140, 48.139179),
            new AzureMapsControl.Components.Atlas.Position(11.581237, 48.141555),
            new AzureMapsControl.Components.Atlas.Position(11.581155, 48.141852),
            new AzureMapsControl.Components.Atlas.Position(11.581990, 48.143534),
            new AzureMapsControl.Components.Atlas.Position(11.583355, 48.143896),
            new AzureMapsControl.Components.Atlas.Position(11.583662, 48.144258)
        }),
        new Dictionary<string, object>()
        {
            { "Color", "#00FF00" }
        }));
        await dataSource.AddAsync(new AzureMapsControl.Components.Atlas.Shape<AzureMapsControl.Components.Atlas.LineString>(
        new AzureMapsControl.Components.Atlas.LineString(new[] {
            new AzureMapsControl.Components.Atlas.Position(11.585458, 48.145596),
            new AzureMapsControl.Components.Atlas.Position(11.587910, 48.145779),
            new AzureMapsControl.Components.Atlas.Position(11.589632, 48.146608),
            new AzureMapsControl.Components.Atlas.Position(11.590771, 48.148219),
            new AzureMapsControl.Components.Atlas.Position(11.591979, 48.150743),
            new AzureMapsControl.Components.Atlas.Position(11.592885, 48.150611),
            new AzureMapsControl.Components.Atlas.Position(11.593161, 48.150874),
            new AzureMapsControl.Components.Atlas.Position(11.593594, 48.151084),
            new AzureMapsControl.Components.Atlas.Position(11.594028, 48.151803),
            new AzureMapsControl.Components.Atlas.Position(11.592281, 48.152074)
        }),
        new Dictionary<string, object>()
        {
            { "Color", "#FF0000" }
        }));
  2. Change LineLayerOptions to this:

    Options = new AzureMapsControl.Components.Layers.LineLayerOptions
            {
                Source = dataSourceId,
                StrokeWidth = new AzureMapsControl.Components.Atlas.ExpressionOrNumber(6),
                StrokeColor = new AzureMapsControl.Components.Atlas.ExpressionOrString(
                    new AzureMapsControl.Components.Atlas.Expression[]
                    {
                        new AzureMapsControl.Components.Atlas.ExpressionOrString("get"),
                        new AzureMapsControl.Components.Atlas.ExpressionOrString("Color")
    
                    })
            }

Expected behavior Line color should come from the property specified

Screenshots Errors in the browser console: image

Desktop (please complete the following information):

arnaudleclerc commented 3 years ago

Thanks for noticing that, I apparently forgot to apply the properties on the shapes when they are created. I will push a fix soon!

arnaudleclerc commented 3 years ago

I just published a v1.8.1 where this issue should be fixed. Let me know if you still face any problem, and feel free to reopen this issue if necessary.