@unmap/sdk 0.9.1 → 0.12.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 CHANGED
@@ -26,6 +26,21 @@ await unmap.router.route([-114.07, 51.05], [-113.99, 51.05], { mode: 'bicycle' }
26
26
  await unmap.router.isochrone([-114.07, 51.05], { minutes: [10, 20] })
27
27
  ```
28
28
 
29
+ ## Without a build step
30
+
31
+ The same SDK loads from a script tag, with MapLibre already inside it:
32
+
33
+ ```html
34
+ <link rel="stylesheet" href="https://cdn.unmap.dev/sdk/0.12.0/unmap.css">
35
+ <div id="map" style="height: 400px"></div>
36
+ <script src="https://cdn.unmap.dev/sdk/0.12.0/unmap.js"></script>
37
+ <script>
38
+ unmap.createMap({ key: 'um_live_...', container: '#map', center: [-114.07, 51.05] })
39
+ </script>
40
+ ```
41
+
42
+ Everything above is on the `unmap` global: `unmap.Unmap`, `unmap.Geocoder`, `unmap.Router`, `unmap.maplibregl`. Pin the exact version in production; `/sdk/0.12/` follows patches and `/sdk/latest/` follows everything.
43
+
29
44
  ## Options
30
45
 
31
46
  | Option | Type | Notes |
package/dist/index.d.ts CHANGED
@@ -1,13 +1,17 @@
1
- import { Map, UnmapMapOptions, UnmapControlsOptions } from '@unmap/maps';
2
- export { DEMO_CITIES, DemoCity, Map, Projection, STYLE_NAMES, StyleInput, StyleName, UnmapControlsOptions, UnmapMapOptions, createMap, maplibregl, unmapStyle } from '@unmap/maps';
3
- import { Geocoder } from '@unmap/geocoding';
1
+ import { Map, MapProfile, UnmapMapOptions, UnmapControlsOptions } from '@unmap/maps';
2
+ export { DEMO_CITIES, DemoCity, Map, MapProfile, Projection, STYLE_NAMES, StyleInput, StyleName, UnmapControlsOptions, UnmapMapOptions, createMap, maplibregl, unmapStyle } from '@unmap/maps';
3
+ import { Geocoder, QueryOptions, QueryResponse, IdentifyOptions, IdentifyResponse } from '@unmap/geocoding';
4
4
  export * from '@unmap/geocoding';
5
5
  import { Router } from '@unmap/routing';
6
6
  export * from '@unmap/routing';
7
+ import { Elevation } from '@unmap/elevation';
8
+ export * from '@unmap/elevation';
7
9
 
8
10
  interface UnmapOptions {
9
11
  key: string;
10
12
  gateway?: string;
13
+ /** Override the fetch implementation (tests, non-global environments). */
14
+ fetch?: typeof fetch;
11
15
  /** If provided, a map is mounted in this container. */
12
16
  container?: string | HTMLElement;
13
17
  style?: string;
@@ -18,6 +22,10 @@ interface UnmapOptions {
18
22
  lang?: string;
19
23
  /** Compact `ut1.` theme code from unmap.dev/create. Wins over the path style on the gateway. */
20
24
  theme?: string;
25
+ /** Catalog layer ids composed onto the style (`municipalities`, `survey.dls`, …). */
26
+ overlays?: readonly string[];
27
+ /** Composition preset. Not a style. Explicit overlays replace the profile list. */
28
+ profile?: MapProfile;
21
29
  /** `"globe"` or `"mercator"`. See `@unmap/maps` `UnmapMapOptions.projection`. */
22
30
  projection?: UnmapMapOptions["projection"];
23
31
  center?: [number, number];
@@ -27,15 +35,21 @@ interface UnmapOptions {
27
35
  }
28
36
  /**
29
37
  * One Stripe-style key, the whole platform. With a `container` you get a rendered map;
30
- * `geocoder` and `router` are always available.
38
+ * `geocoder`, `router` and `elevation` are always available.
31
39
  *
32
40
  * const map = new Unmap({ key: "um_live_...", container: "#map", center: [-75.69, 45.42] });
33
41
  */
34
42
  declare class Unmap {
35
43
  readonly geocoder: Geocoder;
36
44
  readonly router: Router;
45
+ readonly elevation: Elevation;
46
+ readonly data: {
47
+ query(opts: QueryOptions): Promise<QueryResponse>;
48
+ };
37
49
  readonly map?: Map;
38
50
  constructor(opts: UnmapOptions);
51
+ /** Which catalog features contain a point. See `Geocoder.identify`. */
52
+ identify(opts: IdentifyOptions): Promise<IdentifyResponse>;
39
53
  }
40
54
 
41
55
  export { Unmap, type UnmapOptions };
package/dist/index.js CHANGED
@@ -4,20 +4,30 @@ import {
4
4
  } from "@unmap/maps";
5
5
  import { Geocoder } from "@unmap/geocoding";
6
6
  import { Router } from "@unmap/routing";
7
+ import { Elevation } from "@unmap/elevation";
7
8
  export * from "@unmap/geocoding";
8
9
  export * from "@unmap/routing";
10
+ export * from "@unmap/elevation";
9
11
  import { createMap as createMap2, unmapStyle, DEMO_CITIES, STYLE_NAMES, maplibregl } from "@unmap/maps";
10
12
  var Unmap = class {
11
13
  geocoder;
12
14
  router;
15
+ elevation;
16
+ data;
13
17
  map;
14
18
  constructor(opts) {
15
19
  this.geocoder = new Geocoder(opts);
16
20
  this.router = new Router(opts);
21
+ this.elevation = new Elevation(opts);
22
+ this.data = { query: (queryOpts) => this.geocoder.queryLayer(queryOpts) };
17
23
  if (opts.container) {
18
24
  this.map = createMap({ ...opts, container: opts.container });
19
25
  }
20
26
  }
27
+ /** Which catalog features contain a point. See `Geocoder.identify`. */
28
+ identify(opts) {
29
+ return this.geocoder.identify(opts);
30
+ }
21
31
  };
22
32
  export {
23
33
  DEMO_CITIES,
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import {\n createMap,\n type Map as MaplibreMap,\n type UnmapControlsOptions,\n type UnmapMapOptions,\n} 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, STYLE_NAMES, maplibregl } from \"@unmap/maps\";\nexport type {\n Map,\n UnmapMapOptions,\n UnmapControlsOptions,\n DemoCity,\n StyleName,\n StyleInput,\n Projection,\n} 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\". Selects the mode half of the named style. */\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 the path style on the gateway. */\n theme?: string;\n /** `\"globe\"` or `\"mercator\"`. See `@unmap/maps` `UnmapMapOptions.projection`. */\n projection?: UnmapMapOptions[\"projection\"];\n center?: [number, number];\n zoom?: number;\n /** On-map controls. `true` (the default) adds zoom and compass buttons; `false` adds none. */\n controls?: boolean | UnmapControlsOptions;\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;AAAA,EACE;AAAA,OAIK;AACP,SAAS,gBAAgB;AACzB,SAAS,cAAc;AAEvB,cAAc;AACd,cAAc;AACd,SAAS,aAAAA,YAAW,YAAY,aAAa,aAAa,kBAAkB;AAsCrE,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"]}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import {\n createMap,\n type Map as MaplibreMap,\n type MapProfile,\n type UnmapControlsOptions,\n type UnmapMapOptions,\n} from \"@unmap/maps\";\nimport { Geocoder, type IdentifyOptions, type IdentifyResponse, type QueryOptions, type QueryResponse } from \"@unmap/geocoding\";\nimport { Router } from \"@unmap/routing\";\nimport { Elevation } from \"@unmap/elevation\";\n\nexport * from \"@unmap/geocoding\";\nexport * from \"@unmap/routing\";\nexport * from \"@unmap/elevation\";\nexport { createMap, unmapStyle, DEMO_CITIES, STYLE_NAMES, maplibregl } from \"@unmap/maps\";\nexport type {\n Map,\n UnmapMapOptions,\n UnmapControlsOptions,\n DemoCity,\n StyleName,\n StyleInput,\n Projection,\n MapProfile,\n} from \"@unmap/maps\";\n\nexport interface UnmapOptions {\n key: string;\n gateway?: string;\n /** Override the fetch implementation (tests, non-global environments). */\n fetch?: typeof fetch;\n /** If provided, a map is mounted in this container. */\n container?: string | HTMLElement;\n style?: string;\n flavor?: string;\n /** \"light\" or \"dark\". Selects the mode half of the named style. */\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 the path style on the gateway. */\n theme?: string;\n /** Catalog layer ids composed onto the style (`municipalities`, `survey.dls`, …). */\n overlays?: readonly string[];\n /** Composition preset. Not a style. Explicit overlays replace the profile list. */\n profile?: MapProfile;\n /** `\"globe\"` or `\"mercator\"`. See `@unmap/maps` `UnmapMapOptions.projection`. */\n projection?: UnmapMapOptions[\"projection\"];\n center?: [number, number];\n zoom?: number;\n /** On-map controls. `true` (the default) adds zoom and compass buttons; `false` adds none. */\n controls?: boolean | UnmapControlsOptions;\n}\n\n/**\n * One Stripe-style key, the whole platform. With a `container` you get a rendered map;\n * `geocoder`, `router` and `elevation` 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 elevation: Elevation;\n readonly data: { query(opts: QueryOptions): Promise<QueryResponse> };\n readonly map?: MaplibreMap;\n\n constructor(opts: UnmapOptions) {\n this.geocoder = new Geocoder(opts);\n this.router = new Router(opts);\n this.elevation = new Elevation(opts);\n this.data = { query: (queryOpts) => this.geocoder.queryLayer(queryOpts) };\n if (opts.container) {\n this.map = createMap({ ...opts, container: opts.container } as UnmapMapOptions);\n }\n }\n\n /** Which catalog features contain a point. See `Geocoder.identify`. */\n identify(opts: IdentifyOptions): Promise<IdentifyResponse> {\n return this.geocoder.identify(opts);\n }\n}\n"],"mappings":";AAAA;AAAA,EACE;AAAA,OAKK;AACP,SAAS,gBAAoG;AAC7G,SAAS,cAAc;AACvB,SAAS,iBAAiB;AAE1B,cAAc;AACd,cAAc;AACd,cAAc;AACd,SAAS,aAAAA,YAAW,YAAY,aAAa,aAAa,kBAAkB;AA6CrE,IAAM,QAAN,MAAY;AAAA,EACR;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAET,YAAY,MAAoB;AAC9B,SAAK,WAAW,IAAI,SAAS,IAAI;AACjC,SAAK,SAAS,IAAI,OAAO,IAAI;AAC7B,SAAK,YAAY,IAAI,UAAU,IAAI;AACnC,SAAK,OAAO,EAAE,OAAO,CAAC,cAAc,KAAK,SAAS,WAAW,SAAS,EAAE;AACxE,QAAI,KAAK,WAAW;AAClB,WAAK,MAAM,UAAU,EAAE,GAAG,MAAM,WAAW,KAAK,UAAU,CAAoB;AAAA,IAChF;AAAA,EACF;AAAA;AAAA,EAGA,SAAS,MAAkD;AACzD,WAAO,KAAK,SAAS,SAAS,IAAI;AAAA,EACpC;AACF;","names":["createMap"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unmap/sdk",
3
- "version": "0.9.1",
3
+ "version": "0.12.0",
4
4
  "description": "One key, the whole unmap platform: map + geocoder + router",
5
5
  "license": "MIT",
6
6
  "keywords": [
@@ -40,10 +40,11 @@
40
40
  },
41
41
  "dependencies": {
42
42
  "maplibre-gl": "^6.7.0",
43
- "@unmap/maps": "0.9.1",
44
- "@unmap/geocoding": "0.9.1",
45
- "@unmap/routing": "0.9.1",
46
- "@unmap/core": "0.9.1"
43
+ "@unmap/core": "0.12.0",
44
+ "@unmap/elevation": "0.12.0",
45
+ "@unmap/geocoding": "0.12.0",
46
+ "@unmap/maps": "0.12.0",
47
+ "@unmap/routing": "0.12.0"
47
48
  },
48
49
  "devDependencies": {
49
50
  "tsup": "^8.3.0",