Skip to content

Commit

Permalink
Expose map.getImage
Browse files Browse the repository at this point in the history
  • Loading branch information
alex3165 committed Nov 30, 2017
1 parent 4a1329f commit 734cb37
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/style/style.js
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,10 @@ class Style extends Evented {
this.fire('data', {dataType: 'style'});
}

getImage(id: string): ?StyleImage {
return this.imageManager.getImage(id);
}

removeImage(id: string) {
if (!this.imageManager.getImage(id)) {
return this.fire('error', {error: new Error('No image with this name exists.')});
Expand Down
16 changes: 16 additions & 0 deletions src/ui/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -1062,6 +1062,22 @@ class Map extends Camera {
this.style.addImage(id, { data: ((data: any): RGBAImage), pixelRatio, sdf });
}

/**
* Get an image from the style (such as one used by `icon-image` or `background-pattern`).
*
* @param id The ID of the image.
*/
getImage(id: string): ?StyleImage {
if (!id) {
this.fire('error', {
error: new Error('Missing required image id')
});
return;
}

return this.style.getImage(id);
}

/**
* Remove an image from the style (such as one used by `icon-image` or `background-pattern`).
*
Expand Down

0 comments on commit 734cb37

Please sign in to comment.