@unmap/sdk 0.0.3 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +54 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/README.md
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# @unmap/sdk
|
|
2
|
+
|
|
3
|
+
One key, the whole [unmap](https://unmap.dev) platform: a MapLibre GL map, a geocoder, and a
|
|
4
|
+
router behind a single `um_live_` or `um_test_` key. Canadian-first, privacy-first.
|
|
5
|
+
|
|
6
|
+
```bash
|
|
7
|
+
npm i @unmap/sdk
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
```ts
|
|
11
|
+
import { Unmap } from '@unmap/sdk'
|
|
12
|
+
import 'maplibre-gl/dist/maplibre-gl.css'
|
|
13
|
+
|
|
14
|
+
const map = new Unmap({ key: 'um_live_...', container: '#map', center: [-114.07, 51.05] })
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
That is the whole Hello World: a Calgary basemap in the `#map` element. Without a `container`
|
|
18
|
+
you still get the geocoder and router:
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
const unmap = new Unmap({ key: 'um_live_...' })
|
|
22
|
+
|
|
23
|
+
await unmap.geocoder.search('Calgary Tower')
|
|
24
|
+
await unmap.geocoder.nearby('pharmacy', { near: [-114.07, 51.05] })
|
|
25
|
+
await unmap.router.route([-114.07, 51.05], [-113.99, 51.05], { mode: 'bicycle' })
|
|
26
|
+
await unmap.router.isochrone([-114.07, 51.05], { minutes: [10, 20] })
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Options
|
|
30
|
+
|
|
31
|
+
| Option | Type | Notes |
|
|
32
|
+
| ----------- | ----------------------- | ---------------------------------------------------------------------------- |
|
|
33
|
+
| `key` | `string` | Required. |
|
|
34
|
+
| `gateway` | `string` | API base URL. Defaults to `https://api.unmap.dev`. |
|
|
35
|
+
| `container` | `string \| HTMLElement` | Mount a map here. Omit for geocoding and routing only. |
|
|
36
|
+
| `style` | `string` | `calgary` (default), `montreal`, `iqaluit`, or a full style URL. |
|
|
37
|
+
| `flavor` | `string` | `base` (default), `muted`, `relief`, `street`, `outdoor`, or `<style>-<mode>`. |
|
|
38
|
+
| `mode` | `string` | `light` or `dark`. Overrides the mode half of `flavor`. |
|
|
39
|
+
| `lang` | `string` | Label language, e.g. `fr`. Omit to follow the browser's `Accept-Language`. |
|
|
40
|
+
| `theme` | `string` | A `ut1.` theme code from [unmap.dev/create](https://unmap.dev/create). |
|
|
41
|
+
| `center` | `[lng, lat]` | Initial centre. |
|
|
42
|
+
| `zoom` | `number` | Initial zoom. |
|
|
43
|
+
|
|
44
|
+
The instance exposes `.map` (MapLibre GL `Map`, only with a `container`), `.geocoder`
|
|
45
|
+
(`@unmap/geocoding`), and `.router` (`@unmap/routing`). Everything from those two packages and
|
|
46
|
+
from `@unmap/maps` is re-exported here, including `maplibregl` for markers and popups.
|
|
47
|
+
|
|
48
|
+
## Docs
|
|
49
|
+
|
|
50
|
+
- [Quickstart](https://unmap.dev/docs/quickstart) and [Overview](https://unmap.dev/docs/overview)
|
|
51
|
+
- [Tiles & Styles](https://unmap.dev/docs/tiles-and-styles), [Geocoding API](https://unmap.dev/docs/geocoding-api), [Routing API](https://unmap.dev/docs/routing-api)
|
|
52
|
+
- [Errors](https://unmap.dev/docs/errors) and [Plans & Limits](https://unmap.dev/docs/plans-and-limits)
|
|
53
|
+
|
|
54
|
+
Documentation en français : [unmap.dev/fr/docs](https://unmap.dev/fr/docs/quickstart).
|
package/dist/index.d.ts
CHANGED
|
@@ -12,6 +12,12 @@ interface UnmapOptions {
|
|
|
12
12
|
container?: string | HTMLElement;
|
|
13
13
|
style?: string;
|
|
14
14
|
flavor?: string;
|
|
15
|
+
/** "light" or "dark". Overrides the mode half of `flavor`. */
|
|
16
|
+
mode?: string;
|
|
17
|
+
/** Label language, e.g. "fr". Omit to follow the request's Accept-Language. */
|
|
18
|
+
lang?: string;
|
|
19
|
+
/** Compact `ut1.` theme code from unmap.dev/create. Wins over `flavor` on the gateway. */
|
|
20
|
+
theme?: string;
|
|
15
21
|
center?: [number, number];
|
|
16
22
|
zoom?: number;
|
|
17
23
|
}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { createMap, type Map as MaplibreMap, type UnmapMapOptions } from \"@unmap/maps\";\nimport { Geocoder } from \"@unmap/geocoding\";\nimport { Router } from \"@unmap/routing\";\n\nexport * from \"@unmap/geocoding\";\nexport * from \"@unmap/routing\";\nexport { createMap, unmapStyle, DEMO_CITIES, maplibregl } from \"@unmap/maps\";\nexport type { Map, UnmapMapOptions, DemoCity } from \"@unmap/maps\";\n\nexport interface UnmapOptions {\n key: string;\n gateway?: string;\n /** If provided, a map is mounted in this container. */\n container?: string | HTMLElement;\n style?: string;\n flavor?: string;\n center?: [number, number];\n zoom?: number;\n}\n\n/**\n * One Stripe-style key, the whole platform. With a `container` you get a rendered map;\n * `geocoder` and `router` are always available.\n *\n * const map = new Unmap({ key: \"um_live_...\", container: \"#map\", center: [-75.69, 45.42] });\n */\nexport class Unmap {\n readonly geocoder: Geocoder;\n readonly router: Router;\n readonly map?: MaplibreMap;\n\n constructor(opts: UnmapOptions) {\n this.geocoder = new Geocoder(opts);\n this.router = new Router(opts);\n if (opts.container) {\n this.map = createMap({ ...opts, container: opts.container } as UnmapMapOptions);\n }\n }\n}\n"],"mappings":";AAAA,SAAS,iBAAgE;AACzE,SAAS,gBAAgB;AACzB,SAAS,cAAc;AAEvB,cAAc;AACd,cAAc;AACd,SAAS,aAAAA,YAAW,YAAY,aAAa,kBAAkB;
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { createMap, type Map as MaplibreMap, type UnmapMapOptions } from \"@unmap/maps\";\nimport { Geocoder } from \"@unmap/geocoding\";\nimport { Router } from \"@unmap/routing\";\n\nexport * from \"@unmap/geocoding\";\nexport * from \"@unmap/routing\";\nexport { createMap, unmapStyle, DEMO_CITIES, maplibregl } from \"@unmap/maps\";\nexport type { Map, UnmapMapOptions, DemoCity } from \"@unmap/maps\";\n\nexport interface UnmapOptions {\n key: string;\n gateway?: string;\n /** If provided, a map is mounted in this container. */\n container?: string | HTMLElement;\n style?: string;\n flavor?: string;\n /** \"light\" or \"dark\". Overrides the mode half of `flavor`. */\n mode?: string;\n /** Label language, e.g. \"fr\". Omit to follow the request's Accept-Language. */\n lang?: string;\n /** Compact `ut1.` theme code from unmap.dev/create. Wins over `flavor` on the gateway. */\n theme?: string;\n center?: [number, number];\n zoom?: number;\n}\n\n/**\n * One Stripe-style key, the whole platform. With a `container` you get a rendered map;\n * `geocoder` and `router` are always available.\n *\n * const map = new Unmap({ key: \"um_live_...\", container: \"#map\", center: [-75.69, 45.42] });\n */\nexport class Unmap {\n readonly geocoder: Geocoder;\n readonly router: Router;\n readonly map?: MaplibreMap;\n\n constructor(opts: UnmapOptions) {\n this.geocoder = new Geocoder(opts);\n this.router = new Router(opts);\n if (opts.container) {\n this.map = createMap({ ...opts, container: opts.container } as UnmapMapOptions);\n }\n }\n}\n"],"mappings":";AAAA,SAAS,iBAAgE;AACzE,SAAS,gBAAgB;AACzB,SAAS,cAAc;AAEvB,cAAc;AACd,cAAc;AACd,SAAS,aAAAA,YAAW,YAAY,aAAa,kBAAkB;AA0BxD,IAAM,QAAN,MAAY;AAAA,EACR;AAAA,EACA;AAAA,EACA;AAAA,EAET,YAAY,MAAoB;AAC9B,SAAK,WAAW,IAAI,SAAS,IAAI;AACjC,SAAK,SAAS,IAAI,OAAO,IAAI;AAC7B,QAAI,KAAK,WAAW;AAClB,WAAK,MAAM,UAAU,EAAE,GAAG,MAAM,WAAW,KAAK,UAAU,CAAoB;AAAA,IAChF;AAAA,EACF;AACF;","names":["createMap"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unmap/sdk",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "One key, the whole unmap platform: map + geocoder + router",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -20,10 +20,10 @@
|
|
|
20
20
|
"access": "public"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@unmap/
|
|
24
|
-
"@unmap/
|
|
25
|
-
"@unmap/maps": "0.0
|
|
26
|
-
"@unmap/
|
|
23
|
+
"@unmap/routing": "0.0.3",
|
|
24
|
+
"@unmap/core": "0.1.0",
|
|
25
|
+
"@unmap/maps": "0.1.0",
|
|
26
|
+
"@unmap/geocoding": "0.1.0"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"tsup": "^8.3.0",
|