Skip to content

Commit

Permalink
Handle loading of empty raster tiles (204 No Content) (#3428)
Browse files Browse the repository at this point in the history
* Handle empty raster tiles

* Improve `arrayBufferToImageBitmap` to handle empty buffers

* Add changelog entry
  • Loading branch information
petrsloup authored Dec 3, 2023
1 parent 49251c4 commit 4ad19a6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

### 🐞 Bug fixes
- Fix zooming outside the central globe when terrain 3D is enabled ([#3425](https://github.com/maplibre/maplibre-gl-js/pull/3425))
- Handle loading of empty raster tiles (204 No Content) ([#3428](https://github.com/maplibre/maplibre-gl-js/pull/3428))
- _...Add new stuff here..._

## 4.0.0-pre.1
Expand Down
3 changes: 3 additions & 0 deletions src/util/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,9 @@ export function isImageBitmap(image: any): image is ImageBitmap {
* @returns - A promise resolved when the conversion is finished
*/
export const arrayBufferToImageBitmap = async (data: ArrayBuffer): Promise<ImageBitmap> => {
if (data.byteLength === 0) {
return createImageBitmap(new ImageData(1, 1));
}
const blob: Blob = new Blob([new Uint8Array(data)], {type: 'image/png'});
try {
return createImageBitmap(blob);
Expand Down

0 comments on commit 4ad19a6

Please sign in to comment.