Skip to content

Commit d35a300

Browse files
committed
update leaflet plugins reference
1 parent 64eeb45 commit d35a300

3 files changed

Lines changed: 37 additions & 195 deletions

File tree

_includes/plugins-demo.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
// L.PopupIcon
1717
var mappi = createMap('mappi');
18-
mappi.addLayer(L.marker([11, 22], { clickable: false, icon: L.popupIcon("No, you don't have to click me") }));
18+
mappi.addLayer(L.marker([11, 22], { clickable: false, icon: L.popupIcon("No, you don't have to click me", { selectable: true }) }));
1919
mappi.addLayer(L.marker([-20, 100], { icon: L.popupIcon("(but I'm ok with that)") }).bindPopup('Popup on a popup. Oh, the irony.'));
2020

2121
// L.FunctionButtons

leaflet.md

Lines changed: 35 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ A round icon with a white border and text inside. Can be used to display markers
1515
| `color` | String | `'black'` | CSS color of icon background.
1616
| `radius` | Number | `11` | Icon radius.
1717

18-
[Download](https://raw.github.com/MapBBCode/mapbbcode/master/src/LetterIcon.js)
18+
[Download](https://raw.github.com/MapBBCode/mapbbcode/master/src/controls/LetterIcon.js)
1919

2020
```javascript
2121
L.marker([11, 22], { icon: L.letterIcon('Big', { radius: 20 }), clickable: false }).addTo(map);
@@ -25,9 +25,14 @@ L.marker([11, 22], { icon: L.letterIcon('Big', { radius: 20 }), clickable: false
2525

2626
## L.PopupIcon
2727

28-
An icon that looks like a popup panel, but significantly smaller. Title should be passed to the constructor. Has only one option: `width` for maximum icon width.
28+
An icon that looks like a popup panel, but significantly smaller. Title should be passed to the constructor.
2929

30-
[Download](https://raw.github.com/MapBBCode/mapbbcode/master/src/PopupIcon.js)
30+
| Option | Type | Default | Description
31+
|---|---|---|---
32+
| `width` | Number | `150` | Maximum icon width.
33+
| `selectable` | Boolean | `false` | If set, text on the icon can be selected, but marker cannot be clicked or dragged.
34+
35+
[Download](https://raw.github.com/MapBBCode/mapbbcode/master/src/controls/PopupIcon.js)
3136

3237
```javascript
3338
L.marker([11, 22], { icon: L.popupIcon("Don't click me"), clickable: false }).addTo(map);
@@ -39,13 +44,25 @@ L.marker([11, 22], { icon: L.popupIcon("Don't click me"), clickable: false }).ad
3944

4045
This control simplifies creating simple Leaflet controls that invoke javascript functions when clicked. It supports multiple actions on one control: in that case they are stacked vertically, like on a standard zoom control.
4146

42-
Class contructor accepts two parameters: an array of labels for actions (strings, image URLs or html elements) and an options object. The latter may contain `titles` array of strings, which would be used as title attributes, and `bgPos` array of [dx, dy] arrays that define offsets for image content. Other options (one option, actually: `position`) are inherited from the [L.Control](http://leafletjs.com/reference.html#control) class.
47+
Class contructor accepts two parameters: an array of button objects and an options object. Button objects can have following properties:
48+
49+
| Property | Type | Description
50+
|---|---|---|---
51+
| `content` | String or Node | A string, image data URL or a component to display inside a button.
52+
| `alt` | String | A string to display in case `content` is empty.
53+
| `title` | String | Title attribute.
54+
| `href` | String | URL for a button. If set, `clicked` events are not generated, the button acts as a regular link.
55+
| `bgColor` | String | CSS color for a button background.
56+
| `imageSize` | Number | Background image size (when `content` is image data URL, the same for width and height, default `26`).
57+
| `bgPos` | Array | Two numbers for `x` and `y` offset of button background image (when `content` is image data URL).
58+
59+
Some function button properties can be updated with `setContent(id, content)`, `setTitle(id, title)`, `setHref(id, href)` and `setBgPos(id, bgPos)` methods. For a single button `id` can be skipped, it defaults to `0`.
4360

44-
An action inside a function button can be updated with `setContent(id, content)` and `setTitle(id, title)` methods. Image content offset can be altered with `setBgPos(id, bgPos)` method.
61+
The only option, `position`, is inherited from the [L.Control](http://leafletjs.com/reference.html#control) class and stores a corner in which the button is displayed.
4562

4663
When clicked, the control emits a Leaflet event `clicked` with a single data property, `idx`: zero-based index of an action that was selected.
4764

48-
[Download](https://raw.github.com/MapBBCode/mapbbcode/master/src/FunctionButton.js)
65+
[Download](https://raw.github.com/MapBBCode/mapbbcode/master/src/controls/FunctionButton.js)
4966

5067
```javascript
5168
var btn = L.functionButtons([{ content: 'Saint-Petersburg' }, { content: 'Hide buttons'}]);
@@ -61,10 +78,6 @@ map.addControl(btn);
6178

6279
<div class="map" id="mapfb"></div>
6380

64-
### L.FunctionButton
65-
66-
This is a subclass of `L.FunctionButtons` designed to work with a single action. It accepts a single object with options in the contructor, its `setContent()`, `setTitle()` and `setBgPos()` methods accept a single parameter.
67-
6881
## L.StaticLayerSwitcher
6982

7083
This control can replace the standard Leaflet layers control. It allows a user to switch layers and, if `editable` property is set, to remove layers and change their order. This control differs from the stanard one in two ways:
@@ -82,6 +95,7 @@ The constructor accepts two parameters. The first one is a layer list, either an
8295
| `bgColor` | String | `'white'` | Background CSS color of a layer switcher.
8396
| `selectedColor` | String | `#ddd` | Background CSS color of a selected layer line.
8497
| `editable` | Boolean | `false` | Whether a user can move and delete layers.
98+
| `enforceOSM` | Boolean | `false` | Whether the first layer should be OSM-based.
8599

86100
Those methods can be used to get and manipulate layers in a layer switcher:
87101

@@ -90,7 +104,7 @@ Those methods can be used to get and manipulate layers in a layer switcher:
90104
* `<ILayer> getSelectedLayer()`: returns a currently selected layer.
91105
* `<String> getSelectedLayerId()`: returns an identifier of a currently selected layer.
92106
* `<ILayer> addLayer( <String> id, <ILayer> layer )`: appends a layer with given id to the end of the layer list. If `layer` is omitted, `window.layerList` is queried for a given `id`. Returns a layer that was added, or `null` if operation failed.
93-
* `<ILayer> updateLayer( <ILayer> layer, <String> id )`: updated an identifier for a layer. In case the layer was created by `window.layerList`, recreates it. Returns a layer, an id for which was updated, or `null` if operation failed.
107+
* `<ILayer> updateId( <ILayer> layer, <String> id )`: updated an identifier for a layer. In case the layer was created by `window.layerList`, recreates it. Returns a layer, an id for which was updated, or `null` if operation failed.
94108
* `<ILayer> removeLayer( <ILayer> layer )`: Removes a layer from the list. Returns a layer that was removed, or `null` if operation failed.
95109
* ` moveLayer( <ILayer> layer, <Boolean> moveDown )`: moves a layer in the list either up or down.
96110

@@ -101,7 +115,7 @@ When active, the layer switcher emits following Leaflet events:
101115
| `selectionchanged` | `{ <ILayer> selected, <String> selectedId }` | A user has changed active layer.
102116
| `layerschanged` | `{ <String[]> layerIds }` | List of layers has been changed (only when it is editable).
103117

104-
[Download](https://raw.github.com/MapBBCode/mapbbcode/master/src/StaticLayerSwitcher.js)
118+
[Download](https://raw.github.com/MapBBCode/mapbbcode/master/src/controls/StaticLayerSwitcher.js)
105119

106120
``` javascript
107121
map.addControl(L.staticLayerSwitcher([
@@ -122,7 +136,10 @@ The object has some methods to simplify working with the layer list:
122136
* `<String[]> getSortedKeys()`: returns a sorted list of layer keys (every key is essentially a human-readable label).
123137
* `<Boolean> requiresKey( <String> id )`: checks if the layer for a given id requires a developer key.
124138
* `<String> getKeyLink( <String> id )`: returns an URL for a developer key required for a layer, or an empty string if there is no URL or the layer does not need a key.
125-
* `<ILayer[]> getLeafletLayers( <String[]> ids, <Leaflet> L )`: converts an array of ids to array of layers ready to be added to a Leaflet map.
139+
* `<String> getLayerName( <String> id )`: return a name for the layer. Processes keys (`'Bing Imagery:87f292f'`) and custom names (`'A mapbox layer|MapBox:key'`).
140+
* `<ILayer> getLeafletLayer( <String> id, <Leaflet> L )`: converts an id to a layer ready to be added to a Leaflet map.
141+
* `<ILayer[]> getLeafletLayers( <String[]> ids, <Leaflet> L )`: converts an array of ids to array of layers ready to be added to a Leaflet map. Enforces the first layer to be OSM-based.
142+
* `<Boolean> isOpenStreetMapLayer( layer )`: check that the layer (either `id` string or `ILayer` object) can be deemed OSM-based (or at least open).
126143

127144
[Download](https://raw.github.com/MapBBCode/mapbbcode/master/src/layers/LayerList.js)
128145

@@ -140,7 +157,7 @@ Every search control on the Leaflet plugins page has flaws. This is an attempt o
140157
* `title`: title text on the control.
141158
* `email`: e-mail address that will be sent to Nominatim server. It can be used for determining a source of suspicious activity. You should use this option, especially if the control is installed on a popular website.
142159

143-
[Download](https://raw.github.com/MapBBCode/mapbbcode/master/src/Leaflet.Search.js)
160+
[Download](https://raw.github.com/MapBBCode/mapbbcode/master/src/controls/Leaflet.Search.js)
144161

145162
``` javascript
146163
map.addControl(L.control.search());
@@ -160,8 +177,9 @@ An export button for maps downloaded from an external service. Gets the supporte
160177
| `codeid` | String | `''` | Identifier of a map to export.
161178
| `types` | String[] | `[]` | List of supported formats (if empty, then it is downloaded).
162179
| `titles` | String[] | `[]` | Titles for supported formats (if empty, then it is downloaded).
180+
| `filter` | String[] | `[]` | If not empty, only types that are in this array are displayed.
163181

164-
[Download](https://raw.github.com/MapBBCode/mapbbcode/master/src/ExportButton.js)
182+
[Download](https://raw.github.com/MapBBCode/mapbbcode/master/src/controls/ExportButton.js)
165183

166184
``` javascript
167185
map.addControl(L.exportControl({ codeid: 'nwrxs' }));
@@ -171,11 +189,11 @@ map.addControl(L.exportControl({ codeid: 'nwrxs' }));
171189

172190
## L.Control.PermalinkAttribution
173191

174-
Replaces `L.Control.Attribution` with itself, so you won't have to do anything besides including the plugin script. Makes OpenStreetMap links in attribution into permanent links to the displayed place on osm.org website.
192+
Replaces `L.Control.Attribution` with itself, so you won't have to do anything besides including the plugin script. Makes OpenStreetMap links in attribution into permanent links to the displayed place on osm.org website. If other attribution links contain `{lat}`, `{lon}` and `{zoom}` substrings, they are replaced with actual coordinates and zoom level.
175193

176194
An option `attributionEditLink` is added to `L.Map` class. If it is set to `true`, OSM links will be followed by an edit link.
177195

178-
[Download](https://raw.github.com/MapBBCode/mapbbcode/master/src/PermalinkAttribution.js)
196+
[Download](https://raw.github.com/MapBBCode/mapbbcode/master/src/controls/PermalinkAttribution.js)
179197

180198
<div class="map" id="mappa"></div>
181199

0 commit comments

Comments
 (0)