Skip to content

Commit b2281f9

Browse files
docs: improve documentation (#411)
Various small fixes: broken links, wrong option descriptions, grammar/typos, outdated Leaflet version references, rename `LICENSE` to `LICENSE.md`, and a note that `onLocationError` fires independently of Leaflet's `locationerror` event.
1 parent 6ad0cd6 commit b2281f9

File tree

2 files changed

+23
-21
lines changed

2 files changed

+23
-21
lines changed

LICENSE renamed to LICENSE.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
The MIT License (MIT)
1+
# The MIT License (MIT)
22

3-
Copyright (c) 2014 Dominik Moritz
3+
Copyright © 2014 Dominik Moritz
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# <img src="favicon.svg" alt="Leaflet.Locate logo" width="40" height="40" align="top"> Leaflet.Locate
22

3-
[![npm version](https://badge.fury.io/js/leaflet.locatecontrol.svg)](http://badge.fury.io/js/leaflet.locatecontrol)
3+
[![npm version](https://badge.fury.io/js/leaflet.locatecontrol.svg)](https://badge.fury.io/js/leaflet.locatecontrol)
44
[![jsDelivr Hits](https://data.jsdelivr.com/v1/package/npm/leaflet.locatecontrol/badge?style=rounded)](https://www.jsdelivr.com/package/npm/leaflet.locatecontrol)
55

6-
A useful control to geolocate the user with many options. Official [Leaflet](http://leafletjs.com/plugins.html#geolocation) and [MapBox plugin](https://www.mapbox.com/mapbox.js/example/v1.0.0/leaflet-locatecontrol/).
6+
A useful control to geolocate the user with many options. Official [Leaflet](https://leafletjs.com/plugins.html#geolocation) and [MapBox plugin](https://www.mapbox.com/mapbox.js/example/v1.0.0/leaflet-locatecontrol/).
77

8-
Tested with [Leaflet](https://leafletjs.com/) 1.9.2 and [Mapbox.js](https://docs.mapbox.com/mapbox.js/) 3.3.1 in Firefox, Chrome and Safari.
8+
Tested with [Leaflet](https://leafletjs.com/) 1.9.x and 2.x and [Mapbox.js](https://docs.mapbox.com/mapbox.js/) 3.3.1 in Firefox, Chrome and Safari.
99

1010
Please check for [breaking changes in the changelog](https://github.com/domoritz/leaflet-locatecontrol/blob/gh-pages/CHANGELOG.md).
1111

@@ -73,15 +73,15 @@ Then use `new LocateControl()` instead of `L.control.locate()`.
7373

7474
#### Add the following snippet to your map initialization
7575

76-
This snippet adds the control to the map. You can pass also pass a configuration.
76+
This snippet adds the control to the map. You can also pass a configuration.
7777

7878
```js
7979
L.control.locate().addTo(map);
8080
```
8181

8282
### Possible options
8383

84-
The locate controls inherits options from [Leaflet Controls](https://leafletjs.com/reference.html#control).
84+
The locate control inherits options from [Leaflet Controls](https://leafletjs.com/reference.html#control).
8585

8686
To customize the control, pass an object with your custom options to the locate control.
8787

@@ -95,9 +95,9 @@ Possible options are listed in the following table. More details are [in the cod
9595
| Option | Type | Description | Default |
9696
|------------|-----------|-------------------|----------|
9797
| `position` | `string` | Position of the control | `topleft` |
98-
| `layer` | [`ILayer`](http://leafletjs.com/reference.html#ilayer) | The layer that the user's location should be drawn on. | a new layer |
98+
| `layer` | [`Layer`](https://leafletjs.com/reference.html#layer) | The layer that the user's location should be drawn on. | a new layer |
9999
| `setView` | `boolean` or `string` | Set the map view (zoom and pan) to the user's location as it updates. Options are `false`, `'once'`, `'always'`, `'untilPan'`, or `'untilPanOrZoom'` | `'untilPanOrZoom'` |
100-
| `flyTo` | `boolean` | Smooth pan and zoom to the location of the marker. Only works in Leaflet 1.0+. | `false` |
100+
| `flyTo` | `boolean` | Smooth pan and zoom to the location of the marker. | `false` |
101101
| `keepCurrentZoomLevel` | `boolean` or `Array` | Only pan when setting the view. Set to `true` to always keep the current zoom, or provide a zoom range like `[13, 18]` to only keep the zoom when it's within that range. Outside the range, the map will zoom normally. | `false` |
102102
| `initialZoomLevel` | `false` or `integer` | After activating the plugin by clicking on the icon, zoom to the selected zoom level, even when keepCurrentZoomLevel is true. Set to `false` to disable this feature. | `false` |
103103
| `clickBehavior` | `object` | What to do when the user clicks on the control. Has three options `inView`, `inViewNotFollowing` and `outOfView`. Possible values are `stop` and `setView`, or the name of a behaviour to inherit from. | `{inView: 'stop', outOfView: 'setView', inViewNotFollowing: 'inView'}` |
@@ -107,13 +107,13 @@ Possible options are listed in the following table. More details are [in the cod
107107
| `drawCircle` | `boolean` | If set, a circle that shows the location accuracy is drawn. | `true` |
108108
| `drawMarker` | `boolean` | If set, the marker at the users' location is drawn. | `true` |
109109
| `markerClass` | `class` | The class to be used to create the marker. | `LocationMarker` |
110-
| `compassClass` | `class` | The class to be used to create the marker. | `CompassMarker` |
111-
| `circleStyle` | [`Path options`](http://leafletjs.com/reference.html#path-options) | Accuracy circle style properties. | see code |
112-
| `markerStyle` | [`Path options`](http://leafletjs.com/reference.html#path-options) | Inner marker style properties. Only works if your marker class supports `setStyle`. | see code |
113-
| `compassStyle` | [`Path options`](http://leafletjs.com/reference.html#path-options) | Triangle compass heading marker style properties. Only works if your marker class supports `setStyle`. | see code |
114-
| `followCircleStyle` | [`Path options`](http://leafletjs.com/reference.html#path-options) | Changes to the accuracy circle while following. Only need to provide changes. | `{}` |
115-
| `followMarkerStyle` | [`Path options`](http://leafletjs.com/reference.html#path-options) | Changes to the inner marker while following. Only need to provide changes. | `{}` |
116-
| `followCompassStyle` | [`Path options`](http://leafletjs.com/reference.html#path-options) | Changes to the compass marker while following. Only need to provide changes. | `{}` |
110+
| `compassClass` | `class` | The class to be used to create the compass marker. | `CompassMarker` |
111+
| `circleStyle` | [`Path options`](https://leafletjs.com/reference.html#path) | Accuracy circle style properties. | see code |
112+
| `markerStyle` | [`Path options`](https://leafletjs.com/reference.html#path) | Inner marker style properties. Only works if your marker class supports `setStyle`. | see code |
113+
| `compassStyle` | [`Path options`](https://leafletjs.com/reference.html#path) | Triangle compass heading marker style properties. Only works if your marker class supports `setStyle`. | see code |
114+
| `followCircleStyle` | [`Path options`](https://leafletjs.com/reference.html#path) | Changes to the accuracy circle while following. Only need to provide changes. | `{}` |
115+
| `followMarkerStyle` | [`Path options`](https://leafletjs.com/reference.html#path) | Changes to the inner marker while following. Only need to provide changes. | `{}` |
116+
| `followCompassStyle` | [`Path options`](https://leafletjs.com/reference.html#path) | Changes to the compass marker while following. Only need to provide changes. | `{}` |
117117
| `icon` | `string` | The CSS class for the icon. | `leaflet-control-locate-location-arrow` |
118118
| `iconLoading` | `string` | The CSS class for the icon while loading. | `leaflet-control-locate-spinner` |
119119
| `iconElementTag` | `string` | The element to be created for icons. | `span` |
@@ -124,10 +124,10 @@ Possible options are listed in the following table. More details are [in the cod
124124
| `onLocationError` | `function` | Called on location errors. Receives the error and the control instance. | see code |
125125
| `metric` | `boolean` | Use metric units. | `true` |
126126
| `onLocationOutsideMapBounds` | `function` | Called when the user's location is outside the bounds set on the map. Called repeatedly when the user's location changes. | see code |
127-
| `showPopup` | `boolean` | Display a pop-up when the user click on the inner marker. | `true` |
127+
| `showPopup` | `boolean` | Display a pop-up when the user clicks on the inner marker. | `true` |
128128
| `strings` | `object` | Strings used in the control. Options are `title`, `text`, `metersUnit`, `feetUnit`, `popup` and `outsideMapBoundsMsg` | see code |
129129
| `strings.popup` | `string` or `function` | The string shown as popup. May contain the placeholders `{distance}`, `{unit}`, `{lat}`, `{lng}`, `{altitude}`, `{speed}` (in m/s), and `{heading}` (in degrees). If this option is specified as function, it will be executed with a single parameter `{distance, unit, lat, lng, altitude, speed, heading}` and expected to return a string. | see code |
130-
| `locateOptions` | [`Locate options`](https://leafletjs.com/reference.html#locate-options) | The default options passed to leaflets locate method. | see code |
130+
| `locateOptions` | [`Locate options`](https://leafletjs.com/reference.html#locate-options) | The default options passed to Leaflet's locate method. | see code |
131131
<!-- prettier-ignore-end -->
132132

133133
For example, to customize the position and the title, you could write
@@ -192,7 +192,7 @@ You can keep the plugin active but stop following using `lc.stopFollowing()`.
192192

193193
### Events
194194

195-
You can leverage the native Leaflet events `locationfound` and `locationerror` to handle when geolocation is successful or produces an error. You can find out more about these events in the [Leaflet documentation](https://leafletjs.com/examples/mobile/#geolocation).
195+
You can leverage the native Leaflet events `locationfound` and `locationerror` to handle when geolocation is successful or produces an error. You can find out more about these events in the [Leaflet documentation](https://leafletjs.com/examples/mobile/#geolocation). Note that the control's `onLocationError` callback (which shows a browser `alert()` by default) fires independently of the `locationerror` event — override it to suppress the alert.
196196

197197
Additionally, the locate control fires the following events on the map object:
198198

@@ -312,7 +312,7 @@ Run `npm run lint:fix` to automatically fix style and linting issues.
312312

313313
1. Update `CHANGELOG.md` with the changes for the new version and commit: `git commit -am "chore: update changelog"`
314314
2. Run `npm run bump:minor` or `npm run bump:patch` (automatically bumps the version in `package.json`, runs lint, tests, and build, then stages the `dist/` files)
315-
3. Review what will be released: `git log $(git describe --tags --abbrev=0 HEAD~1)..HEAD --oneline`
315+
3. Review what will be released: `git log $(git describe --tags --abbrev=0)..HEAD --oneline`
316316
4. `git push && git push --tags`
317317
5. `npm publish`
318318

@@ -327,6 +327,8 @@ To all [contributors](https://github.com/domoritz/leaflet-locatecontrol/contribu
327327

328328
## License
329329

330-
MIT
330+
This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details.
331+
332+
## Attributions
331333

332334
SVG icons from [Font Awesome v5.15.4](https://github.com/FortAwesome/Font-Awesome/releases/tag/5.15.4): [Creative Commons Attribution 4.0](https://fontawesome.com/license/free)

0 commit comments

Comments
 (0)