mapbox / mapbox/mapbox-gl-js

Combine loadImage and addImage

Open
#7,800 0 comments 13 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

api :memo: feature :green_apple:
Dominant language
TypeScript
Stars
12.4k
Forks
2.4k
PR merge metrics
No merged PRs in 30d

Description

It's not the end of the world, but I find this pattern clunky and hard to remember:

```
map.loadImage('assets/images/marker.png', (error, image) => {
map.addImage('marker', image);
});
```

It could just as easily be:

```
map.addImage('marker', 'assets/images/marker.png');
```

I would have thought that the primary use case for `addImage` is fetching an image specifically for the purpose of adding it to the map, rather than using some existing image that happens to exist in the DOM.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the existing loadImage and addImage entry points and their public API behavior. Compare how each handles image URLs, loading errors, and already available images; the work is done when the proposed combined call has clear behavior and corresponding coverage or documentation.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
api, frontend, web-dev
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.