How can I put a border in a symbol layer with SDF image?
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 12.4k
- Forks
- 2.4k
- PR merge metrics
- No merged PRs in 30d
Description
I have this code. I need put a border in this symbol, but I don't know, how to do that. Can someone help me?
```
> const map = new mapboxgl.Map({
> style: "mapbox://styles/mapbox/dark-v11",
> container: "map",
> center: [-74.5, 40], // starting position [lng, lat]
> zoom: 9, // starting zoom
> });
> map.on("load", () => {
> if (!map.hasImage("i_circle_svg")) {
> const img = new Image(145, 145);
> img.src = "icons/i_circle_svg.svg";
> img.onload = () =>
> map.addImage("i_circle_svg", img, {
> sdf: true,
> });
> }
> map.addSource("source-teste", {
> type: "geojson",
> data: {
> type: "Feature",
> geometry: {
> type: "Point",
> coordinates: [-74.5, 40],
> },
> properties: {
> title: "Mapbox DC",
> "marker-symbol": "monument",
> },
> },
> });
> map.addLayer({
> id: "HarvestPanelWeightLayer",
> type: "symbol",
> source: "source-teste",
> paint: {
> "icon-color": ["get","value"],
> },
> layout: {
> "icon-image": "i_circle_svg",
> },
> });
> });
```
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the map.addImage call using sdf: true and the symbol layer's icon-image and icon-color properties. Determine whether the requested border can be represented through the existing SDF and symbol styling behavior; done means the supplied custom icon renders with a visible border in the example.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend, web-dev
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100