@ -1,5 +1,5 @@
import { ImageOverlay , LatLngBounds , LatLng BoundsExpression, LatLng Expression } from 'leaflet' ;
import { buildOptions , parseAttributeValue } from '../core/utils.js' ;
import { ImageOverlay , LatLngBounds , LatLng Expression } from 'leaflet' ;
import { buildOptions , parseAttributeValue , parseBoundsAttr } from '../core/utils.js' ;
import { withProps } from '../core/with-props.js' ;
import { registerChildren , unregisterChildren } from '../core/register.js' ;
@ -28,7 +28,7 @@ export class LeafletImageOverlay extends withProps(HTMLElement, PROPS) {
const url = this . getAttribute ( 'url' ) || '' ;
this . # obj = new ImageOverlay (
url ,
this . # parse d Bounds( ) ,
parse BoundsAttr ( this ) ,
buildOptions ( this , PROPS , [ 'url' , 'bounds' ] ) ,
) ;
registerChildren ( this , this . # obj ) ;
@ -45,7 +45,7 @@ export class LeafletImageOverlay extends withProps(HTMLElement, PROPS) {
if ( name === 'url' ) {
if ( val ) this . # obj . setUrl ( val ) ;
} else if ( name === 'bounds' ) {
this . # obj . setBounds ( new LatLngBounds ( this . # parse d Bounds( ) as LatLngExpression [ ] ) ) ;
this . # obj . setBounds ( new LatLngBounds ( parse BoundsAttr ( this ) as LatLngExpression [ ] ) ) ;
} else if ( name === 'alt' ) {
const el = this . # obj . getElement ( ) ;
if ( el ) ( el as HTMLImageElement ) . alt = val ? ? '' ;
@ -61,11 +61,6 @@ export class LeafletImageOverlay extends withProps(HTMLElement, PROPS) {
}
}
}
# parsedBounds ( ) : LatLngBoundsExpression {
const raw = this . getAttribute ( 'bounds' ) ;
return raw ? ( JSON . parse ( raw ) as LatLngBoundsExpression ) : [ ] ;
}
}
customElements . define ( 'leaflet-image-overlay' , LeafletImageOverlay ) ;