Merge pull request #32586 from v1zix/v1zix/leaflet-update-imageoverlay-options

[@types/leaflet] Update ImageOverlay options and add setZIndex method
This commit is contained in:
Mine Starks 2019-02-12 18:20:31 -08:00 committed by GitHub
commit d77c47c753
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 3 deletions

View File

@ -494,7 +494,7 @@ export interface TileLayerOptions extends GridLayerOptions {
tms?: boolean;
zoomReverse?: boolean;
detectRetina?: boolean;
crossOrigin?: boolean;
crossOrigin?: CrossOrigin;
// [name: string]: any;
// You are able add additional properties, but it makes this interface unchackable.
// See: https://github.com/DefinitelyTyped/DefinitelyTyped/issues/15313
@ -550,12 +550,16 @@ export namespace tileLayer {
function wms(baseUrl: string, options?: WMSOptions): TileLayer.WMS;
}
export type CrossOrigin = boolean | string;
export interface ImageOverlayOptions extends InteractiveLayerOptions {
opacity?: number;
alt?: string;
interactive?: boolean;
attribution?: string;
crossOrigin?: boolean;
crossOrigin?: CrossOrigin;
errorOverlayUrl?: string;
zIndex?: number;
className?: string;
}
@ -569,6 +573,9 @@ export class ImageOverlay extends Layer {
/** Update the bounds that this ImageOverlay covers */
setBounds(bounds: LatLngBounds): this;
/** Changes the zIndex of the image overlay */
setZIndex(value: number): this;
/** Get the bounds that this ImageOverlay covers */
getBounds(): LatLngBounds;

View File

@ -263,13 +263,15 @@ imageOverlayOptions = {
alt: 'alt',
interactive: true,
attribution: 'attribution',
errorOverlayUrl: 'http://www.test.com/error.png',
zIndex: 1,
crossOrigin: true,
className: 'className',
bubblingMouseEvents: false,
pane: 'pane'
};
const imageOverlayBounds = latLngBounds;
let imageOverlayBounds = latLngBounds;
let imageOverlay: L.ImageOverlay;
imageOverlay = L.imageOverlay('https://www.google.ru/images/branding/googlelogo/2x/googlelogo_color_120x44dp.png', imageOverlayBounds);
imageOverlay = L.imageOverlay('https://www.google.ru/images/branding/googlelogo/2x/googlelogo_color_120x44dp.png', imageOverlayBounds, imageOverlayOptions);
@ -278,6 +280,14 @@ imageOverlay = L.imageOverlay('https://www.google.ru/images/branding/googlelogo/
alt: 'alt',
className: 'className',
});
imageOverlay.setOpacity(100);
imageOverlay.bringToFront();
imageOverlay.bringToBack();
imageOverlay.setUrl('https://www.google.ru/images/branding/googlelogo/2x/googlelogo_color_120x44dp.png');
imageOverlay.setBounds(imageOverlayBounds);
imageOverlay.setZIndex(1);
imageOverlayBounds = imageOverlay.getBounds();
html = imageOverlay.getElement();
// videoOverlay
let videoOverlayOptions: L.VideoOverlayOptions;