ts-maps 0.2.6 → 0.3.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.
Files changed (225) hide show
  1. package/LICENSE.md +21 -0
  2. package/README.md +202 -141
  3. package/dist/core-map/assets/embedded-icons.d.ts +8 -0
  4. package/dist/core-map/control/AttributionControl.d.ts +12 -0
  5. package/dist/core-map/control/Control.d.ts +14 -0
  6. package/dist/core-map/control/LayersControl.d.ts +38 -0
  7. package/dist/core-map/control/ScaleControl.d.ts +14 -0
  8. package/dist/core-map/control/ZoomControl.d.ts +14 -0
  9. package/dist/core-map/control/index.d.ts +5 -0
  10. package/dist/core-map/core/Browser.d.ts +24 -0
  11. package/dist/core-map/core/Class.d.ts +12 -0
  12. package/dist/core-map/core/Events.d.ts +31 -0
  13. package/dist/core-map/core/Handler.d.ts +12 -0
  14. package/dist/core-map/core/Util.d.ts +24 -0
  15. package/dist/core-map/core/index.d.ts +7 -0
  16. package/dist/core-map/dom/Animation.d.ts +50 -0
  17. package/dist/core-map/dom/DomEvent.DoubleTap.d.ts +6 -0
  18. package/dist/core-map/dom/DomEvent.PointerEvents.d.ts +4 -0
  19. package/dist/core-map/dom/DomEvent.d.ts +15 -0
  20. package/dist/core-map/dom/DomUtil.d.ts +22 -0
  21. package/dist/core-map/dom/Draggable.d.ts +26 -0
  22. package/dist/core-map/dom/PosAnimation.d.ts +19 -0
  23. package/dist/core-map/dom/easing.d.ts +41 -0
  24. package/dist/core-map/dom/index.d.ts +8 -0
  25. package/dist/core-map/geo/LatLng.d.ts +18 -0
  26. package/dist/core-map/geo/LatLngBounds.d.ts +27 -0
  27. package/dist/core-map/geo/TerrainSource.d.ts +35 -0
  28. package/dist/core-map/geo/crs/CRS.d.ts +23 -0
  29. package/dist/core-map/geo/crs/EPSG3395.d.ts +7 -0
  30. package/dist/core-map/geo/crs/EPSG3857.d.ts +10 -0
  31. package/dist/core-map/geo/crs/EPSG4326.d.ts +7 -0
  32. package/dist/core-map/geo/crs/EarthCRS.d.ts +7 -0
  33. package/dist/core-map/geo/crs/SimpleCRS.d.ts +11 -0
  34. package/dist/core-map/geo/crs/index.d.ts +6 -0
  35. package/dist/core-map/geo/elevation.d.ts +23 -0
  36. package/dist/core-map/geo/index.d.ts +13 -0
  37. package/dist/core-map/geo/index.js +1204 -0
  38. package/dist/core-map/geo/projection/Projection.Globe.d.ts +30 -0
  39. package/dist/core-map/geo/projection/Projection.LonLat.d.ts +11 -0
  40. package/dist/core-map/geo/projection/Projection.Mercator.d.ts +6 -0
  41. package/dist/core-map/geo/projection/Projection.SphericalMercator.d.ts +6 -0
  42. package/dist/core-map/geo/projection/index.d.ts +5 -0
  43. package/dist/core-map/geo/terrainMesh.d.ts +21 -0
  44. package/dist/core-map/geometry/Bounds.d.ts +23 -0
  45. package/dist/core-map/geometry/LineUtil.d.ts +13 -0
  46. package/dist/core-map/geometry/Point.d.ts +35 -0
  47. package/dist/core-map/geometry/PolyUtil.d.ts +6 -0
  48. package/dist/core-map/geometry/RTree.d.ts +35 -0
  49. package/dist/core-map/geometry/Transformation.d.ts +12 -0
  50. package/dist/core-map/geometry/earcut.d.ts +17 -0
  51. package/dist/core-map/geometry/index.d.ts +10 -0
  52. package/dist/core-map/geometry/index.js +1586 -0
  53. package/dist/core-map/index.d.ts +59 -0
  54. package/dist/core-map/layer/BlanketOverlay.d.ts +24 -0
  55. package/dist/core-map/layer/DivOverlay.d.ts +40 -0
  56. package/dist/core-map/layer/FeatureGroup.d.ts +11 -0
  57. package/dist/core-map/layer/GeoJSON.d.ts +17 -0
  58. package/dist/core-map/layer/GeoJSONClusterSource.d.ts +54 -0
  59. package/dist/core-map/layer/HeatmapLayer.d.ts +40 -0
  60. package/dist/core-map/layer/ImageOverlay.d.ts +27 -0
  61. package/dist/core-map/layer/Layer.d.ts +18 -0
  62. package/dist/core-map/layer/LayerGroup.d.ts +16 -0
  63. package/dist/core-map/layer/Popup.d.ts +18 -0
  64. package/dist/core-map/layer/SVGOverlay.d.ts +4 -0
  65. package/dist/core-map/layer/Tooltip.d.ts +15 -0
  66. package/dist/core-map/layer/VideoOverlay.d.ts +4 -0
  67. package/dist/core-map/layer/index.d.ts +18 -0
  68. package/dist/core-map/layer/marker/DefaultIcon.d.ts +7 -0
  69. package/dist/core-map/layer/marker/DivIcon.d.ts +5 -0
  70. package/dist/core-map/layer/marker/Icon.d.ts +10 -0
  71. package/dist/core-map/layer/marker/Marker.Drag.d.ts +17 -0
  72. package/dist/core-map/layer/marker/Marker.d.ts +37 -0
  73. package/dist/core-map/layer/marker/index.d.ts +5 -0
  74. package/dist/core-map/layer/tile/GridLayer.d.ts +88 -0
  75. package/dist/core-map/layer/tile/RasterDEMLayer.d.ts +46 -0
  76. package/dist/core-map/layer/tile/TileLayer.d.ts +22 -0
  77. package/dist/core-map/layer/tile/VectorTileMapLayer.d.ts +145 -0
  78. package/dist/core-map/layer/tile/WMSTileLayer.d.ts +12 -0
  79. package/dist/core-map/layer/tile/index.d.ts +15 -0
  80. package/dist/core-map/layer/tile/urlTemplate.d.ts +17 -0
  81. package/dist/core-map/layer/vector/Canvas.d.ts +52 -0
  82. package/dist/core-map/layer/vector/Circle.d.ts +7 -0
  83. package/dist/core-map/layer/vector/CircleMarker.d.ts +22 -0
  84. package/dist/core-map/layer/vector/Path.d.ts +20 -0
  85. package/dist/core-map/layer/vector/Polygon.d.ts +13 -0
  86. package/dist/core-map/layer/vector/Polyline.d.ts +30 -0
  87. package/dist/core-map/layer/vector/Rectangle.d.ts +6 -0
  88. package/dist/core-map/layer/vector/Renderer.d.ts +12 -0
  89. package/dist/core-map/layer/vector/Renderer.getRenderer.d.ts +1 -0
  90. package/dist/core-map/layer/vector/SVG.d.ts +21 -0
  91. package/dist/core-map/layer/vector/index.d.ts +10 -0
  92. package/dist/core-map/map/Map.d.ts +353 -0
  93. package/dist/core-map/map/Style.d.ts +29 -0
  94. package/dist/core-map/map/handler/BoxZoomHandler.d.ts +23 -0
  95. package/dist/core-map/map/handler/DoubleClickZoomHandler.d.ts +6 -0
  96. package/dist/core-map/map/handler/DragHandler.d.ts +27 -0
  97. package/dist/core-map/map/handler/KeyboardHandler.d.ts +18 -0
  98. package/dist/core-map/map/handler/PinchZoomHandler.d.ts +20 -0
  99. package/dist/core-map/map/handler/ScrollWheelZoomHandler.d.ts +12 -0
  100. package/dist/core-map/map/handler/TapHoldHandler.d.ts +15 -0
  101. package/dist/core-map/map/handler/TwoFingerPitchHandler.d.ts +21 -0
  102. package/dist/core-map/map/handler/TwoFingerRotateHandler.d.ts +17 -0
  103. package/dist/core-map/map/index.d.ts +11 -0
  104. package/dist/core-map/mvt/VectorTile.d.ts +9 -0
  105. package/dist/core-map/mvt/VectorTileFeature.d.ts +59 -0
  106. package/dist/core-map/mvt/VectorTileLayer.d.ts +13 -0
  107. package/dist/core-map/proto/Pbf.d.ts +84 -0
  108. package/dist/core-map/renderer/webgl/GLContext.d.ts +22 -0
  109. package/dist/core-map/renderer/webgl/WebGLTileRenderer.d.ts +86 -0
  110. package/dist/core-map/renderer/webgl/index.d.ts +9 -0
  111. package/dist/core-map/renderer/webgl/mat4.d.ts +14 -0
  112. package/dist/core-map/services/index.d.ts +26 -0
  113. package/dist/core-map/services/index.js +1230 -0
  114. package/dist/core-map/services/providers/Google.d.ts +16 -0
  115. package/dist/core-map/services/providers/Mapbox.d.ts +26 -0
  116. package/dist/core-map/services/providers/Maptiler.d.ts +11 -0
  117. package/dist/core-map/services/providers/Nominatim.d.ts +11 -0
  118. package/dist/core-map/services/providers/OSRM.d.ts +20 -0
  119. package/dist/core-map/services/providers/Photon.d.ts +10 -0
  120. package/dist/core-map/services/providers/Valhalla.d.ts +20 -0
  121. package/dist/core-map/services/types.d.ts +84 -0
  122. package/dist/core-map/storage/TileCache.d.ts +40 -0
  123. package/dist/core-map/storage/cachedFetch.d.ts +13 -0
  124. package/dist/core-map/storage/defaultCache.d.ts +3 -0
  125. package/dist/core-map/storage/index.d.ts +13 -0
  126. package/dist/core-map/storage/index.js +283 -0
  127. package/dist/core-map/storage/offlineRegion.d.ts +26 -0
  128. package/dist/core-map/style-spec/diff.d.ts +17 -0
  129. package/dist/core-map/style-spec/expressions/Color.d.ts +16 -0
  130. package/dist/core-map/style-spec/expressions/compile.d.ts +4 -0
  131. package/dist/core-map/style-spec/expressions/errors.d.ts +8 -0
  132. package/dist/core-map/style-spec/expressions/index.d.ts +16 -0
  133. package/dist/core-map/style-spec/expressions/legacyFilter.d.ts +6 -0
  134. package/dist/core-map/style-spec/expressions/operators/conversion.d.ts +1 -0
  135. package/dist/core-map/style-spec/expressions/operators/interpolate.d.ts +14 -0
  136. package/dist/core-map/style-spec/expressions/operators/logical.d.ts +1 -0
  137. package/dist/core-map/style-spec/expressions/operators/lookup.d.ts +1 -0
  138. package/dist/core-map/style-spec/expressions/operators/math.d.ts +1 -0
  139. package/dist/core-map/style-spec/expressions/operators/string.d.ts +1 -0
  140. package/dist/core-map/style-spec/expressions/registry.d.ts +29 -0
  141. package/dist/core-map/style-spec/expressions/types.d.ts +48 -0
  142. package/dist/core-map/style-spec/expressions/validate.d.ts +13 -0
  143. package/dist/core-map/style-spec/index.d.ts +68 -0
  144. package/dist/core-map/style-spec/index.js +2529 -0
  145. package/dist/core-map/style-spec/schema.d.ts +381 -0
  146. package/dist/core-map/style-spec/types.d.ts +375 -0
  147. package/dist/core-map/style-spec/validate.d.ts +14 -0
  148. package/dist/core-map/symbols/CollisionIndex.d.ts +21 -0
  149. package/dist/core-map/symbols/GlyphAtlas.d.ts +38 -0
  150. package/dist/core-map/symbols/IconAtlas.d.ts +18 -0
  151. package/dist/core-map/symbols/index.d.ts +6 -0
  152. package/dist/core-map/symbols/index.js +501 -0
  153. package/dist/index.d.ts +2 -4
  154. package/dist/index.js +18414 -1857
  155. package/package.json +50 -58
  156. package/src/core-map/ts-maps.css +725 -0
  157. package/dist/components/base.d.ts +0 -17
  158. package/dist/components/concerns/interactable.d.ts +0 -1
  159. package/dist/components/line.d.ts +0 -29
  160. package/dist/components/marker.d.ts +0 -50
  161. package/dist/components/region.d.ts +0 -46
  162. package/dist/components/tooltip.d.ts +0 -22
  163. package/dist/core/apply-transform.d.ts +0 -7
  164. package/dist/core/coords-to-point.d.ts +0 -12
  165. package/dist/core/create-lines.d.ts +0 -2
  166. package/dist/core/create-markers.d.ts +0 -2
  167. package/dist/core/create-regions.d.ts +0 -2
  168. package/dist/core/create-series.d.ts +0 -3
  169. package/dist/core/get-inset-for-point.d.ts +0 -13
  170. package/dist/core/get-marker-position.d.ts +0 -6
  171. package/dist/core/index.d.ts +0 -1
  172. package/dist/core/reposition-labels.d.ts +0 -2
  173. package/dist/core/reposition-lines.d.ts +0 -2
  174. package/dist/core/reposition-markers.d.ts +0 -2
  175. package/dist/core/resize.d.ts +0 -3
  176. package/dist/core/set-focus.d.ts +0 -2
  177. package/dist/core/set-scale.d.ts +0 -2
  178. package/dist/core/setup-container-events.d.ts +0 -2
  179. package/dist/core/setup-container-touch-events.d.ts +0 -2
  180. package/dist/core/setup-element-events.d.ts +0 -2
  181. package/dist/core/setup-zoom-buttons.d.ts +0 -2
  182. package/dist/core/update-size.d.ts +0 -2
  183. package/dist/data-visualization.d.ts +0 -17
  184. package/dist/defaults/events.d.ts +0 -1
  185. package/dist/defaults/options.d.ts +0 -1
  186. package/dist/event-handler.d.ts +0 -1
  187. package/dist/legend.d.ts +0 -17
  188. package/dist/map.d.ts +0 -81
  189. package/dist/maps/brasil.d.ts +0 -2
  190. package/dist/maps/brasil.js +0 -7
  191. package/dist/maps/canada.d.ts +0 -2
  192. package/dist/maps/canada.js +0 -7
  193. package/dist/maps/iraq.d.ts +0 -2
  194. package/dist/maps/iraq.js +0 -84
  195. package/dist/maps/italy.d.ts +0 -2
  196. package/dist/maps/italy.js +0 -7
  197. package/dist/maps/russia.d.ts +0 -2
  198. package/dist/maps/russia.js +0 -366
  199. package/dist/maps/spain.d.ts +0 -2
  200. package/dist/maps/spain.js +0 -7
  201. package/dist/maps/us-aea-en.d.ts +0 -2
  202. package/dist/maps/us-aea-en.js +0 -7
  203. package/dist/maps/us-lcc-en.d.ts +0 -2
  204. package/dist/maps/us-lcc-en.js +0 -7
  205. package/dist/maps/us-merc-en.d.ts +0 -2
  206. package/dist/maps/us-merc-en.js +0 -7
  207. package/dist/maps/us-mill-en.d.ts +0 -2
  208. package/dist/maps/us-mill-en.js +0 -7
  209. package/dist/maps/world-merc.d.ts +0 -2
  210. package/dist/maps/world-merc.js +0 -7
  211. package/dist/maps/world.d.ts +0 -2
  212. package/dist/maps/world.js +0 -7
  213. package/dist/projection.d.ts +0 -1
  214. package/dist/scales/ordinal-scale.d.ts +0 -12
  215. package/dist/series.d.ts +0 -14
  216. package/dist/svg/base-element.d.ts +0 -19
  217. package/dist/svg/canvas-element.d.ts +0 -21
  218. package/dist/svg/image-element.d.ts +0 -12
  219. package/dist/svg/shape-element.d.ts +0 -19
  220. package/dist/svg/text-element.d.ts +0 -7
  221. package/dist/types.d.ts +0 -418
  222. package/dist/util/deep-merge.d.ts +0 -2
  223. package/dist/util/index.d.ts +0 -18
  224. package/dist/utils.d.ts +0 -87
  225. package/dist/vector-map.d.ts +0 -5
package/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) Chris Breuer
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -2,170 +2,208 @@
2
2
 
3
3
  [![npm version][npm-version-src]][npm-version-href]
4
4
  [![GitHub Actions][github-actions-src]][github-actions-href]
5
- [![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)
5
+ [![Commitizen friendly][commitizen-friendly]][commitizen-href]
6
6
 
7
7
  # ts-maps
8
8
 
9
- > Modern TypeScript library for creating stunning vector maps
9
+ > A zero-dependency, TypeScript-native, interactive mapping library.
10
10
 
11
11
  ## Features
12
12
 
13
- - 🗺️ **Vector Maps**
14
- - High-quality SVG-based interactive maps
15
- - Multiple projection types (Mercator, Equal Earth)
16
- - Built-in world maps and custom regions
13
+ - 🗺️ **`TsMap`** — modern interactive slippy map with fractional zoom,
17
14
 
18
- - 📊 **Data Visualization**
19
- - Choropleth maps with customizable scales
20
- - Heat maps and bubble charts
21
- - Interactive legends and tooltips
15
+ bearing, pitch, and unified camera animations (`flyTo`, `easeTo`,
16
+ `jumpTo`).
22
17
 
23
- - 🎯 **Framework Agnostic**
24
- - Zero dependencies
25
- - Works with any framework
26
- - Official React and Vue bindings
18
+ - 🧱 **Vector tiles** — in-house MVT decoder + Mapbox GL Style Spec
27
19
 
28
- - 🔒 **Type Safety**
29
- - Full TypeScript support
30
- - Strict types for better DX
31
- - Comprehensive type definitions
20
+ subset with a full expression engine (`interpolate`, `step`, `case`,
21
+ `match`, `coalesce`, `feature-state`). `queryRenderedFeatures` and
22
+ `querySourceFeatures` backed by a per-tile R-tree.
32
23
 
33
- ## Installation
24
+ - 🏔️ **3D** — `fill-extrusion`, atmospheric `setFog`, `setSky`, and
34
25
 
35
- ```bash
36
- # Using npm
37
- npm install ts-maps
26
+ DEM-based `setTerrain` with auto-loaded tiles from a `raster-dem`
27
+ source. `addCustomLayer()` lets apps render raw WebGL2 alongside.
28
+
29
+ - 🌍 **Globe** — seamless Mercator-to-globe transition around zoom 5.5
30
+
31
+ with an atmosphere halo.
32
+
33
+ - 🧭 **Services** — geocoding / directions / isochrones / matrix
34
+
35
+ adapters with keyless defaults (Nominatim, OSRM, Valhalla) and
36
+ opt-in commercial providers (Mapbox, Google, Maptiler, Photon).
37
+
38
+ - 📴 **Offline** — IndexedDB-backed `TileCache`, `saveOfflineRegion`
39
+
40
+ pre-fetcher, worker pool for off-main-thread tile decode.
41
+
42
+ - 🧩 **Layer-scoped events** — `map.on('click', 'layer-id', handler)`.
43
+
44
+ - 🎯 **Zero runtime deps.** Subpath exports (`ts-maps/services`,
45
+
46
+ `ts-maps/style-spec`, …) let callers pull in just one slice.
38
47
 
39
- # Using pnpm
40
- pnpm add ts-maps
48
+ - 🔒 **TypeScript-native** — strict types, `isolatedDeclarations`
41
49
 
42
- # Using yarn
43
- yarn add ts-maps
50
+ compliant, typed events, declaration files for every public module.
44
51
 
45
- # Using bun
46
- bun add ts-maps
52
+ ## Installation
53
+
54
+ ```bash
55
+ bun add ts-maps # or: npm install ts-maps / pnpm add ts-maps / yarn add ts-maps
47
56
  ```
48
57
 
49
58
  ### Framework Bindings
50
59
 
51
60
  ```bash
52
- # React
53
- npm install ts-maps ts-maps-react
61
+ bun add @ts-maps/react # React
62
+ bun add @ts-maps/vue # Vue 3
63
+ bun add @ts-maps/svelte # Svelte
64
+ bun add @ts-maps/solid # SolidJS
65
+ bun add ts-maps-nuxt # Nuxt module
66
+ bun add @ts-maps/react-native # React Native (WebView-hosted)
67
+ ```
68
+
69
+ ### Subpath imports for tree-shaking
54
70
 
55
- # Vue
56
- npm install ts-maps ts-maps-vue
71
+ Pull in only the part you need:
72
+
73
+ ```ts
74
+ import { defaultGeocoder } from 'ts-maps/services'
75
+ import { validateStyle } from 'ts-maps/style-spec'
76
+ import { TileCache } from 'ts-maps/storage'
77
+ import { LatLng, LatLngBounds } from 'ts-maps/geo'
57
78
  ```
58
79
 
80
+ Full list: `services`, `style-spec`, `storage`, `geo`, `geometry`,
81
+ `symbols`.
82
+
59
83
  ## Quick Start
60
84
 
61
- ```typescript
62
- import type { VectorMapOptions } from 'ts-maps'
63
- import { VectorMap } from 'ts-maps'
64
-
65
- // Create a map instance
66
- const map = new VectorMap({
67
- container: 'map',
68
- map: 'world',
69
- theme: 'light',
70
- style: {
71
- regions: {
72
- fill: '#e4e4e4',
73
- stroke: '#ffffff',
74
- strokeWidth: 1,
75
- },
76
- hover: {
77
- fill: '#2ca25f',
78
- },
79
- },
80
- })
85
+ ```ts
86
+ import 'ts-maps/styles.css'
87
+ import { Marker, tileLayer, TsMap } from 'ts-maps'
81
88
 
82
- // Add interactivity
83
- map.on('regionClick', (event, region) => {
84
- console.log(`Clicked: ${region.id}`)
89
+ const map = new TsMap('map', {
90
+ center: [40.758, -73.9855],
91
+ zoom: 13,
85
92
  })
93
+
94
+ tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', {
95
+ attribution: '© OpenStreetMap contributors',
96
+ }).addTo(map)
97
+
98
+ new Marker([40.758, -73.9855])
99
+ .addTo(map)
100
+ .bindPopup('Hello from ts-maps')
101
+ .openPopup()
86
102
  ```
87
103
 
88
- ### Data Visualization
104
+ ### Vector tiles + style spec
89
105
 
90
- ```typescript
91
- import type { DataVisualizationOptions } from 'ts-maps'
92
- import { VectorMap } from 'ts-maps'
106
+ ```ts
107
+ import { vectorTileLayer } from 'ts-maps'
93
108
 
94
- const map = new VectorMap({
95
- container: 'map',
96
- map: 'world',
109
+ vectorTileLayer({
110
+ url: 'https://tiles.example.com/{z}/{x}/{y}.pbf',
111
+ layers: [
112
+ { id: 'water', type: 'fill', sourceLayer: 'water', paint: { 'fill-color': '#0ea5e9' } },
113
+ { id: 'major-roads', type: 'line', sourceLayer: 'transportation',
114
+ filter: ['match', ['get', 'class'], ['primary', 'trunk'], true, false],
115
+ paint: { 'line-color': '#6b7280', 'line-width': ['interpolate', ['linear'], ['zoom'], 10, 0.5, 16, 3] } },
116
+ ],
117
+ }).addTo(map)
118
+
119
+ // Layer-scoped events:
120
+ map.on('click', 'major-roads', (e) => {
121
+ console.log('road clicked', e.features[0].properties)
97
122
  })
123
+ ```
124
+
125
+ ### 3D — fog, sky, terrain, fill-extrusion, custom WebGL
98
126
 
99
- // Add data visualization
100
- const options: DataVisualizationOptions = {
101
- scale: ['#e5f5f9', '#2ca25f'], // Color gradient from light blue to green
102
- values: {
103
- US: 100,
104
- CA: 80,
105
- GB: 65,
106
- },
107
- }
108
-
109
- map.visualizeData(options)
127
+ ```ts
128
+ map.setPitch(50)
129
+
130
+ map.addSource('terrain-dem', {
131
+ type: 'raster-dem',
132
+ tiles: ['https://tiles.example.com/terrain-rgb/{z}/{x}/{y}.png'],
133
+ tileSize: 512,
134
+ encoding: 'mapbox',
135
+ })
136
+ map.setTerrain({ source: 'terrain-dem', exaggeration: 1.4 })
137
+ map.setSky({ 'sky-color': '#87ceeb', 'horizon-color': '#ffffff' })
138
+ map.setFog({ color: 'rgb(245, 247, 250)', 'horizon-blend': 0.1 })
139
+
140
+ // Bilinear ground elevation lookup (uses the loaded DEM tile pyramid).
141
+ const metres = map.queryTerrainElevation({ lng: -74, lat: 40.7 })
142
+
143
+ // Custom WebGL layer — rendered every frame alongside the built-in layers:
144
+ map.addCustomLayer({
145
+ id: 'my-layer',
146
+ type: 'custom',
147
+ render(gl, projectionMatrix) { /* …your GL draws here… */ },
148
+ })
110
149
  ```
111
150
 
112
- ### React Component
113
-
114
- ```tsx
115
- import type { VectorMapProps } from 'ts-maps-react'
116
- import { useVectorMap } from 'ts-maps-react'
117
-
118
- function WorldMap() {
119
- const { map, isLoading } = useVectorMap({
120
- map: 'world',
121
- theme: 'light',
122
- })
123
-
124
- return (
125
- <div className="map-container">
126
- {isLoading
127
- ? (
128
- <div>Loading...</div>
129
- )
130
- : (
131
- <div id="map" />
132
- )}
133
- </div>
134
- )
135
- }
151
+ ### Services — geocoding, directions, isochrones, matrix
152
+
153
+ ```ts
154
+ import { services } from 'ts-maps'
155
+
156
+ const geocoder = services.defaultGeocoder() // Nominatim, keyless
157
+ const hits = await geocoder.search('Tower Bridge, London')
158
+
159
+ const directions = services.defaultDirections() // OSRM, keyless
160
+ const routes = await directions.getDirections(
161
+ [{ lat: 51.5055, lng: -0.0754 }, { lat: 51.5074, lng: -0.1278 }],
162
+ { profile: 'driving' },
163
+ )
164
+
165
+ const matrix = services.defaultMatrix() // OSRM /table
166
+ const m = await matrix.getMatrix(
167
+ [{ lat: 51.5055, lng: -0.0754 }, { lat: 51.5074, lng: -0.1278 }, { lat: 51.5155, lng: -0.1408 }],
168
+ { profile: 'driving' },
169
+ )
136
170
  ```
137
171
 
138
- ### Vue Component
172
+ ### Offline tiles
139
173
 
140
- ```vue
141
- <script setup lang="ts">
142
- import type { VectorMapOptions } from 'ts-maps'
143
- import { useVectorMap } from 'ts-maps-vue'
174
+ ```ts
175
+ import { saveOfflineRegion, TileCache } from 'ts-maps'
144
176
 
145
- const { map, isLoading } = useVectorMap({
146
- map: 'world',
147
- theme: 'light',
177
+ const cache = new TileCache({ maxBytes: 200 * 1024 * 1024 })
178
+ await saveOfflineRegion({
179
+ bounds: [-0.20, 51.50, -0.05, 51.53],
180
+ zoomRange: [10, 14],
181
+ tileUrl: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png',
182
+ cache,
148
183
  })
149
- </script>
150
-
151
- <template>
152
- <div class="map-container">
153
- <div v-if="isLoading">
154
- Loading...
155
- </div>
156
- <div v-else id="map" />
157
- </div>
158
- </template>
184
+ // Later, when tearing down: await cache.close()
159
185
  ```
160
186
 
187
+ ### Static image export
188
+
189
+ ```ts
190
+ const dataUrl = await map.toDataURL()
191
+ const blob = await map.toBlob('image/png')
192
+ ```
193
+
194
+ See the [docs folder][docs] for the full concept guides, API reference,
195
+ and runnable examples.
196
+
197
+ [docs]: ../../docs
198
+
161
199
  ## Documentation
162
200
 
163
- - [Introduction](https://ts-maps.dev/intro)
164
- - [Installation](https://ts-maps.dev/install)
165
- - [Usage Guide](https://ts-maps.dev/usage)
166
- - [API Reference](https://ts-maps.dev/api)
167
- - [Examples](https://ts-maps.dev/examples)
168
- - [Playground](https://ts-maps.dev/playground)
201
+ - [Introduction][introduction]
202
+ - [Installation][installation]
203
+ - [Usage Guide][usage-guide]
204
+ - [API Reference][api-reference]
205
+ - [Examples][examples]
206
+ - [Playground][playground]
169
207
 
170
208
  ## Development
171
209
 
@@ -179,36 +217,36 @@ cd ts-maps
179
217
  2. Install dependencies:
180
218
 
181
219
  ```bash
182
- pnpm install
220
+ bun install
183
221
  ```
184
222
 
185
223
  3. Start development:
186
224
 
187
225
  ```bash
188
- pnpm dev
226
+ bun run dev
189
227
  ```
190
228
 
191
229
  ## Changelog
192
230
 
193
- Please see our [releases](https://github.com/stacksjs/ts-maps/releases) page for more information on what has changed recently.
231
+ Please see our [releases][releases] page for more information on what has changed recently.
194
232
 
195
233
  ## Contributing
196
234
 
197
- Please see [CONTRIBUTING](https://github.com/stacksjs/stacks/blob/main/.github/CONTRIBUTING.md) for details.
235
+ Please see [CONTRIBUTING][contributing] for details.
198
236
 
199
237
  ## Community
200
238
 
201
239
  For help, discussion about best practices, or any other conversation that would benefit from being searchable:
202
240
 
203
- [Discussions on GitHub](https://github.com/stacksjs/ts-maps/discussions)
241
+ [Discussions on GitHub][discussions-on-github]
204
242
 
205
243
  For casual chit-chat with others using this package:
206
244
 
207
- [Join the Stacks Discord Server](https://discord.gg/stacksjs)
245
+ [Join the Stacks Discord Server][join-the-stacks-discord-server]
208
246
 
209
247
  ## Postcardware
210
248
 
211
- Software that is free, but hopes for a postcard.” We love receiving postcards from around the world showing where `ts-maps` is being used! We showcase them on our website too.
249
+ "Software that is free, but hopes for a postcard." We love receiving postcards from around the world showing where `ts-maps` is being used! We showcase them on our website too.
212
250
 
213
251
  Our address: Stacks.js, 12665 Village Ln #2306, Playa Vista, CA 90094, United States 🌎
214
252
 
@@ -216,26 +254,49 @@ Our address: Stacks.js, 12665 Village Ln #2306, Playa Vista, CA 90094, United St
216
254
 
217
255
  We would like to extend our thanks to the following sponsors for funding Stacks development. If you are interested in becoming a sponsor, please reach out to us.
218
256
 
219
- - [JetBrains](https://www.jetbrains.com/)
220
- - [The Solana Foundation](https://solana.com/)
257
+ - [JetBrains][jetbrains]
258
+ - [The Solana Foundation][the-solana-foundation]
221
259
 
222
260
  ## Credits
223
261
 
224
- - [jsvectormap](https://github.com/themustafaomar/jsvectormap)
225
- - [Chris Breuer](https://github.com/chrisbbreuer)
226
- - [All Contributors](https://github.com/stacksjs/ts-maps/contributors)
262
+ - [Leaflet][leaflet] — the module layout and public API shape of the
263
+
264
+ interactive map API follow its design.
265
+
266
+ - [Mapbox GL JS][mapbox-gl-js] — the style spec, expression engine, and
267
+
268
+ vector-tile renderer are modeled after its design.
269
+
270
+ - [Chris Breuer][chris-breuer]
271
+ - [All Contributors][all-contributors]
227
272
 
228
273
  ## License
229
274
 
230
- The MIT License (MIT). Please see [LICENSE](https://github.com/stacksjs/clarity/blob/main/LICENSE.md) for more information.
275
+ The MIT License (MIT). Please see [LICENSE][license] for more information.
231
276
 
232
277
  Made with 💙
233
278
 
234
279
  <!-- Badges -->
235
- [npm-version-src]: https://img.shields.io/npm/v/@stacksjs/clarity?style=flat-square
236
- [npm-version-href]: https://npmjs.com/package/@stacksjs/clarity
237
- [github-actions-src]: https://img.shields.io/github/actions/workflow/status/stacksjs/clarity/ci.yml?style=flat-square&branch=main
238
- [github-actions-href]: https://github.com/stacksjs/clarity/actions?query=workflow%3Aci
239
-
240
- <!-- [codecov-src]: https://img.shields.io/codecov/c/gh/stacksjs/clarity/main?style=flat-square
241
- [codecov-href]: https://codecov.io/gh/stacksjs/clarity -->
280
+ [npm-version-src]: https://img.shields.io/npm/v/ts-maps?style=flat-square
281
+ [npm-version-href]: https://npmjs.com/package/ts-maps
282
+ [github-actions-src]: https://img.shields.io/github/actions/workflow/status/stacksjs/ts-maps/ci.yml?style=flat-square&branch=main
283
+ [github-actions-href]: https://github.com/stacksjs/ts-maps/actions?query=workflow%3Aci
284
+ [commitizen-friendly]: https://img.shields.io/badge/commitizen-friendly-brightgreen.svg
285
+ [introduction]: https://ts-maps.dev/intro
286
+ [installation]: https://ts-maps.dev/install
287
+ [usage-guide]: https://ts-maps.dev/usage
288
+ [api-reference]: https://ts-maps.dev/api
289
+ [examples]: https://ts-maps.dev/examples
290
+ [playground]: https://ts-maps.dev/playground
291
+ [releases]: https://github.com/stacksjs/ts-maps/releases
292
+ [contributing]: https://github.com/stacksjs/stacks/blob/main/.github/CONTRIBUTING.md
293
+ [discussions-on-github]: https://github.com/stacksjs/ts-maps/discussions
294
+ [join-the-stacks-discord-server]: https://stacksjs.com/discord
295
+ [jetbrains]: https://www.jetbrains.com/
296
+ [the-solana-foundation]: https://solana.com/
297
+ [leaflet]: https://leafletjs.com/
298
+ [mapbox-gl-js]: https://github.com/mapbox/mapbox-gl-js
299
+ [chris-breuer]: https://github.com/chrisbbreuer
300
+ [all-contributors]: https://github.com/stacksjs/ts-maps/contributors
301
+ [license]: https://github.com/stacksjs/ts-maps/blob/main/LICENSE.md
302
+ [commitizen-href]: http://commitizen.github.io/cz-cli/
@@ -0,0 +1,8 @@
1
+ /*.svg)` in CSS).
2
+ */
3
+ /** Classic map pin (Leaflet-compatible proportions). */
4
+ export declare const MARKER_ICON_DATA_URI: string;
5
+ /** Soft drop shadow under the default pin. */
6
+ export declare const MARKER_SHADOW_DATA_URI: string;
7
+ /** Layers control toggle (stacked tiles). */
8
+ export declare const LAYERS_TOGGLE_DATA_URI: string;
@@ -0,0 +1,12 @@
1
+ import { Control } from './Control';
2
+ export declare class AttributionControl extends Control {
3
+ _attributions: Record<string, number>;
4
+ initialize(options?: any): void;
5
+ onAdd(map: any): HTMLElement;
6
+ onRemove(map: any): void;
7
+ _addAttribution(ev: any): void;
8
+ setPrefix(prefix: string | false): this;
9
+ addAttribution(text: string): this;
10
+ removeAttribution(text: string): this;
11
+ _update(): void;
12
+ }
@@ -0,0 +1,14 @@
1
+ import { Class } from '../core/Class';
2
+ export declare class Control extends Class {
3
+ _map: any;
4
+ _container?: HTMLElement;
5
+ onAdd(_map: any): HTMLElement;
6
+ onRemove(_map: any): void;
7
+ initialize(...args: any[]): void;
8
+ getPosition(): string;
9
+ setPosition(position: string): this;
10
+ getContainer(): HTMLElement | undefined;
11
+ addTo(map: any): this;
12
+ remove(): this;
13
+ _refocusOnMap(e: any): void;
14
+ }
@@ -0,0 +1,38 @@
1
+ import { Control } from './Control';
2
+ declare interface LayerEntry {
3
+ layer: any
4
+ name: string
5
+ overlay?: boolean
6
+ }
7
+ export declare class LayersControl extends Control {
8
+ _layerControlInputs: any[];
9
+ _layers: LayerEntry[];
10
+ _lastZIndex: number;
11
+ _handlingClick: boolean;
12
+ _preventClick: boolean;
13
+ _section: HTMLElement;
14
+ _separator: HTMLElement;
15
+ _baseLayersList: HTMLElement;
16
+ _overlaysList: HTMLElement;
17
+ _layersLink: HTMLAnchorElement;
18
+ _collapseDelayTimeout?: ReturnType<typeof setTimeout>;
19
+ initialize(baseLayers?: Record<string, any>, overlays?: Record<string, any>, options?: any): void;
20
+ onAdd(map: any): HTMLElement;
21
+ addTo(map: any): this;
22
+ onRemove(): void;
23
+ addBaseLayer(layer: any, name: string): this;
24
+ addOverlay(layer: any, name: string): this;
25
+ removeLayer(layer: any): this;
26
+ expand(): this;
27
+ collapse(ev?: any): this;
28
+ _initLayout(): void;
29
+ _getLayer(id: number): LayerEntry | undefined;
30
+ _addLayer(layer: any, name: string, overlay?: boolean): void;
31
+ _update(): this;
32
+ _onLayerChange(e: any): void;
33
+ _addItem(obj: LayerEntry): HTMLLabelElement;
34
+ _onInputClick(e: any): void;
35
+ _checkDisabledLayers(): void;
36
+ _expandIfNotCollapsed(): this;
37
+ _expandSafely(): void;
38
+ }
@@ -0,0 +1,14 @@
1
+ import { Control } from './Control';
2
+ export declare class ScaleControl extends Control {
3
+ _mScale?: HTMLElement;
4
+ _iScale?: HTMLElement;
5
+ onAdd(map: any): HTMLElement;
6
+ onRemove(map: any): void;
7
+ _addScales(options: any, className: string, container: HTMLElement): void;
8
+ _update(): void;
9
+ _updateScales(maxMeters: number): void;
10
+ _updateMetric(maxMeters: number): void;
11
+ _updateImperial(maxMeters: number): void;
12
+ _updateScale(scale: HTMLElement, text: string, ratio: number): void;
13
+ _getRoundNum(num: number): number;
14
+ }
@@ -0,0 +1,14 @@
1
+ import { Control } from './Control';
2
+ export declare class ZoomControl extends Control {
3
+ _zoomInButton?: HTMLAnchorElement;
4
+ _zoomOutButton?: HTMLAnchorElement;
5
+ _disabled?: boolean;
6
+ onAdd(map: any): HTMLElement;
7
+ onRemove(map: any): void;
8
+ disable(): this;
9
+ enable(): this;
10
+ _zoomIn(e: any): void;
11
+ _zoomOut(e: any): void;
12
+ _createButton(html: string, title: string, className: string, container: HTMLElement, fn: (e: any) => void): HTMLAnchorElement;
13
+ _updateDisabled(): void;
14
+ }
@@ -0,0 +1,5 @@
1
+ export { AttributionControl } from './AttributionControl';
2
+ export { Control } from './Control';
3
+ export { LayersControl } from './LayersControl';
4
+ export { ScaleControl } from './ScaleControl';
5
+ export { ZoomControl } from './ZoomControl';
@@ -0,0 +1,24 @@
1
+ // Browser feature detection used internally.
2
+ declare function userAgentContains(str: string): boolean;
3
+ declare const chrome: unknown;
4
+ declare const safari: unknown;
5
+ declare const mobile: boolean;
6
+ declare const pointer: boolean;
7
+ declare const touchNative: boolean;
8
+ declare const touch: unknown;
9
+ declare const retina: boolean;
10
+ declare const mac: boolean;
11
+ declare const linux: boolean;
12
+ declare const Browser: BrowserInfo;
13
+ export declare interface BrowserInfo {
14
+ chrome: boolean
15
+ safari: boolean
16
+ mobile: boolean
17
+ pointer: boolean
18
+ touch: boolean
19
+ touchNative: boolean
20
+ retina: boolean
21
+ mac: boolean
22
+ linux: boolean
23
+ }
24
+ export default Browser;
@@ -0,0 +1,12 @@
1
+ export declare class Class {
2
+ static include(props: Record<string, any>): typeof Class;
3
+ static setDefaultOptions(options: Record<string, any>): typeof Class;
4
+ static mergeOptions(options: Record<string, any>): typeof Class;
5
+ static addInitHook(fn: string | (() => void), ...args: any[]): typeof Class;
6
+ options?: Record<string, any>;
7
+ _initHooksCalled: boolean;
8
+ _initHooks?: Array<() => void>;
9
+ initialize(..._args: any[]): void;
10
+ constructor(...args: any[]);
11
+ callInitHooks(): void;
12
+ }
@@ -0,0 +1,31 @@
1
+ import { Class } from './Class';
2
+ export declare interface EventListener {
3
+ fn: (event?: any) => void
4
+ ctx?: any
5
+ once?: boolean
6
+ }
7
+ export type EventHandler = (_event?: any) => void;
8
+ // A set of methods shared between event-powered classes (like Map and Marker).
9
+ export declare class Evented extends Class {
10
+ static __REMOVED_EVENTS: string[];
11
+ _events?: Record<string, EventListener[]>;
12
+ _eventParents?: Record<number, Evented>;
13
+ _firingCount?: number;
14
+ on(types: string | Record<string, EventHandler>, fn?: EventHandler | any, context?: any): this;
15
+ off(types?: string | Record<string, EventHandler>, fn?: EventHandler | any, context?: any): this;
16
+ _on(type: string, fn: EventHandler, context?: any, _once?: boolean): void;
17
+ _off(type: string, fn?: EventHandler, context?: any): void;
18
+ fire(type: string, data?: Record<string, any>, propagate?: boolean): this;
19
+ listens(type: string, fn?: EventHandler | boolean, context?: any, propagate?: boolean): boolean;
20
+ _listens(type: string, fn?: EventHandler, context?: any): number | false;
21
+ once(types: string | Record<string, EventHandler>, fn?: EventHandler | any, context?: any): this;
22
+ addEventParent(obj: Evented): this;
23
+ removeEventParent(obj: Evented): this;
24
+ _propagateEvent(e: any): void;
25
+ addEventListener: Evented['on'];
26
+ removeEventListener: Evented['off'];
27
+ clearAllEventListeners: Evented['off'];
28
+ addOneTimeEventListener: Evented['once'];
29
+ fireEvent: Evented['fire'];
30
+ hasEventListeners: Evented['listens'];
31
+ }
@@ -0,0 +1,12 @@
1
+ import { Class } from './Class';
2
+ export declare class Handler extends Class {
3
+ _map: any;
4
+ _enabled: boolean;
5
+ static addTo(this: any, map: any, name: string): any;
6
+ initialize(...args: any[]): void;
7
+ enable(): this;
8
+ disable(): this;
9
+ enabled(): boolean;
10
+ addHooks(): void;
11
+ removeHooks(): void;
12
+ }