@tileflow/dom 0.1.0-alpha.1 → 0.1.0-alpha.2

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.
Files changed (3) hide show
  1. package/README.md +42 -2
  2. package/dist/index.js +14 -12
  3. package/package.json +3 -3
package/README.md CHANGED
@@ -5,8 +5,8 @@ the map, loads its manifest and style, keeps its theme, colours, camera, annotat
5
5
  interactions current, and takes everything down again. It draws nothing of its own around the map:
6
6
  marker, popup and tooltip views, loading and error states belong to your page.
7
7
 
8
- Use it for plain pages and web components. The React, Vue and Svelte packages are the easier way in
9
- those frameworks.
8
+ Use it for plain pages and web components. The React, Vue and Svelte packages run on it and are the
9
+ easier way in those frameworks.
10
10
 
11
11
  > Related packages and guides: [documentation index](https://raw.githubusercontent.com/tileflow/tileflow-sdk/main/llms.txt).
12
12
 
@@ -104,6 +104,46 @@ settles with `null` once the image has loaded.
104
104
 
105
105
  See [REFERENCE.md](REFERENCE.md) for every option and controller method.
106
106
 
107
+ ## Extend the map
108
+
109
+ The map is a real MapLibre map: `ready` and `onLoad` give it, and `getMap()` returns it while it
110
+ exists. Add your own layers, sources, controls, events and MapLibre libraries to it.
111
+
112
+ <!-- docs:check -->
113
+
114
+ ```ts
115
+ import {createTileflowMap} from '@tileflow/dom';
116
+
117
+ const map = createTileflowMap(document.querySelector<HTMLElement>('#map')!, {
118
+ source: {map: 'madrid'},
119
+ onLoad(mapLibreMap) {
120
+ mapLibreMap.on('style.load', () => addRoute(mapLibreMap));
121
+ addRoute(mapLibreMap);
122
+ },
123
+ });
124
+
125
+ function addRoute(mapLibreMap: NonNullable<ReturnType<typeof map.getMap>>) {
126
+ if (mapLibreMap.getSource('route')) return;
127
+ mapLibreMap.addSource('route', {
128
+ type: 'geojson',
129
+ data: {
130
+ type: 'LineString',
131
+ coordinates: [
132
+ [-3.7038, 40.4168],
133
+ [-3.6921, 40.4138],
134
+ ],
135
+ },
136
+ });
137
+ mapLibreMap.addLayer({id: 'route', type: 'line', source: 'route', paint: {'line-width': 4}});
138
+ }
139
+ ```
140
+
141
+ Tileflow owns the style it applied, its protocols, its hosted requests and session, and the
142
+ controls it adds. A theme change may replace the style while keeping the camera, so add your own
143
+ layers and sources again on `style.load`, as above, or pass them as `dataSources` and `dataOverlays`,
144
+ which the map puts back after every theme change. Keep the map's lifetime with the controller:
145
+ `destroy()` takes everything down, and `getMap().remove()` stops the controller too.
146
+
107
147
  ## Next steps
108
148
 
109
149
  - [Show a popup on click](https://tileflow.dev/docs/examples/show-a-popup-on-click)
package/dist/index.js CHANGED
@@ -1,7 +1,18 @@
1
1
  // src/map.ts
2
2
  import {
3
- attachTileflowAtmosphere,
4
3
  attachTileflowBranding,
4
+ createTileflowAppearanceBinding,
5
+ createTileflowContourRequestScope,
6
+ createTileflowNavigationControlBinding,
7
+ getTileflowSystemColorScheme,
8
+ reportTileflowMapError,
9
+ resolveTileflowCameraFit,
10
+ subscribeTileflowSystemColorScheme,
11
+ tileflowMaxPitch
12
+ } from "@tileflow/core/browser";
13
+ import { normalizeTileflowCaptureId } from "@tileflow/core/capture";
14
+ import {
15
+ attachTileflowAtmosphere,
5
16
  attachTileflowFairUseNotice,
6
17
  attachTileflowHorizonQueries,
7
18
  attachTileflowLabelPlacement,
@@ -9,26 +20,17 @@ import {
9
20
  attachTileflowMapLifecycle,
10
21
  attachTileflowNauticalLights,
11
22
  attachTileflowNotices,
12
- createTileflowAppearanceBinding,
13
- createTileflowContourRequestScope,
14
- createTileflowNavigationControlBinding,
15
23
  createTileflowSessionStarter,
16
24
  createTileflowThemeController,
17
25
  createTileflowTransformRequest,
18
- getTileflowSystemColorScheme,
19
26
  loadTileflowRuntimeStyle,
20
27
  loadTileflowStyleFonts,
21
28
  registerTileflowContourProtocol,
22
29
  registerTileflowPathGroundProtocol,
23
30
  registerTileflowPmtilesProtocol,
24
31
  registerTileflowWorldRequestBridge,
25
- reportTileflowMapError,
26
- resolveTileflowCameraFit,
27
- subscribeTileflowSystemColorScheme,
28
- tileflowCanvasContextAttributes,
29
- tileflowMaxPitch
30
- } from "@tileflow/core/browser";
31
- import { normalizeTileflowCaptureId } from "@tileflow/core/capture";
32
+ tileflowCanvasContextAttributes
33
+ } from "@tileflow/core/internal";
32
34
  import {
33
35
  createTileflowSessionController,
34
36
  defaultTileflowManifestUrl,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tileflow/dom",
3
- "version": "0.1.0-alpha.1",
3
+ "version": "0.1.0-alpha.2",
4
4
  "license": "Apache-2.0",
5
5
  "description": "Mount a Tileflow map in any DOM element, without a framework.",
6
6
  "type": "module",
@@ -40,8 +40,8 @@
40
40
  "access": "public"
41
41
  },
42
42
  "dependencies": {
43
- "@tileflow/core": ">=0.1.0-alpha.51 <0.1.0-beta.0",
44
- "@tileflow/interactions": ">=0.1.0-alpha.10 <0.1.0-beta.0"
43
+ "@tileflow/core": ">=0.1.0-alpha.52 <0.1.0-beta.0",
44
+ "@tileflow/interactions": ">=0.1.0-alpha.11 <0.1.0-beta.0"
45
45
  },
46
46
  "peerDependencies": {
47
47
  "maplibre-gl": ">=6.4.1 <7"