# @digitregroup/map-location-factory

> Map and location factory

Latest version **1.9.2** (published 2024-02-29) · 0 weekly downloads

## Install

```sh
npm install @digitregroup/map-location-factory
pnpm add @digitregroup/map-location-factory
yarn add @digitregroup/map-location-factory
bun add @digitregroup/map-location-factory
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.9.2 |
| Published | 2024-02-29 |
| First published | 2019-10-04 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 669.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | bouiboui, l0gin, dominique_digit, digital-factory-digitregroup |

## Links

- npm: https://www.npmjs.com/package/@digitregroup/map-location-factory
- Repository: https://github.com/digitregroup/map-location-factory
- Homepage: https://github.com/digitregroup/map-location-factory#readme
- Issues: https://github.com/digitregroup/map-location-factory/issues
- npm.io page: https://npm.io/package/@digitregroup/map-location-factory

## Dependencies (4)

- [lodash](https://npm.io/package/lodash.md) ^4.17.14
- [leaflet](https://npm.io/package/leaflet.md) ^1.4.0
- [cross-fetch](https://npm.io/package/cross-fetch.md) ^3.0.2
- [@babel/runtime](https://npm.io/package/@babel/runtime.md) ^7.4.5

## Recent versions

- 1.9.2 (latest) — 2024-02-29
- 1.9.1 — 2024-02-23
- 1.9.0 — 2024-02-19
- 1.8.7 — 2023-12-11
- 1.8.5 — 2023-12-08
- 1.8.3 — 2023-12-07
- 1.8.2 — 2023-12-07
- 1.8.1 — 2023-12-07
- 1.8.0 — 2023-12-07
- 1.7.7 — 2021-09-14
- 1.7.5 — 2020-02-25
- 1.7.4 — 2019-11-13
- 1.7.3 — 2019-11-07
- 1.7.2 — 2019-11-06
- 1.7.1 — 2019-10-07
- … 1 more at https://npm.io/package/@digitregroup/map-location-factory/versions

## README

# map-location-factory

## How to use

### Front-end

- Install the last npm package
- Import the library
- use the autocompleteAdapter plugin


### Back-end

- Install the last npm package
- Import the library
- use the API public function suggest, geocode, reverse.


## The library

### Constructor params :

```
    const engine = new GeocoderEngine(
        'Here', {
            "apiKey":   "API_KEY",
            "cacheEnable": false,
            "cacheUrl": "https://geocoder-stage.digitregroup.io",
            "cacheKey": "CACHE_KEY"
            "lookup": {
              "baseUrl": "https://lookup.search.hereapi.com/v1/",
              "path": "",
              "resource": "lookup"
            },
            "geocode": {
              "baseUrl": "https://geocode.search.hereapi.com/v1/",
              "path": "",
              "resource": "geocode",
              "options": {
                "limit": 2,
                "lang": "fr",
                "country": "FRA,GLP,GUF,MTQ,REU,MYT,BLM,MAF,NCL,PYF,SPM,ATF,WLF"
              }
            },
            "reverse": {
              "baseUrl": "https://revgeocode.search.hereapi.com/v1/",
              "path": "",
              "resource": "revgeocode",
              "options": {
                "limit": 2,
                "lang": "DEU"
            }
        });
```

Options (suggest, geocode, reverse) : 

| params          | type                  | value                                                                                                                          |
|-----------------|-----------------------|--------------------------------------------------------------------------------------------------------------------------------|
| options         | object                | {}                                                                                                                             |
| options.term    | string                | Address, city, postalCode,...                                                                                                  |
| options.country | array_string or array | 'FRA' or 'FRA,DEU' or ['FRA','DEU']<br/> default : 'FRA', 'GLP', 'GUF', 'MTQ', 'REU', 'MYT', 'PYF', 'SPM', 'WLF', 'MAF', 'BLM' |
| options.types   | array_string          | 'area,city,postalCode'                                                                                                         |
| options.limit   | int                   | 10                                                                                                                             |
| options.lang    | string                | 'fr'        |

All options of Here API are accepted,
For more information : https://www.here.com/docs/bundle/geocoding-and-search-api-v7-api-reference/page/index.html


***


### Here suggest API

#### params :

| params          | type                  | value                                                                                                                          |
|-----------------|-----------------------|--------------------------------------------------------------------------------------------------------------------------------|
| term            | string                | A city or postalCode,...                                                                                                       |


#### exemples :
```
    engine.suggest({
      term: 'Montpellier',
    }, (results, status) => {
      results.map(r => r.label)
          .indexOf('Montpellier')
          .should.equal(-1);

      status.should.be.eql(200);
    });
  })
```

### Here Geocode API

#### params :

| params | type                  | value                                                                                                                          |
|--------|-----------------------|--------------------------------------------------------------------------------------------------------------------------------|
| id     | string                | Here ID                                                                                                                        |
| text   | string                | An address                                                                                                                     |
                                                                                                                           


#### exemples :
```
    engine.geocode({
        id: 'here:cm:namedplace:20098349'
    });

```

```
    engine.geocode({{
        text: '1 rue de Rivoli, Paris'
    });
```

### Here Reverse API

#### params :

| params          | type                  | value                                                                                                                          |
|-----------------|-----------------------|--------------------------------------------------------------------------------------------------------------------------------|
| latitude        | number                | latitude coordinate                                                                                                            |
| longitude       | number                | longitude coordinate                                                                                                           |



#### exemple :
```
    engine.reverse({ latitude: 48.8555, longitude: 2.36039 });
```

---
_Source: https://npm.io/package/@digitregroup/map-location-factory · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
