Skip to content

SVGRenderer

Defined in: leaflet/vector/svg_renderer.ts:65

Allows vector layers to be displayed with SVG. Inherits Renderer.

Example

Use SVG by default for all paths in the map:

const map = map('map', {
    renderer: svg()
});

Use a SVG renderer with extra padding for specific vector geometries:

var map = map('map');
var myRenderer = svg({ padding: 0.5 });
var line = polyline( coordinates, { renderer: myRenderer } );
var circle = circle( center, { renderer: myRenderer } );

Extends

Methods

_destroyContainer()

protected _destroyContainer(): void

Defined in: leaflet/vector/svg_renderer.ts:81

Must destroy the HTML element in this._container and free any other resources. The base implementation destroys the element and removes any event handlers attached to it.

Returns

void

Overrides

RendererBase._destroyContainer


_initContainer()

protected _initContainer(): SVGSVGElement

Defined in: leaflet/vector/svg_renderer.ts:69

Must initialize the HTML element to use as blanket, and store it as this._container. The base implementation creates a blank <div>

Returns

SVGSVGElement

Overrides

RendererBase._initContainer


_onSettled()

protected _onSettled(): void

Defined in: leaflet/vector/renderer.ts:89

Runs whenever the map state settles after changing (at the end of pan/zoom animations, etc). This should trigger the bulk of any rendering logic.

If the continuous option is set to true, then this also runs on any map state change (including during pan/zoom animations).

Returns

void

Inherited from

RendererBase._onSettled


_onViewReset()

protected _onViewReset(): void

Defined in: leaflet/vector/renderer.ts:81

(Optional) Runs on the map's viewreset event.

Returns

void

Inherited from

RendererBase._onViewReset


_onZoomEnd()

protected _onZoomEnd(): void

Defined in: leaflet/vector/renderer.ts:62

(Optional) Runs on the map's zoomend event.

Returns

void

Inherited from

RendererBase._onZoomEnd


_resizeContainer()

protected _resizeContainer(): Point

Defined in: leaflet/vector/svg_renderer.ts:87

The base implementation resizes the container (based on the map's size and taking into account the padding), returning the new size in CSS pixels.

Subclass implementations shall reset container parameters and data structures as needed.

Returns

Point

Overrides

RendererBase._resizeContainer


addEventParent()

addEventParent(obj: LeafletEvented): this

Defined in: leaflet/leaflet_evented.ts:577

Adds an event parent - an Evented that will receive propagated events.

Parameters

Parameter Type
obj LeafletEvented

Returns

this

Inherited from

RendererBase.addEventParent


bindPopup()

bindPopup(content: Popup | OverlayContent, options?: PopupOptions): this

Defined in: leaflet/layer.ts:295

Binds a popup to the layer with the passed content and sets up the necessary event listeners. If a Function is passed it will receive the layer as the first argument and should return a String or HTMLElement.

Parameters

Parameter Type
content Popup | OverlayContent
options? PopupOptions

Returns

this

Inherited from

RendererBase.bindPopup


bindTooltip()

bindTooltip(content: Tooltip | OverlayContent | (layer: Layer) => OverlayContent, options?: TooltipOptions): this

Defined in: leaflet/layer.ts:429

Binds a tooltip to the layer with the passed content and sets up the necessary event listeners. If a Function is passed it will receive the layer as the first argument and should return a String or HTMLElement.

Parameters

Parameter Type
content Tooltip | OverlayContent | (layer: Layer) => OverlayContent
options? TooltipOptions

Returns

this

Inherited from

RendererBase.bindTooltip


closePopup()

closePopup(): this

Defined in: leaflet/layer.ts:332

Closes the popup bound to this layer if it is open.

Returns

this

Inherited from

RendererBase.closePopup


closeTooltip()

closeTooltip(): this

Defined in: leaflet/layer.ts:529

Closes the tooltip bound to this layer if it is open.

Returns

this

Inherited from

RendererBase.closeTooltip


fire()

fire(type: "loaded" | keyof LeafletEventHandlerFnMap | "contentupdate" | "addpoint" | "addline" | "addlayer" | "tileloaded" | "beforetiledeleted" | "alltilesloaded", data?: object, propagate?: boolean): this

Defined in: leaflet/leaflet_evented.ts:415

Fires an event of the specified type. You can optionally provide a data object — the first argument of the listener function will contain its properties. The event can optionally be propagated to event parents. The data argument may optionally include the sourceTarget property that is passed to the event.

Parameters

Parameter Type
type "loaded" | keyof LeafletEventHandlerFnMap | "contentupdate" | "addpoint" | "addline" | "addlayer" | "tileloaded" | "beforetiledeleted" | "alltilesloaded"
data? object
propagate? boolean

Returns

this

Inherited from

RendererBase.fire


getAttribution()?

optional getAttribution(): string

Defined in: leaflet/layer.ts:206

Classes deriving from Layer may implement this method. This optional method should return a string containing HTML to be shown on the MapLibre Attribution control whenever the layer is visible.

Returns

string

Inherited from

RendererBase.getAttribution


getBounds()?

optional getBounds(): LatLngBounds

Defined in: leaflet/layer.ts:675

Optionally implemented by child classes.

Returns

LatLngBounds

Inherited from

RendererBase.getBounds


getCenter()?

optional getCenter(): LatLng

Defined in: leaflet/layer.ts:685

Optionally implemented by child classes.

Returns

LatLng

Inherited from

RendererBase.getCenter


getLatLng()?

optional getLatLng(): LatLng

Defined in: leaflet/layer.ts:680

Optionally implemented by child classes.

Returns

LatLng

Inherited from

RendererBase.getLatLng


getPane()

getPane(name?: string): HTMLElement

Defined in: leaflet/layer.ts:154

Returns the HTMLElement representing the named pane on the map. If name is omitted, returns the pane for this layer.

Parameters

Parameter Type
name? string

Returns

HTMLElement

Inherited from

RendererBase.getPane


getPopup()

getPopup(): Popup

Defined in: leaflet/layer.ts:369

Returns the popup bound to this layer.

Returns

Popup

Inherited from

RendererBase.getPopup


getTooltip()

getTooltip(): Tooltip

Defined in: leaflet/layer.ts:566

Returns the tooltip bound to this layer.

Returns

Tooltip

Inherited from

RendererBase.getTooltip


isPopupOpen()

isPopupOpen(): boolean

Defined in: leaflet/layer.ts:352

Returns true if the popup bound to this layer is currently open.

Returns

boolean

Inherited from

RendererBase.isPopupOpen


isTooltipOpen()

isTooltipOpen(): boolean

Defined in: leaflet/layer.ts:549

Returns true if the tooltip bound to this layer is currently open.

Returns

boolean

Inherited from

RendererBase.isTooltipOpen


listens()

Call Signature

listens(type: string, propagate?: boolean): boolean

Defined in: leaflet/leaflet_evented.ts:456

Returns true if a particular event type has any listeners attached to it. The verification can optionally be propagated, it will return true if parents have the listener attached to it.

Parameters
Parameter Type
type string
propagate? boolean
Returns

boolean

Inherited from

RendererBase.listens

Call Signature

listens(type: string, fn: Function, context?: object, propagate?: boolean): boolean

Defined in: leaflet/leaflet_evented.ts:457

Returns true if a particular event type has any listeners attached to it. The verification can optionally be propagated, it will return true if parents have the listener attached to it.

Parameters
Parameter Type
type string
fn Function
context? object
propagate? boolean
Returns

boolean

Inherited from

RendererBase.listens

Call Signature

listens(type: string, fn: boolean | Function, context: object, propagate: boolean): boolean

Defined in: leaflet/leaflet_evented.ts:458

Returns true if a particular event type has any listeners attached to it. The verification can optionally be propagated, it will return true if parents have the listener attached to it.

Parameters
Parameter Type
type string
fn boolean | Function
context object
propagate boolean
Returns

boolean

Inherited from

RendererBase.listens


once()

Call Signature

once<T>(type: T, fn: LeafletGlEventHandlerFnMap[T], context?: object): this

Defined in: leaflet/leaflet_evented.ts:543

Behaves as on, except the listener will only get fired once and then removed.

Type Parameters
Type Parameter
T extends "loaded" | keyof LeafletEventHandlerFnMap | "contentupdate" | "addpoint" | "addline" | "addlayer" | "tileloaded" | "beforetiledeleted" | "alltilesloaded"
Parameters
Parameter Type
type T
fn LeafletGlEventHandlerFnMap[T]
context? object
Returns

this

Inherited from

RendererBase.once

Call Signature

once(types: LeafletGlEventHandlerFnMap, context?: object): this

Defined in: leaflet/leaflet_evented.ts:548

Behaves as on, except the listener will only get fired once and then removed.

Parameters
Parameter Type
types LeafletGlEventHandlerFnMap
context? object
Returns

this

Inherited from

RendererBase.once


openPopup()

openPopup(latlng?: LatLngExpression): this

Defined in: leaflet/layer.ts:317

Opens the bound popup at the specified latlng or at the default popup anchor if no latlng is passed.

Parameters

Parameter Type
latlng? LatLngExpression

Returns

this

Inherited from

RendererBase.openPopup


openTooltip()

openTooltip(latlng?: LatLng): this

Defined in: leaflet/layer.ts:509

Opens the bound tooltip at the specified latlng or at the default tooltip anchor if no latlng is passed.

Parameters

Parameter Type
latlng? LatLng

Returns

this

Inherited from

RendererBase.openTooltip


remove()

remove(): this

Defined in: leaflet/layer.ts:131

Removes the layer from the map it is currently active on.

Returns

this

Inherited from

RendererBase.remove


removeEventParent()

removeEventParent(obj: LeafletEvented): this

Defined in: leaflet/leaflet_evented.ts:586

Removes an event parent, so it will stop receiving propagated events.

Parameters

Parameter Type
obj LeafletEvented

Returns

this

Inherited from

RendererBase.removeEventParent


removeFrom()

Call Signature

removeFrom(map: LeafletGlMap): this

Defined in: leaflet/layer.ts:141

Removes the layer from the given map or LayerGroup.

Parameters
Parameter Type
map LeafletGlMap
Returns

this

Inherited from

RendererBase.removeFrom

Call Signature

removeFrom(layerGroup: LayerGroup): this

Defined in: leaflet/layer.ts:142

Removes the layer from the given map or LayerGroup.

Parameters
Parameter Type
layerGroup LayerGroup
Returns

this

Inherited from

RendererBase.removeFrom

Call Signature

removeFrom(obj: LeafletGlMap | LayerGroup): this

Defined in: leaflet/layer.ts:143

Removes the layer from the given map or LayerGroup.

Parameters
Parameter Type
obj LeafletGlMap | LayerGroup
Returns

this

Inherited from

RendererBase.removeFrom


setPopupContent()

setPopupContent(content: OverlayContent): this

Defined in: leaflet/layer.ts:359

Sets the content of the popup bound to this layer.

Parameters

Parameter Type
content OverlayContent

Returns

this

Inherited from

RendererBase.setPopupContent


setStyle()?

optional setStyle(style: LayerStyle): this

Defined in: leaflet/layer.ts:195

Optional styling function for GeoJSNON.

Parameters

Parameter Type
style LayerStyle

Returns

this

Inherited from

RendererBase.setStyle


setTooltipContent()

setTooltipContent(content: OverlayContent): this

Defined in: leaflet/layer.ts:556

Sets the content of the tooltip bound to this layer.

Parameters

Parameter Type
content OverlayContent

Returns

this

Inherited from

RendererBase.setTooltipContent


togglePopup()

togglePopup(): this

Defined in: leaflet/layer.ts:342

Opens or closes the popup bound to this layer depending on its current state.

Returns

this

Inherited from

RendererBase.togglePopup


toggleTooltip()

toggleTooltip(): this

Defined in: leaflet/layer.ts:539

Opens or closes the tooltip bound to this layer depending on its current state.

Returns

this

Inherited from

RendererBase.toggleTooltip


unbindPopup()

unbindPopup(): this

Defined in: leaflet/layer.ts:276

Removes the popup previously bound with bindPopup.

Returns

this

Inherited from

RendererBase.unbindPopup


unbindTooltip()

unbindTooltip(): this

Defined in: leaflet/layer.ts:455

Removes the tooltip previously bound with bindTooltip.

Returns

this

Inherited from

RendererBase.unbindTooltip

Properties

feature?

optional feature: Feature<Geometry, {[name: string]: any; }>

Defined in: leaflet/layer.ts:200

Optional geojson feature.

Inherited from

RendererBase.feature