You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Update yarn.lock files
* Add "Map#addImage"
* Make `SpriteAtlas` fire `error` and `data` events
* Add "Map#removeImage"
* Relax requirement that styles using "icon-image" must have a "sprite"
* Add "pixelRatio" parameter to "Map#addImage"
* Enable "runtime-styling/image-add" integration test
* Add "runtime-styling/image-remove" integration test
* Add "runtime-styling/image-add-pattern" integration test
* Add docs for `Map#addImage` and `Map#removeImage`
* Add explanatory comment to `SpriteAtlas`
* Rename SpriteAtlas#atlas to SpriteAtlas#shelfPack
* Eliminate `AtlasImage`
* Moar comments
* Ensure `SpriteAtlas#addImage` returns early after an error
* Misc docs improvements
* Remove logic that clears texture when image is removed
* fixup! Eliminate `AtlasImage`
* Remove addImage debug page
returnthis.fire('error',{error: newError('Image provided in an invalid format. Supported formats are HTMLImageElement, ImageData, and ArrayBufferView.')});
68
+
}
69
+
70
+
if(this.images[name]){
71
+
returnthis.fire('error',{error: newError('An image with this name already exists.')});
72
+
}
73
+
74
+
constrect=this.allocateImage(width,height);
75
+
if(!rect){
76
+
returnthis.fire('error',{error: newError('There is not enough space to add this image.')});
Copy file name to clipboardExpand all lines: src/ui/map.js
+26
Original file line number
Diff line number
Diff line change
@@ -817,6 +817,32 @@ class Map extends Camera {
817
817
returnthis.style.getSource(id);
818
818
}
819
819
820
+
/**
821
+
* Add an image to the style. This image can be used in `icon-image`,
822
+
* `background-pattern`, `fill-pattern`, and `line-pattern`. An
823
+
* {@link Map#error} event will be fired if there is not enough space in the
824
+
* sprite to add this image.
825
+
*
826
+
* @param {string} name The name of the image.
827
+
* @param {HTMLImageElement|ArrayBufferView} image The image as an `HTMLImageElement` or `ArrayBufferView` (using the format of [`ImageData#data`](https://developer.mozilla.org/en-US/docs/Web/API/ImageData/data))
828
+
* @param {Object} [options] Required if and only if passing an `ArrayBufferView`
829
+
* @param {number} [options.width] The pixel width of the `ArrayBufferView` image
830
+
* @param {number} [options.height] The pixel height of the `ArrayBufferView` image
831
+
* @param {number} [options.pixelRatio] The ratio of pixels in the `ArrayBufferView` image to physical pixels on the screen
0 commit comments