2017-12-17 18:16:04 +01:00
|
|
|
# `locations(query, [opt])`
|
|
|
|
|
|
|
|
`query` must be an string (e.g. `'Alexanderplatz'`).
|
|
|
|
|
|
|
|
With `opt`, you can override the default options, which look like this:
|
|
|
|
|
|
|
|
```js
|
|
|
|
{
|
|
|
|
fuzzy: true // find only exact matches?
|
2018-12-07 17:00:24 +01:00
|
|
|
, results: 5 // how many search results?
|
2019-01-23 12:58:05 +08:00
|
|
|
, stops: true // return stops/stations?
|
2017-12-17 18:16:04 +01:00
|
|
|
, addresses: true
|
|
|
|
, poi: true // points of interest
|
2020-03-18 20:04:39 +01:00
|
|
|
, subStops: true // parse & expose sub-stops of stations?
|
|
|
|
, entrances: true // parse & expose entrances of stops/stations?
|
2019-01-23 13:03:01 +08:00
|
|
|
, linesOfStops: false // parse & expose lines at each stop/station?
|
2018-07-09 12:40:38 +02:00
|
|
|
, language: 'en' // language to get results in
|
2017-12-17 18:16:04 +01:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
## Response
|
|
|
|
|
2018-01-05 15:01:32 +01:00
|
|
|
As an example, we're going to use the [VBB profile](../p/vbb):
|
2017-12-17 18:16:04 +01:00
|
|
|
|
|
|
|
```js
|
2022-05-07 16:17:37 +02:00
|
|
|
import {createClient} from 'hafas-client'
|
2022-11-22 21:08:08 +01:00
|
|
|
import {profile as vbbProfile} from 'hafas-client/p/vbb/index.js'
|
2017-12-17 18:16:04 +01:00
|
|
|
|
2023-03-14 20:32:50 +01:00
|
|
|
const userAgent = 'link-to-your-project-or-email' // adapt this to your project!
|
|
|
|
const client = createClient(vbbProfile, userAgent)
|
2017-12-17 18:16:04 +01:00
|
|
|
|
2021-12-29 16:59:31 +01:00
|
|
|
await client.locations('Alexanderplatz', {results: 3})
|
2017-12-17 18:16:04 +01:00
|
|
|
```
|
|
|
|
|
2021-12-29 16:59:31 +01:00
|
|
|
The result may look like this:
|
2017-12-17 18:16:04 +01:00
|
|
|
|
|
|
|
```js
|
|
|
|
[ {
|
2018-07-11 00:32:57 +02:00
|
|
|
type: 'stop',
|
2017-12-17 18:16:04 +01:00
|
|
|
id: '900000100003',
|
|
|
|
name: 'S+U Alexanderplatz',
|
|
|
|
location: {
|
|
|
|
type: 'location',
|
|
|
|
latitude: 52.521508,
|
|
|
|
longitude: 13.411267
|
|
|
|
},
|
|
|
|
products: {
|
|
|
|
suburban: true,
|
|
|
|
subway: true,
|
|
|
|
tram: true,
|
|
|
|
bus: true,
|
|
|
|
ferry: false,
|
|
|
|
express: false,
|
|
|
|
regional: true
|
|
|
|
}
|
|
|
|
}, { // point of interest
|
|
|
|
type: 'location',
|
|
|
|
id: '900980709',
|
2019-02-07 17:47:50 +01:00
|
|
|
poi: true,
|
2018-07-16 12:39:13 +02:00
|
|
|
name: 'Berlin, Holiday Inn Centre Alexanderplatz****',
|
2017-12-17 18:16:04 +01:00
|
|
|
latitude: 52.523549,
|
|
|
|
longitude: 13.418441
|
|
|
|
}, { // point of interest
|
|
|
|
type: 'location',
|
|
|
|
id: '900980176',
|
2019-02-07 17:47:50 +01:00
|
|
|
poi: true,
|
2018-07-16 12:39:13 +02:00
|
|
|
name: 'Berlin, Hotel Agon am Alexanderplatz',
|
2017-12-17 18:16:04 +01:00
|
|
|
latitude: 52.524556,
|
|
|
|
longitude: 13.420266
|
|
|
|
} ]
|
|
|
|
```
|