简体   繁体   English

将 icon-translate 属性 function、stops 转换为 mapbox 表达式

[英]Convert icon-translate property function, stops, to mapbox expression

In mapbox how can I convert this icon-translate stops to an Expression with interpolate.在 mapbox 中,我如何将这个图标翻译停止转换为带有插值的表达式。 I can't figure it out from the mapbox docs.我无法从 mapbox 文档中弄清楚。

The stops works correctly and changes the offset of the icon based on the zoom level, between the two zoom levels 12 and 15. Typescript errors because stops isn't an expression. stops 正常工作,并根据缩放级别更改图标的偏移量,在两个缩放级别 12 和 15 之间。Typescript 错误,因为 stops 不是表达式。

        'icon-translate': {
          // @ts-ignore
          stops: [
            [12, [0, 0]],
            [15, [0, -55]]
          ]
        },

Thanks for the help.谢谢您的帮助。

Edit: This worked with no more js errors and typescript编辑:这没有更多的 js 错误和 typescript

        'icon-translate': ['interpolate',['linear'],['zoom'],
          12, ["literal",[0, 0]],
          15, ["literal",[0, -55]]
        ],

Like this:像这样:

{
'icon-translate': ['interpolate',['linear'],['zoom'], 
    12, ['literal', [0, 0]],
    15, ['literal', [0, -55]]
]
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM