UNPKG

leaflet

Version:

JavaScript library for mobile-friendly interactive maps

85 lines (84 loc) • 3.21 kB
import { Renderer } from './Renderer.js'; import type { RendererEventMap, RendererOptions } from '../../types.js'; import type { Point } from '../../geometry/Point.js'; import type { CircleMarker } from './CircleMarker.js'; import type { Path } from './Path.js'; import type { Polyline } from './Polyline.js'; /** @import {RendererEventMap, RendererOptions} from '../../types.js' */ /** @import {Point} from '../../geometry/Point.js' */ /** @import {CircleMarker} from './CircleMarker.js' */ /** @import {Path} from './Path.js' */ /** @import {Polyline} from './Polyline.js' */ /** * Allows vector layers to be displayed with [SVG](https://developer.mozilla.org/docs/Web/SVG). Inherits `Renderer`. * @constructorDescription Creates an SVG renderer with the given options. * @example * Use SVG by default for all paths in the map: * * ```js * const map = new LeafletMap('map', { * renderer: new SVG() * }); * ``` * * Use a SVG renderer with extra padding for specific vector geometries: * * ```js * const map = new LeafletMap('map'); * const myRenderer = new SVG({ padding: 0.5 }); * const line = new Polyline( coordinates, { renderer: myRenderer } ); * const circle = new Circle( center, { renderer: myRenderer, radius: 100 } ); * ``` * @template {RendererOptions} [O=RendererOptions] * @template {RendererEventMap} [E=RendererEventMap] * @extends {Renderer<O, E>} */ export declare class SVG<O extends RendererOptions = RendererOptions, E extends RendererEventMap = RendererEventMap> extends Renderer<O, E> { /** @type {SVGElement} */ _rootGroup: SVGElement; /** @type {Point | undefined} */ _svgSize: Point | undefined; _initContainer(): void; _destroyContainer(): void; _resizeContainer(): Point; _update(): void; /** @param {Path} layer */ _initPath(layer: Path): void; /** @param {Path} layer */ _addPath(layer: Path): void; /** @param {Path} layer */ _removePath(layer: Path): void; /** @param {Path} layer */ _updatePath(layer: Path): void; /** @param {Path} layer */ _updateStyle(layer: Path): void; /** * @param {Polyline} layer * @param {boolean} [closed] */ _updatePoly(layer: Polyline, closed?: boolean): void; /** @param {CircleMarker} layer */ _updateCircle(layer: CircleMarker): void; /** * @param {Path} layer * @param {string} path */ _setPath(layer: Path, path: string): void; /** @param {Path} layer */ _bringToFront(layer: Path): void; /** @param {Path} layer */ _bringToBack(layer: Path): void; /** * Returns a instance of [SVGElement](https://developer.mozilla.org/docs/Web/API/SVGElement), * corresponding to the class name passed. For example, using 'line' will return an instance * of [SVGLineElement](https://developer.mozilla.org/docs/Web/API/SVGLineElement). * @param {string} name */ static create(name: string): SVGElement; /** * Generates a SVG path string for multiple rings, with each ring turning into "M..L..L.." instructions * @param {Point[][]} rings * @param {boolean} [closed] */ static pointsToPath(rings: Point[][], closed?: boolean): string; }