1- import { extend , bindAll , warnOnce , uniqueId } from '../util/util' ;
1+ import { extend , bindAll , warnOnce , uniqueId , isImageBitmap } from '../util/util' ;
22import browser from '../util/browser' ;
33import DOM from '../util/dom' ;
44import { getImage , getJSON , ResourceType } from '../util/ajax' ;
@@ -1662,8 +1662,8 @@ class Map extends Camera {
16621662 this . _lazyInitEmptyStyle ( ) ;
16631663 const version = 0 ;
16641664
1665- if ( image instanceof HTMLImageElement || ( ImageBitmap && image instanceof ImageBitmap ) ) {
1666- const { width, height, data} = browser . getImageData ( image as HTMLImageElement | ImageBitmap ) ;
1665+ if ( image instanceof HTMLImageElement || isImageBitmap ( image ) ) {
1666+ const { width, height, data} = browser . getImageData ( image ) ;
16671667 this . style . addImage ( id , { data : new RGBAImage ( { width, height} , data ) , pixelRatio, stretchX, stretchY, content, sdf, version} ) ;
16681668 } else if ( image . width === undefined || image . height === undefined ) {
16691669 return this . fire ( new ErrorEvent ( new Error (
@@ -1720,9 +1720,9 @@ class Map extends Camera {
17201720 return this . fire ( new ErrorEvent ( new Error (
17211721 'The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.' ) ) ) ;
17221722 }
1723- const imageData = ( image instanceof HTMLImageElement || ( ImageBitmap && image instanceof ImageBitmap ) ) ?
1724- browser . getImageData ( image as HTMLImageElement | ImageBitmap ) :
1725- image as ImageData ;
1723+ const imageData = ( image instanceof HTMLImageElement || isImageBitmap ( image ) ) ?
1724+ browser . getImageData ( image ) :
1725+ image ;
17261726 const { width, height, data} = imageData ;
17271727
17281728 if ( width === undefined || height === undefined ) {
@@ -1736,7 +1736,7 @@ class Map extends Camera {
17361736 'The width and height of the updated image must be that same as the previous version of the image' ) ) ) ;
17371737 }
17381738
1739- const copy = ! ( image instanceof HTMLImageElement || ( ImageBitmap && image instanceof ImageBitmap ) ) ;
1739+ const copy = ! ( image instanceof HTMLImageElement || isImageBitmap ( image ) ) ;
17401740 existingImage . data . replace ( data , copy ) ;
17411741
17421742 this . style . updateImage ( id , existingImage ) ;
0 commit comments