Skip to content

Commit

Permalink
Generate API documentation using TypeDoc
Browse files Browse the repository at this point in the history
  • Loading branch information
simon04 committed Nov 27, 2020
1 parent 812b149 commit 756ae93
Show file tree
Hide file tree
Showing 21 changed files with 444 additions and 160 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
bundle.js
demo-*/package-lock.json
dist/
docs/
node_modules/
146 changes: 2 additions & 144 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ The plugin supports many different data providers:
- [HERE Geocoder API](https://developer.here.com/documentation/geocoder/topics/introduction.html)
- [Neutrino API](https://www.neutrinoapi.com/api/geocode-address/)
- [Plus codes](https://plus.codes/) (formerly OpenLocationCode) (requires [open-location-code](https://www.npmjs.com/package/open-location-code))
- [ArcGIS](https://developers.arcgis.com/features/geocoding/)

The plugin can easily be extended to support other providers. Current extensions:

Expand Down Expand Up @@ -84,147 +85,4 @@ var geocoder = L.Control.geocoder({
This will add a polygon representing the result's boundingbox when a result is selected.

# API

## L.Control.Geocoder

This is the geocoder control. It works like any other Leaflet control, and is added to the map.

### Constructor

This plugin supports the standard JavaScript constructor (to be invoked using `new`) as well as the [class factory methods](https://leafletjs.com/reference.html#class-class-factories) known from Leaflet:

```js
new L.Control.Geocoder(options);
// or
L.Control.geocoder(options);
```

### Options

| Option | Type | Default | Description |
| ------------------ | --------- | ------------------------------------ | ------------------------------------------------------------------------------------------------------------- |
| `collapsed` | Boolean | `true` | Collapse control unless hovered/clicked |
| `expand` | String | `"touch"` | How to expand a collapsed control: `touch` or `click` or `hover` |
| `position` | String | `"topright"` | Control [position](https://leafletjs.com/reference.html#control-positions) |
| `placeholder` | String | `"Search..."` | Placeholder text for text input |
| `errorMessage` | String | `"Nothing found."` | Message when no result found / geocoding error occurs |
| `iconLabel` | String | `"Initiate a new search"` | Accessibility label for the search icon used by screen readers |
| `geocoder` | IGeocoder | `new L.Control.Geocoder.Nominatim()` | Object to perform the actual geocoding queries |
| `showUniqueResult` | Boolean | `true` | Immediately show the unique result without prompting for alternatives |
| `showResultIcons` | Boolean | `false` | Show icons for geocoding results (if available); supported by Nominatim |
| `suggestMinLength` | Number | `3` | Minimum number characters before suggest functionality is used (if available from geocoder) |
| `suggestTimeout` | Number | `250` | Number of milliseconds after typing stopped before suggest functionality is used (if available from geocoder) |
| `query` | String | `""` | Initial query string for text input |
| `queryMinLength` | Number | `1` | Minimum number of characters in search text before performing a query |

### Methods

| Method | Returns | Description |
| --------------------------------------- | ------- | --------------------------------------- |
| `markGeocode(<GeocodingResult> result)` | `this` | Marks a geocoding result on the map |
| `setQuery(<String> query)` | `this` | Sets the query string on the text input |

## L.Control.Geocoder.Nominatim

Uses [Nominatim](https://wiki.openstreetmap.org/wiki/Nominatim) to respond to geocoding queries. This is the default
geocoding service used by the control, unless otherwise specified in the options. Implements `IGeocoder`.

Unless using your own Nominatim installation, please refer to the [Nominatim usage policy](https://operations.osmfoundation.org/policies/nominatim/).

### Constructor

```js
new L.Control.Geocoder.Nominatim(options);
// or
L.Control.Geocoder.nominatim(options);
```

### Options

| Option | Type | Default | Description |
| ---------------------- | -------- | ---------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `serviceUrl` | String | `"https://nominatim.openstreetmap.org/"` | URL of the service |
| `geocodingQueryParams` | Object | `{}` | Additional URL parameters (strings) that will be added to geocoding requests; can be used to restrict results to a specific country for example, by providing the [`countrycodes`](https://wiki.openstreetmap.org/wiki/Nominatim#Parameters) parameter to Nominatim |
| `reverseQueryParams` | Object | `{}` | Additional URL parameters (strings) that will be added to reverse geocoding requests |
| `htmlTemplate` | function | special | A function that takes an GeocodingResult as argument and returns an HTML formatted string that represents the result. Default function breaks up address in parts from most to least specific, in attempt to increase readability compared to Nominatim's naming |

## L.Control.Geocoder.Bing

Uses [Bing Locations API](http://msdn.microsoft.com/en-us/library/ff701715.aspx) to respond to geocoding queries. Implements `IGeocoder`.

Note that you need an API key to use this service.

### Constructor

```ts
new L.Control.Geocoder.Bing(options);
// or
L.Control.Geocoder.bing(options);
```

## L.Control.Geocoder.OpenCage

Uses [OpenCage Data API](https://opencagedata.com/) to respond to geocoding queries. Implements `IGeocoder`.

Note that you need an API key to use this service.

### Constructor

```ts
new L.Control.Geocoder.OpenCage(options);
// or
L.Control.Geocoder.opencage(options);
```

### Options

| Option | Type | Default | Description |
| ---------------------- | ------ | ------------------------------------------------ | ------------------------------------------------------------------------------------ |
| `serviceUrl` | String | `"https://api.opencagedata.com/geocode/v1/json"` | URL of the service |
| `geocodingQueryParams` | Object | `{}` | Additional URL parameters (strings) that will be added to geocoding requests |
| `reverseQueryParams` | Object | `{}` | Additional URL parameters (strings) that will be added to reverse geocoding requests |

## L.Control.Geocoder.LatLng

Parses basic latitude/longitude strings such as `'50.06773 14.37742'`, `'N50.06773 W14.37742'`, `'S 50° 04.064 E 014° 22.645'`, or `'S 50° 4′ 03.828″, W 14° 22′ 38.712″'`.

### Constructor

```ts
new L.Control.Geocoder.LatLng(options);
// or
L.Control.Geocoder.latLng(options);
```

### Options

| Option | Type | Default | Description |
| -------------- | --------- | ------- | --------------------------------------------------------- |
| `next` | IGeocoder | | The next geocoder to use for non-supported queries. |
| `sizeInMeters` | Number | 10000 | The size in meters used for passing to `LatLng.toBounds`. |

## IGeocoder

An interface implemented to respond to geocoding queries.

### Methods

| Method | Returns | Description |
| ----------------------------------------------------------------- | ------------------- | --------------------------------------------------------------------------------------------------------------------------------- |
| `geocode(<String> query, callback, context)` | `GeocodingResult[]` | Performs a geocoding query and returns the results to the callback in the provided context |
| `suggest(<String> query, callback, context)` | `GeocodingResult[]` | Performs a geocoding query suggestion (this happens while typing) and returns the results to the callback in the provided context |
| `reverse(<L.LatLng> location, <Number> scale, callback, context)` | `GeocodingResult[]` | Performs a reverse geocoding query and returns the results to the callback in the provided context |

## GeocodingResult

An object that represents a result from a geocoding query.

### Properties

| Property | Type | Description |
| -------- | -------------- | ---------------------------------------------------- |
| `name` | String | Name of found location |
| `bbox` | L.LatLngBounds | The bounds of the location |
| `center` | L.LatLng | The center coordinate of the location |
| `icon` | String | URL for icon representing result; optional |
| `html` | String | (optional) HTML formatted representation of the name |
→ docs/
107 changes: 107 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"build:demo-rollup": "cd demo-rollup && npm install && npm run build",
"build:demo-webpack": "cd demo-rollup && npm install && npm run build",
"changelog": "conventional-changelog --infile CHANGELOG.md --same-file --output-unreleased",
"doc": "typedoc --excludePrivate --stripInternal --moduleResolution node --out docs/ src/",
"test": "jest",
"lint": "eslint --ext .js,.ts ."
},
Expand Down Expand Up @@ -74,6 +75,7 @@
"rollup-plugin-terser": "^5.3.0",
"ts-jest": "^26.4.4",
"tslib": "^1.11.1",
"typedoc": "^0.19.2",
"typescript": "^3.8.3"
},
"optionalDependencies": {
Expand Down
Loading

0 comments on commit 756ae93

Please sign in to comment.