mapbox gl更改图标颜色 [英] mapbox gl change icon color

查看:835
本文介绍了mapbox gl更改图标颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以更改mapbox-gl-js图标图像的颜色?

Is there a way to change a mapbox-gl-js icon-image color?

此代码摘自 https://www.mapbox.com /mapbox-gl-js/example/geojson-markers/不会将标记颜色更改为红色

This code taken from https://www.mapbox.com/mapbox-gl-js/example/geojson-markers/ won't change the marker color to red

map.addLayer({
    "id": "markers",
    "type": "symbol",
    "source": "markers",
    "layout": {
        "icon-image": "{marker-symbol}-15",
        "text-field": "{title}",
        "text-font": ["Open Sans Semibold", "Arial Unicode MS Bold"],
        "text-offset": [0, 0.6],
        "text-anchor": "top"
    },
    "paint": {
        "text-size": 12,
        "icon-color" : "#ff0000"
    }
});

我已经尝试了官方文档中列出的所有选项

I've tried all the options listed in the official documentation

推荐答案

我找到了答案.您需要专门的sdf图标才能使其正常工作.

I found a answer. You need sdf icons specifically for it to work.

https://github.com/mapbox/mapbox-gl-js /issues/1594

Unfortunately we don't have a turnkey solution for generating sdf icons but you can see an example of how its done in the maki project

https://github.com/mapbox/maki/blob/mb-pages/sdf-render.js

https://github.com/mapbox/maki/blob/mb-pages/sdf-render.js

由@yurik更新:上面的链接不再起作用,可能是指

Updated by @yurik: The above link no longer works, probably refers to https://github.com/mapbox/maki/blob/b0060646e28507037e71edf049a17fab470a0080/sdf-render.js

https://github.com/mapbox/mapbox-gl-js /issues/161

这篇关于mapbox gl更改图标颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆