You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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.
41
46
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`.
43
60
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.
45
62
46
63
When clicked, the control emits a Leaflet event `clicked` with a single data property, `idx`: zero-based index of an action that was selected.
var btn =L.functionButtons([{ content:'Saint-Petersburg' }, { content:'Hide buttons'}]);
@@ -61,10 +78,6 @@ map.addControl(btn);
61
78
62
79
<divclass="map"id="mapfb"></div>
63
80
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
-
68
81
## L.StaticLayerSwitcher
69
82
70
83
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
82
95
| `bgColor` | String | `'white'` | Background CSS color of a layer switcher.
83
96
| `selectedColor` | String | `#ddd` | Background CSS color of a selected layer line.
84
97
| `editable` | Boolean | `false` | Whether a user can move and delete layers.
98
+
| `enforceOSM` | Boolean | `false` | Whether the first layer should be OSM-based.
85
99
86
100
Those methods can be used to get and manipulate layers in a layer switcher:
87
101
@@ -90,7 +104,7 @@ Those methods can be used to get and manipulate layers in a layer switcher:
90
104
*`<ILayer> getSelectedLayer()`: returns a currently selected layer.
91
105
*`<String> getSelectedLayerId()`: returns an identifier of a currently selected layer.
92
106
*`<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.
94
108
*`<ILayer> removeLayer( <ILayer> layer )`: Removes a layer from the list. Returns a layer that was removed, or `null` if operation failed.
95
109
*` moveLayer( <ILayer> layer, <Boolean> moveDown )`: moves a layer in the list either up or down.
96
110
@@ -101,7 +115,7 @@ When active, the layer switcher emits following Leaflet events:
101
115
| `selectionchanged` | `{ <ILayer> selected, <String> selectedId }` | A user has changed active layer.
102
116
| `layerschanged` | `{ <String[]> layerIds }` | List of layers has been changed (only when it is editable).
@@ -122,7 +136,10 @@ The object has some methods to simplify working with the layer list:
122
136
*`<String[]> getSortedKeys()`: returns a sorted list of layer keys (every key is essentially a human-readable label).
123
137
*`<Boolean> requiresKey( <String> id )`: checks if the layer for a given id requires a developer key.
124
138
*`<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).
@@ -140,7 +157,7 @@ Every search control on the Leaflet plugins page has flaws. This is an attempt o
140
157
*`title`: title text on the control.
141
158
*`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.
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.
175
193
176
194
An option `attributionEditLink` is added to `L.Map` class. If it is set to `true`, OSM links will be followed by an edit link.
0 commit comments