mapbox / mapbox/mapbox-gl-js

sdf param of map.addImage not working correct

Open
#10,920 0 comments 0 reactions 0 assignees View on GitHub
bug :lady_beetle: needs investigation :mag:
Dominant language
TypeScript
Stars
12.4k
Forks
2.4k
PR merge metrics
No merged PRs in 30d

Description

**mapbox-gl-js version**: 2.4.0

**browser**: Chrome 92

### Steps to Trigger Behavior

1. using map.addImage add first image.
2. using map.addImage add second image, with sdf param true.
3. add a symbol layer, using this two icons, add set 'icon-color' yellow.
4. when map zoom to 0, two icons change to yellow color.

### Link to Demonstration
https://jsbin.com/varekic/1/edit?js,output

https://user-images.githubusercontent.com/10242480/128799096-736ca489-d700-4ce7-a36c-560ab517a1a7.mp4

### Code
```javascript
map.on('load', () => {
// Add an image to use as a custom marker
map.loadImage(
'https://docs.mapbox.com/mapbox-gl-js/assets/custom_marker.png',
(error, image) => {
if (error) throw error;
map.addImage('custom-marker', image);
}
);
map.loadImage(
'https://docs.mapbox.com/mapbox-gl-js/assets/cat.png',
(error, image) => {
if (error) throw error;
map.addImage('custom-red', image, {sdf: true});
}
);
// Add a GeoJSON source with 2 points
map.addSource('points', {
'type': 'geojson',
'data': {
'type': 'FeatureCollection',
'features': [
{
// feature for Mapbox DC
'type': 'Feature',
'geometry': {
'type': 'Point',
'coordinates': [
30.03238901390978, 38.913188059745586
]
},
'properties': {
'title': 'Mapbox DC',
'image': 'custom-marker'
}
},
{
// feature for Mapbox SF
'type': 'Feature',
'geometry': {
'type': 'Point',
'coordinates': [-122.414, 37.776]
},
'properties': {
'title': 'Mapbox SF',
'image': 'custom-red'
}
}
]
}
});

// Add a symbol layer
map.addLayer({
'id': 'points',
'type': 'symbol',
'source': 'points',
'paint': {
'icon-color': 'yellow'
},
'layout': {
'icon-image': ['get', 'image'],
}
});
});
```

### Expected Behavior
cat image should be yellow color and custom_marker shouldn't be yellow color.

### Actual Behavior
two images are switching between normal image and colored image.

Contributor guide

Open the contributing guide

Research direction

Start with the map.addImage calls and the linked JSBin reproduction, especially the second image created with sdf: true and the symbol layer using icon-color. Confirm the behavior at zoom 0 and verify that only the SDF image becomes yellow while custom_marker retains its original colors.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
computer-graphics, frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.