diff --git a/docs/components/LImageOverlay.md b/docs/components/LImageOverlay.md index e4cdc8c8..cf1861aa 100644 --- a/docs/components/LImageOverlay.md +++ b/docs/components/LImageOverlay.md @@ -59,7 +59,6 @@ export default { | visible | | boolean | - | true | | interactive | | boolean | - | false | | bubblingMouseEvents | | boolean | - | true | -| url | | string | - | | | bounds | | | - | | | opacity | | number | - | 1.0 | | alt | | string | - | '' | @@ -68,6 +67,7 @@ export default { | zIndex | | number | - | 1 | | className | | string | - | '' | | options | Leaflet options to pass to the component constructor | object | - | {} | +| url | | string | - | null | ## Events diff --git a/docs/components/LSVGOverlay.md b/docs/components/LSVGOverlay.md new file mode 100644 index 00000000..8f95e6a7 --- /dev/null +++ b/docs/components/LSVGOverlay.md @@ -0,0 +1,87 @@ +--- +title: LSVGOverlay +--- + +# LSVGOverlay + +> Easily display a svg overlay. + +--- + +## Demo + +::: demo + + + + +::: + +## Props + +| Prop name | Description | Type | Values | Default | +| ------------------- | ---------------------------------------------------- | ------------------ | ------ | ------------- | +| pane | | string | - | 'overlayPane' | +| attribution | | string | - | null | +| name | | string | - | undefined | +| layerType | | string | - | undefined | +| visible | | boolean | - | true | +| interactive | | boolean | - | false | +| bubblingMouseEvents | | boolean | - | true | +| bounds | | | - | | +| opacity | | number | - | 1.0 | +| alt | | string | - | '' | +| crossOrigin | | boolean | - | false | +| errorOverlayUrl | | string | - | '' | +| zIndex | | number | - | 1 | +| className | | string | - | '' | +| options | Leaflet options to pass to the component constructor | object | - | {} | +| svg | | string\|SVGElement | - | null | + +## Events + +| Event name | Type | Description | +| -------------- | ------- | -------------------------------------------------- | +| update:visible | boolean | Triggers when the visible prop needs to be updated | +| ready | object | Triggers when the component is ready | diff --git a/src/components/LImageOverlay.vue b/src/components/LImageOverlay.vue index c9789884..842352da 100644 --- a/src/components/LImageOverlay.vue +++ b/src/components/LImageOverlay.vue @@ -10,6 +10,13 @@ import { imageOverlay, DomEvent } from 'leaflet'; export default { name: 'LImageOverlay', mixins: [ImageOverlayMixin, Options], + props: { + url: { + type: String, + custom: true, + default: null + } + }, mounted() { const options = optionsMerger(this.imageOverlayOptions, this); this.mapObject = imageOverlay(this.url, this.bounds, options); diff --git a/src/components/LSVGOverlay.vue b/src/components/LSVGOverlay.vue new file mode 100644 index 00000000..2fbbf538 --- /dev/null +++ b/src/components/LSVGOverlay.vue @@ -0,0 +1,88 @@ + + + +## Demo +::: demo + + + +::: + diff --git a/src/index.js b/src/index.js index 2516e998..31f41db8 100644 --- a/src/index.js +++ b/src/index.js @@ -35,6 +35,7 @@ export { default as LPolygon } from './components/LPolygon'; export { default as LPolyline } from './components/LPolyline'; export { default as LPopup } from './components/LPopup'; export { default as LRectangle } from './components/LRectangle'; +export { default as LSVGOverlay } from './components/LSVGOverlay'; export { default as LTileLayer } from './components/LTileLayer'; export { default as LTooltip } from './components/LTooltip'; export { default as LWMSTileLayer } from './components/LWMSTileLayer'; diff --git a/src/mixins/ImageOverlay.js b/src/mixins/ImageOverlay.js index e78c3162..797a8a57 100644 --- a/src/mixins/ImageOverlay.js +++ b/src/mixins/ImageOverlay.js @@ -4,10 +4,6 @@ import InteractiveLayer from './InteractiveLayer'; export default { mixins: [Layer, InteractiveLayer], props: { - url: { - type: String, - custom: true - }, bounds: { custom: true }, diff --git a/src/mixins/SVGOverlay.js b/src/mixins/SVGOverlay.js new file mode 100644 index 00000000..e5e93684 --- /dev/null +++ b/src/mixins/SVGOverlay.js @@ -0,0 +1,16 @@ +import ImageOverlay from './ImageOverlay.js'; + +export default { + mixins: [ImageOverlay], + mounted () { + this.svgOverlayOptions = this.imageOverlayOptions; + }, + methods: { + getElement () { + return this.mapObject.getElement(); + } + }, + render () { + return null; + } +}; diff --git a/types/index.d.ts b/types/index.d.ts index 110d9280..24c9c262 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -71,10 +71,6 @@ declare module "vue2-leaflet" { } class ImageOverlay extends Mixins(Layer, InteractiveLayer) { // props - url: string; - /** - * @default true - */ bounds: boolean; /** * @default 1.0 @@ -307,6 +303,10 @@ declare module "vue2-leaflet" { */ upperCase: boolean; } + class SVGOverlay extends Mixins(ImageOverlay) { + // methods + getElement(): SVGElement; + } // components class LCircle extends Mixins(Circle) { @@ -489,6 +489,13 @@ declare module "vue2-leaflet" { setImagePath(newVal: string, oldVal?: string): void; } class LImageOverlay extends Mixins(ImageOverlay) { + // props + /** + * @default null + */ + url: string | null; + + // data mapObject: L.ImageOverlay; parentContainer: any; } @@ -699,6 +706,17 @@ declare module "vue2-leaflet" { mapObject: L.TileLayer.WMS; parentContainer: any; } + class LSVGOverlay extends Mixins(SVGOverlay) { + // props + /** + * @default null + */ + svg: string | SVGElement | null; + + // data + mapObject: L.SVGOverlay; + parentContainer: any; + } // utils function findRealParent(firstVueParent: Vue): any; @@ -734,6 +752,7 @@ declare module "vue2-leaflet" { LRectangle, LTileLayer, LTooltip, - LWMSTileLayer + LWMSTileLayer, + LSVGOverlay }; }