-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to implement markers that can be scaled and recoloured? #1594
Comments
@mourner Any thoughts on my above query? |
I am also interested in doing this. I find it strange that Mapbox GL JS is all about vector graphics but doesn't seem to have an easy way of customizing vector icons. It would be great to be able to use Mapbox GL JS instead of d3.js for mapping dynamic data. |
icon-color is also not working, this code taken from https://www.mapbox.com/mapbox-gl-js/example/geojson-markers/ wont 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"
}
}); |
@jordi-adame The documentation for |
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 |
A poor man's attempt: I tried to use the cli tools of imagemagick to create SDF images - and it works kind of (it is far from perfect, but at least it is simple): As my test input I downloaded this maki icon: bicycle-15.svg
_I´m on Windows; on Linux you need no together with a {"icon": {"width": 38, "height": 38,"x": 0,"y": 0,"pixelRatio": 1, "sdf": true }} this makes a single icon. As said, this is just a quick-and-dirty solution with a lot of manual work ( e.g. the values in the IM commands could be tweaked) and I´m not sure somebody is interested. |
I need to implement dynamic markers that can be scaled and re-coloured.
From this issue, I can see that SDF icons is a neat way to go about. But I am not sure how I can generate an SDF image? Do you use any tool for this? And I see that there is no SDF usage in V8 and it has been replaced with SVG.
SVG would be a better solution, but again from this issue that I raised earlier, it looks like SVG's are converted to png + JSON sprites, and therefore I cannot scale or re-colour it.
And I also think that there should be an example for this.
The text was updated successfully, but these errors were encountered: