SVG
Although SVG is not available on IE7 and IE8, these browsers support VML, and the SVG renderer will fall back to VML in this case. VML was deprecated in 2012, which means VML functionality exists only for backwards compatibility with old versions of Internet Explorer.
Allows vector layers to be displayed with SVG.
Inherits Renderer
.
Due to technical limitations, SVG is not
available in all web browsers, notably Android 2.x and 3.x.
Although SVG is not available on IE7 and IE8, these browsers support
VML
(a now deprecated technology), and the SVG renderer will fall back to VML in
this case.
Usage example
Use SVG by default for all paths in the map:
var map = L.map('map', {
renderer: L.svg();
});
Use a SVG renderer with extra padding for specific vector geometries:
var map = L.map('map');
var myRenderer = L.svg({ padding: 0.5 });
var line = L.polyline( coordinates, { renderer: myRenderer } );
var circle = L.circle( center, { renderer: myRenderer } );
Creation
Factory | Description |
---|---|
L.svg( |
Creates a SVG renderer with the given options. |
Options
Option | Type | Default | Description |
---|---|---|---|
padding |
Number
| 0.1 |
How much to extend the clip area around the map view (relative to its size) e.g. 0.1 would be 10% of map view in each direction |
Option | Type | Default | Description |
---|---|---|---|
pane |
String
| 'overlayPane' |
By default the layer will be added to the map's overlay pane. Overriding this option will cause the layer to be placed on another pane by default. |
Events
Event | Data | Description |
---|---|---|
update
|
Event | Data | Description |
---|---|---|
popupopen
| ||
popupclose
|
Event | Data | Description |
---|---|---|
tooltipopen
| ||
tooltipclose
|
Methods
Method | Returns | Description |
---|---|---|
bindPopup( |
this |
Binds a popup to the layer with the passed |
unbindPopup() |
this |
Removes the popup previously bound with |
openPopup( |
this |
Opens the bound popup at the specificed |
closePopup() |
this |
Closes the popup bound to this layer if it is open. |
togglePopup() |
this |
Opens or closes the popup bound to this layer depending on its current state. |
isPopupOpen() |
boolean |
Returns |
setPopupContent( |
this |
Sets the content of the popup bound to this layer. |
getPopup() |
Popup |
Returns the popup bound to this layer. |
Method | Returns | Description |
---|---|---|
bindTooltip( |
this |
Binds a tooltip to the layer with the passed |
unbindTooltip() |
this |
Removes the tooltip previously bound with |
openTooltip( |
this |
Opens the bound tooltip at the specificed |
closeTooltip() |
this |
Closes the tooltip bound to this layer if it is open. |
toggleTooltip() |
this |
Opens or closes the tooltip bound to this layer depending on its current state. |
isTooltipOpen() |
boolean |
Returns |
setTooltipContent( |
this |
Sets the content of the tooltip bound to this layer. |
getTooltip() |
Tooltip |
Returns the tooltip bound to this layer. |
Method | Returns | Description |
---|---|---|
addTo( |
this |
Adds the layer to the given map |
remove() |
this |
Removes the layer from the map it is currently active on. |
removeFrom( |
this |
Removes the layer from the given map |
getPane( |
HTMLElement |
Returns the |
Method | Returns | Description |
---|---|---|
on( |
this |
Adds a listener function ( |
on( |
this |
Adds a set of type/listener pairs, e.g. |
off( |
this |
Removes a previously added listener function. If no function is specified, it will remove all the listeners of that particular event from the object. Note that if you passed a custom context to |
off( |
this |
Removes a set of type/listener pairs. |
off() |
this |
Removes all listeners to all events on the object. |
fire( |
this |
Fires an event of the specified type. You can optionally provide an data object — the first argument of the listener function will contain its properties. The event might can optionally be propagated to event parents. |
listens( |
Boolean |
Returns |
once(…) |
this |
Behaves as |
addEventParent( |
this |
Adds an event parent - an |
removeEventParent( |
this |
Removes an event parent, so it will stop receiving propagated events |
addEventListener(…) |
this |
Alias to |
removeEventListener(…) |
this |
Alias to |
clearAllEventListeners(…) |
this |
Alias to |
addOneTimeEventListener(…) |
this |
Alias to |
fireEvent(…) |
this |
Alias to |
hasEventListeners(…) |
Boolean |
Alias to |
Functions
Function | Returns | Description |
---|---|---|
create( |
SVGElement |
Returns a instance of SVGElement, corresponding to the class name passed. For example, using 'line' will return an instance of SVGLineElement. |
pointsToPath( |
String |
Generates a SVG path string for multiple rings, with each ring turning into "M..L..L.." instructions |