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?
|
|
|
|
, results: 10 // how many search results?
|
|
|
|
, stations: true
|
|
|
|
, addresses: true
|
|
|
|
, poi: true // points of interest
|
2018-06-28 13:00:33 +02:00
|
|
|
, stationLines: false // parse & expose lines of the 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
|
|
|
|
const createClient = require('hafas-client')
|
|
|
|
const vbbProfile = require('hafas-client/p/vbb')
|
|
|
|
|
2018-07-19 21:55:03 +02:00
|
|
|
const client = createClient(vbbProfile, 'my-awesome-program')
|
2017-12-17 18:16:04 +01:00
|
|
|
|
|
|
|
client.locations('Alexanderplatz', {results: 3})
|
|
|
|
.then(console.log)
|
|
|
|
.catch(console.error)
|
|
|
|
```
|
|
|
|
|
|
|
|
The response may look like this:
|
|
|
|
|
|
|
|
```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',
|
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',
|
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
|
|
|
|
} ]
|
|
|
|
```
|