Skip to content

Commit

Permalink
Merge branch 'develop' into pr/311
Browse files Browse the repository at this point in the history
  • Loading branch information
smeijer committed Jun 8, 2022
2 parents b32d1bc + 9fe12b2 commit ce19809
Show file tree
Hide file tree
Showing 39 changed files with 2,806 additions and 1,791 deletions.
28 changes: 28 additions & 0 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,34 @@
"contributions": [
"doc"
]
},
{
"login": "grigorpavlov",
"name": "Grigor Pavlov",
"avatar_url": "https://avatars.githubusercontent.com/u/21351616?v=4",
"profile": "https://github.com/grigorpavlov",
"contributions": [
"code"
]
},
{
"login": "missinglink",
"name": "Peter Johnson",
"avatar_url": "https://avatars.githubusercontent.com/u/738069?v=4",
"profile": "https://geocode.earth",
"contributions": [
"code",
"test"
]
},
{
"login": "tsamaya",
"name": "Arnaud Ferrand",
"avatar_url": "https://avatars.githubusercontent.com/u/1741320?v=4",
"profile": "http://about.me/arnaudferrand",
"contributions": [
"doc"
]
}
],
"contributorsPerLine": 7,
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ jobs:
runs-on: ubuntu-latest
needs: [setup]
timeout-minutes: 5
strategy:
matrix:
leaflet: ["1.6.0", "1.7.1", "1.8.0"]
steps:
- uses: actions/checkout@v2

Expand All @@ -96,6 +99,9 @@ jobs:
path: node_modules
key: ${{ runner.os }}-node_modules-${{ hashFiles('**/package-lock.json') }}

- name: install specific leaflet version
run: npm install leaflet@${{ matrix.leaflet }}

- name: unit tests
run: npm run ci:test
env:
Expand Down
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->

[![All Contributors](https://img.shields.io/badge/all_contributors-45-orange.svg?style=flat-square)](#contributors-)
[![All Contributors](https://img.shields.io/badge/all_contributors-48-orange.svg?style=flat-square)](#contributors-)

<!-- ALL-CONTRIBUTORS-BADGE:END -->

Expand Down Expand Up @@ -52,10 +52,12 @@ The control comes with a number of default providers:
- [Algolia]
- [Bing]
- [Esri]
- [Geocode Earth]
- [Google]
- [LocationIQ]
- [OpenCage]
- [OpenStreetMap]
- [Pelias]
- [Mapbox](https://docs.mapbox.com/help/tutorials/local-search-geocoding-api/)
- [GeoApiFR](https://geo.api.gouv.fr/adresse)

Expand Down Expand Up @@ -134,7 +136,7 @@ use your debugger)
# Providers

When `OpenStreetMap` does not match your needs; you can also choose to use the
`Algolia`, `Bing`, `Esri`, `Google` `LocationIQ`, or `OpenCage` providers. Most of those providers do however require API
`Algolia`, `Bing`, `Esri`, `Geocode Earth`, `Google`, `LocationIQ`, `OpenCage`, or `Pelias` providers. Most of those providers do however require API
keys. See the documentation pages on the relevant organisations on how to obtain
these keys.

Expand Down Expand Up @@ -337,10 +339,12 @@ to share your work with us.
[algolia]: https://smeijer.github.io/leaflet-geosearch/providers/algolia
[bing]: https://smeijer.github.io/leaflet-geosearch/providers/bing
[esri]: https://smeijer.github.io/leaflet-geosearch/providers/esri
[geocode earth]: https://smeijer.github.io/leaflet-geosearch/providers/geocode-earth
[google]: https://smeijer.github.io/leaflet-geosearch/providers/google
[locationiq]: https://smeijer.github.io/leaflet-geosearch/providers/locationiq
[opencage]: https://smeijer.github.io/leaflet-geosearch/providers/opencage
[openstreetmap]: https://smeijer.github.io/leaflet-geosearch/providers/openstreetmap
[pelias]: https://smeijer.github.io/leaflet-geosearch/providers/pelias

## Contributors ✨

Expand Down Expand Up @@ -408,6 +412,9 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
<td align="center"><a href="https://github.com/patou"><img src="https://avatars.githubusercontent.com/u/841858?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Patrice De Saint Steban</b></sub></a><br /><a href="https://github.com/smeijer/leaflet-geosearch/commits?author=patou" title="Code">💻</a> <a href="https://github.com/smeijer/leaflet-geosearch/commits?author=patou" title="Documentation">📖</a></td>
<td align="center"><a href="https://github.com/AntoineAA"><img src="https://avatars.githubusercontent.com/u/5539332?v=4?s=100" width="100px;" alt=""/><br /><sub><b>AntoineAA</b></sub></a><br /><a href="https://github.com/smeijer/leaflet-geosearch/commits?author=AntoineAA" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/HolyMarcell"><img src="https://avatars.githubusercontent.com/u/2223520?v=4?s=100" width="100px;" alt=""/><br /><sub><b>HolyMarcell</b></sub></a><br /><a href="https://github.com/smeijer/leaflet-geosearch/commits?author=HolyMarcell" title="Documentation">📖</a></td>
<td align="center"><a href="https://github.com/grigorpavlov"><img src="https://avatars.githubusercontent.com/u/21351616?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Grigor Pavlov</b></sub></a><br /><a href="https://github.com/smeijer/leaflet-geosearch/commits?author=grigorpavlov" title="Code">💻</a></td>
<td align="center"><a href="https://geocode.earth"><img src="https://avatars.githubusercontent.com/u/738069?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Peter Johnson</b></sub></a><br /><a href="https://github.com/smeijer/leaflet-geosearch/commits?author=missinglink" title="Code">💻</a> <a href="https://github.com/smeijer/leaflet-geosearch/commits?author=missinglink" title="Tests">⚠️</a></td>
<td align="center"><a href="http://about.me/arnaudferrand"><img src="https://avatars.githubusercontent.com/u/1741320?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Arnaud Ferrand</b></sub></a><br /><a href="https://github.com/smeijer/leaflet-geosearch/commits?author=tsamaya" title="Documentation">📖</a></td>
</tr>
</table>

Expand Down
2 changes: 2 additions & 0 deletions docs/leaflet-control.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { SearchControl, OpenStreetMapProvider } from 'leaflet-geosearch';

const searchControl = new SearchControl({
provider: new OpenStreetMapProvider(),
style: 'bar',
});

map.addControl(searchControl);
Expand Down Expand Up @@ -61,6 +62,7 @@ import { SearchControl, OpenStreetMapProvider } from 'leaflet-geosearch';
const searchControl = new SearchControl({
notFoundMessage: 'Sorry, that address could not be found.',
provider: new OpenStreetMapProvider(),
style: 'bar',
});

map.addControl(searchControl);
Expand Down
9 changes: 9 additions & 0 deletions docs/lib/providers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ import {
AlgoliaProvider,
BingProvider,
EsriProvider,
GeocodeEarthProvider,
GoogleProvider,
HereProvider,
LocationIQProvider,
OpenCageProvider,
OpenStreetMapProvider,
PeliasProvider,
GeoApiFrProvider,
} from 'leaflet-geosearch';

Expand All @@ -19,6 +21,11 @@ export default {

Esri: new EsriProvider(),

GeocodeEarth: new GeocodeEarthProvider({
// eslint-disable-next-line @typescript-eslint/camelcase
params: { api_key: process.env.GATSBY_GEOCODEEARTH_API_KEY },
}),

Google: new GoogleProvider({
params: { key: process.env.GATSBY_GOOGLE_API_KEY },
}),
Expand All @@ -37,5 +44,7 @@ export default {

OpenStreetMap: new OpenStreetMapProvider(),

Pelias: new PeliasProvider(),

GeoApiFr: new GeoApiFrProvider(),
};
1 change: 1 addition & 0 deletions docs/providers/algolia.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { GeoSearchControl } from 'leaflet-geosearch';
map.addControl(
new GeoSearchControl({
provider,
style: 'bar',
}),
);
```
Expand Down
1 change: 1 addition & 0 deletions docs/providers/bing.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import { GeoSearchControl } from 'leaflet-geosearch';
map.addControl(
new GeoSearchControl({
provider,
style: 'bar',
}),
);
```
Expand Down
1 change: 1 addition & 0 deletions docs/providers/esri.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { GeoSearchControl } from 'leaflet-geosearch';
map.addControl(
new GeoSearchControl({
provider,
style: 'bar',
}),
);
```
Expand Down
3 changes: 2 additions & 1 deletion docs/providers/geoapifr.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { GeoSearchControl } from 'leaflet-geosearch';
map.addControl(
new GeoSearchControl({
provider,
style: 'bar',
}),
);
```
Expand All @@ -37,7 +38,7 @@ Geo Api FR supports a number of [optional parameters][2]. As the api requires th
All options defined next to the `params` key, would have been added to the request body.

```js
const provider = new OpenStreetMapProvider({
const provider = new GeoApiFrProvider({
searchUrl: 'https://api-adresse.data.gouv.fr/search',
reverseUrl: 'https://api-adresse.data.gouv.fr/reverse',
params: {
Expand Down
71 changes: 71 additions & 0 deletions docs/providers/geocode-earth.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
---
name: Geocode Earth
menu: Providers
route: /providers/geocode-earth
---

import Playground from '../components/Playground';
import Map from '../components/Map';

# Geocode Earth Provider

Geocode Earth is a hosted version of Pelias run by the core maintainers of the FOSS project.

**note**: Geocode Earth services require an API key, grab a [free trial key][1] from their website.

For more options and configurations, see the [documentation][2].

<Playground>
<Map provider="GeocodeEarth" />
</Playground>

```js
import { GeocodeEarthProvider } from 'leaflet-geosearch';

// grab an API key from https://geocode.earth
const provider = new GeocodeEarthProvider({
params: {
api_key: '__YOUR_GEOCODE_EARTH_KEY__',
},
});

// add to leaflet
import { GeoSearchControl } from 'leaflet-geosearch';

map.addControl(
new GeoSearchControl({
provider,
style: 'bar',
}),
);
```

## Optional parameters

Geocode Earth supports a wide range of number of [optional parameters][2] which can be applied to every request using the `params` object:

```js
const provider = new GeocodeEarthProvider({
params: {
size: 5, // limit the total number of results returned
lang: 'nl', // render results in Dutch
'boundary.country': 'NL', // limit search results to the Netherlands
layers: 'address,street', // limmit which layers are queried
},
});
```

Or individually on a per-request basis:

```js
const results = await provider.search({
query: {
text: 'example',
'focus.point.lat': 1.11, // score results nearer to the focus point higher
'focus.point.lon': 2.22,
},
});
```

[1]: https://geocode.earth/
[2]: https://geocode.earth/docs/
1 change: 1 addition & 0 deletions docs/providers/google.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import { GeoSearchControl } from 'leaflet-geosearch';
map.addControl(
new GeoSearchControl({
provider,
style: 'bar',
}),
);
```
Expand Down
1 change: 1 addition & 0 deletions docs/providers/here.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import { GeoSearchControl } from 'leaflet-geosearch';
map.addControl(
new GeoSearchControl({
provider,
style: 'bar',
}),
);
```
Expand Down
1 change: 1 addition & 0 deletions docs/providers/locationIq.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import { GeoSearchControl } from 'leaflet-geosearch';
map.addControl(
new GeoSearchControl({
provider,
style: 'bar',
}),
);
```
Expand Down
1 change: 1 addition & 0 deletions docs/providers/opencage.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import { GeoSearchControl } from 'leaflet-geosearch';
map.addControl(
new GeoSearchControl({
provider,
style: 'bar',
}),
);
```
Expand Down
1 change: 1 addition & 0 deletions docs/providers/openstreetmap.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { GeoSearchControl } from 'leaflet-geosearch';
map.addControl(
new GeoSearchControl({
provider,
style: 'bar',
}),
);
```
Expand Down
75 changes: 75 additions & 0 deletions docs/providers/pelias.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
---
name: Pelias
menu: Providers
route: /providers/pelias
---

import Playground from '../components/Playground';
import Map from '../components/Map';

# Pelias Provider

[Pelias][1] is an open-source geocoder powered completely by open data, available freely to everyone.

In order to use this provider you'll need to have your own Pelias server running.

The [Docker][3] repository provides the quickest path to running your own server.

See the [Pelias documentation][2] for more detailed information about the available endpoints and query parameters.

Looking for a hosted version of Pelias? check out the Geocode Earth provider.

<Playground>
<Map provider="Pelias" />
</Playground>

```js
import { PeliasProvider } from 'leaflet-geosearch';

// Pelias servers are self-hosted so you'll need to configure the 'options.host' string
// to identify where requests to your running pelias/api server instance should be sent.
// note: you SHOULD include the scheme, domain and port but NOT any path or parameters.
const provider = new PeliasProvider({ host: 'http://localhost:4000' });

// add to leaflet
import { GeoSearchControl } from 'leaflet-geosearch';

map.addControl(
new GeoSearchControl({
provider,
style: 'bar',
}),
);
```

## Optional parameters

Pelias supports a wide range of number of [optional parameters][4] which can be applied to every request using the `params` object:

```js
const provider = new PeliasProvider({
params: {
size: 5, // limit the total number of results returned
lang: 'nl', // render results in Dutch
'boundary.country': 'NL', // limit search results to the Netherlands
layers: 'address,street', // limmit which layers are queried
},
});
```

Or individually on a per-request basis:

```js
const results = await provider.search({
query: {
text: 'example',
'focus.point.lat': 1.11, // score results nearer to the focus point higher
'focus.point.lon': 2.22,
},
});
```

[1]: https://github.com/pelias/pelias
[2]: https://github.com/pelias/documentation
[3]: https://github.com/pelias/docker
[4]: https://github.com/pelias/documentation/blob/master/autocomplete.md
1 change: 1 addition & 0 deletions docs/usage.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import { GeoSearchControl, OpenStreetMapProvider } from 'leaflet-geosearch';

const searchControl = new GeoSearchControl({
provider: new OpenStreetMapProvider(),
style: 'bar',
});

map.addControl(searchControl);
Expand Down
Loading

0 comments on commit ce19809

Please sign in to comment.