ts-maps 0.3.0 → 0.3.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.
@@ -0,0 +1,53 @@
1
+ import { Control } from './Control';
2
+ /**
3
+ * "Where am I" — the crosshair button every map is expected to have.
4
+ *
5
+ * Centres the map on the device's own position and, unless told otherwise,
6
+ * keeps following it as the position updates. The button carries its own state
7
+ * so the user is never left wondering whether anything happened:
8
+ *
9
+ * idle the outline crosshair
10
+ * locating pulsing, while the first fix is being acquired
11
+ * active filled, while the map is following the device
12
+ * denied struck through, when permission was refused or the fix failed
13
+ *
14
+ * Geolocation is requested on CLICK and never on load. A permission prompt
15
+ * that appears unasked is the fastest way to be denied for the rest of the
16
+ * session, and a denied permission cannot be re-requested without the user
17
+ * going into browser settings.
18
+ *
19
+ * Following stops the moment the user pans, drags, or zooms by hand: a map
20
+ * that yanks itself back under a finger is worse than one that does nothing.
21
+ */
22
+ export declare interface LocateControlOptions {
23
+ position?: string
24
+ zoom?: number | null
25
+ follow?: boolean
26
+ enableHighAccuracy?: boolean
27
+ timeout?: number
28
+ maximumAge?: number
29
+ title?: string
30
+ titleLocating?: string
31
+ titleActive?: string
32
+ titleDenied?: string
33
+ showMarker?: boolean
34
+ }
35
+ export declare class LocateControl extends Control {
36
+ _button?: HTMLAnchorElement;
37
+ _watchId?: number;
38
+ _following?: boolean;
39
+ _marker?: any;
40
+ _accuracyCircle?: any;
41
+ onAdd(map: any): HTMLElement;
42
+ onRemove(map: any): void;
43
+ start(): this;
44
+ stop(): this;
45
+ _onClick(): void;
46
+ _locate(): void;
47
+ _onPosition(position: GeolocationPosition, recenter: boolean): void;
48
+ _updateMarker(latlng: [number, number], accuracy: number): void;
49
+ _clearMarker(): void;
50
+ _stopFollowing(): void;
51
+ _clearWatch(): void;
52
+ _setState(state: 'idle' | 'locating' | 'active' | 'denied'): void;
53
+ }
@@ -1,5 +1,7 @@
1
+ export type { LocateControlOptions } from './LocateControl';
1
2
  export { AttributionControl } from './AttributionControl';
2
3
  export { Control } from './Control';
3
4
  export { LayersControl } from './LayersControl';
5
+ export { LocateControl } from './LocateControl';
4
6
  export { ScaleControl } from './ScaleControl';
5
7
  export { ZoomControl } from './ZoomControl';
@@ -40,17 +40,17 @@ var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
40
40
  // src/core-map/core/Util.ts
41
41
  var exports_Util = {};
42
42
  __export(exports_Util, {
43
- wrapNum: () => wrapNum,
44
- throttle: () => throttle,
45
- template: () => template,
46
- stamp: () => stamp,
47
- splitWords: () => splitWords,
48
- setOptions: () => setOptions,
49
- setLastId: () => setLastId,
50
- noop: () => noop,
51
- lastId: () => lastId,
43
+ falseFn: () => falseFn,
52
44
  formatNum: () => formatNum,
53
- falseFn: () => falseFn
45
+ lastId: () => lastId,
46
+ noop: () => noop,
47
+ setLastId: () => setLastId,
48
+ setOptions: () => setOptions,
49
+ splitWords: () => splitWords,
50
+ stamp: () => stamp,
51
+ template: () => template,
52
+ throttle: () => throttle,
53
+ wrapNum: () => wrapNum
54
54
  });
55
55
  function stamp(obj) {
56
56
  if (!("_tsmap_id" in obj)) {
@@ -1022,10 +1022,10 @@ init_TerrainSource();
1022
1022
  // src/core-map/geo/projection/index.ts
1023
1023
  var exports_projection = {};
1024
1024
  __export(exports_projection, {
1025
- SphericalMercator: () => SphericalMercator,
1026
- Mercator: () => Mercator,
1025
+ Globe: () => Globe,
1027
1026
  LonLat: () => LonLat,
1028
- Globe: () => Globe
1027
+ Mercator: () => Mercator,
1028
+ SphericalMercator: () => SphericalMercator
1029
1029
  });
1030
1030
 
1031
1031
  // src/core-map/geo/projection/Projection.Globe.ts
@@ -1182,23 +1182,23 @@ class SimpleCRS extends CRS {
1182
1182
  }
1183
1183
  }
1184
1184
  export {
1185
- toLatLngBounds,
1186
- toLatLng,
1187
- sampleElevationBilinear,
1188
- getElevationDecoder,
1189
- decodeTerrariumRGB,
1190
- decodeMapboxRGB,
1191
- decodeElevationGrid,
1192
- buildTerrainMesh,
1193
- TerrainSource,
1194
- SimpleCRS,
1195
- exports_projection as Projection,
1196
- LatLngBounds,
1197
- LatLng,
1198
- EarthCRS,
1199
- EPSG900913,
1200
- EPSG4326,
1201
- EPSG3857,
1185
+ CRS,
1202
1186
  EPSG3395,
1203
- CRS
1187
+ EPSG3857,
1188
+ EPSG4326,
1189
+ EPSG900913,
1190
+ EarthCRS,
1191
+ LatLng,
1192
+ LatLngBounds,
1193
+ exports_projection as Projection,
1194
+ SimpleCRS,
1195
+ TerrainSource,
1196
+ buildTerrainMesh,
1197
+ decodeElevationGrid,
1198
+ decodeMapboxRGB,
1199
+ decodeTerrariumRGB,
1200
+ getElevationDecoder,
1201
+ sampleElevationBilinear,
1202
+ toLatLng,
1203
+ toLatLngBounds
1204
1204
  };
@@ -40,17 +40,17 @@ var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
40
40
  // src/core-map/core/Util.ts
41
41
  var exports_Util = {};
42
42
  __export(exports_Util, {
43
- wrapNum: () => wrapNum,
44
- throttle: () => throttle,
45
- template: () => template,
46
- stamp: () => stamp,
47
- splitWords: () => splitWords,
48
- setOptions: () => setOptions,
49
- setLastId: () => setLastId,
50
- noop: () => noop,
51
- lastId: () => lastId,
43
+ falseFn: () => falseFn,
52
44
  formatNum: () => formatNum,
53
- falseFn: () => falseFn
45
+ lastId: () => lastId,
46
+ noop: () => noop,
47
+ setLastId: () => setLastId,
48
+ setOptions: () => setOptions,
49
+ splitWords: () => splitWords,
50
+ stamp: () => stamp,
51
+ template: () => template,
52
+ throttle: () => throttle,
53
+ wrapNum: () => wrapNum
54
54
  });
55
55
  function stamp(obj) {
56
56
  if (!("_tsmap_id" in obj)) {
@@ -1291,23 +1291,23 @@ init_LatLngBounds();
1291
1291
  init_Point();
1292
1292
  var exports_LineUtil = {};
1293
1293
  __export(exports_LineUtil, {
1294
- simplify: () => simplify,
1295
- polylineCenter: () => polylineCenter,
1296
- pointToSegmentDistance: () => pointToSegmentDistance,
1297
- isFlat: () => isFlat,
1298
- closestPointOnSegment: () => closestPointOnSegment,
1299
- clipSegment: () => clipSegment,
1300
- _sqClosestPointOnSegment: () => _sqClosestPointOnSegment,
1294
+ _getBitCode: () => _getBitCode,
1301
1295
  _getEdgeIntersection: () => _getEdgeIntersection,
1302
- _getBitCode: () => _getBitCode
1296
+ _sqClosestPointOnSegment: () => _sqClosestPointOnSegment,
1297
+ clipSegment: () => clipSegment,
1298
+ closestPointOnSegment: () => closestPointOnSegment,
1299
+ isFlat: () => isFlat,
1300
+ pointToSegmentDistance: () => pointToSegmentDistance,
1301
+ polylineCenter: () => polylineCenter,
1302
+ simplify: () => simplify
1303
1303
  });
1304
1304
 
1305
1305
  // src/core-map/geometry/PolyUtil.ts
1306
1306
  var exports_PolyUtil = {};
1307
1307
  __export(exports_PolyUtil, {
1308
- polygonCenter: () => polygonCenter,
1308
+ centroid: () => centroid,
1309
1309
  clipPolygon: () => clipPolygon,
1310
- centroid: () => centroid
1310
+ polygonCenter: () => polygonCenter
1311
1311
  });
1312
1312
  init_LatLng();
1313
1313
  init_LatLngBounds();
@@ -1574,13 +1574,13 @@ function polylineCenter(latlngs, crs) {
1574
1574
  return new LatLng(latlngCenter.lat + centroidLatLng.lat, latlngCenter.lng + centroidLatLng.lng);
1575
1575
  }
1576
1576
  export {
1577
- toTransformation,
1578
- toPoint,
1579
- toBounds,
1580
- Transformation,
1581
- RTree,
1582
- exports_PolyUtil as PolyUtil,
1583
- Point,
1577
+ Bounds,
1584
1578
  exports_LineUtil as LineUtil,
1585
- Bounds
1579
+ Point,
1580
+ exports_PolyUtil as PolyUtil,
1581
+ RTree,
1582
+ Transformation,
1583
+ toBounds,
1584
+ toPoint,
1585
+ toTransformation
1586
1586
  };
@@ -1,4 +1,4 @@
1
- import { AttributionControl, Control, LayersControl, ScaleControl, ZoomControl } from './control/index';
1
+ import { AttributionControl, Control, LayersControl, LocateControl, ScaleControl, ZoomControl } from './control/index';
2
2
  import { Circle, CircleMarker, DivIcon, FeatureGroup, GeoJSON, GridLayer, HeatmapLayer, RasterDEMLayer, Icon, ImageOverlay, LayerGroup, Marker, Polygon, Polyline, Popup, Rectangle, SVGOverlay, TileLayer, Tooltip, VectorTileMapLayer, VideoOverlay, WMSTileLayer } from './layer/index';
3
3
  import { TsMap } from './map/index';
4
4
  import * as services from './services/index';
@@ -40,6 +40,7 @@ export declare const control: Factory < ConstructorParameters < typeof Control>,
40
40
  layers: Factory < ConstructorParameters < typeof LayersControl>, LayersControl>
41
41
  attribution: Factory < ConstructorParameters < typeof AttributionControl>, AttributionControl>
42
42
  scale: Factory < ConstructorParameters < typeof ScaleControl>, ScaleControl>
43
+ locate: Factory < ConstructorParameters < typeof LocateControl>, LocateControl>
43
44
  };
44
45
  // Default namespace object grouping all public exports.
45
46
  declare const tsMap: Record<string, unknown>;
@@ -1,4 +1,5 @@
1
1
  import { Evented } from '../core/Events';
2
+ import { TsMap } from '../map/Map';
2
3
  export declare class Layer extends Evented {
3
4
  _map?: any;
4
5
  _mapToAdd?: any;
@@ -16,3 +17,11 @@ export declare class Layer extends Evented {
16
17
  getAttribution(): string | null | undefined;
17
18
  _layerAdd(e: any): void;
18
19
  }
20
+ declare module '../map/Map' {
21
+ interface TsMap {
22
+ addLayer: (layer: Layer) => this
23
+ removeLayer: (layer: Layer) => this
24
+ hasLayer: (layer: Layer) => boolean
25
+ eachLayer: (method: (layer: Layer) => void, context?: unknown) => this
26
+ }
27
+ }
@@ -1,5 +1,7 @@
1
1
  import { DivOverlay } from './DivOverlay';
2
+ import { Layer } from './Layer';
2
3
  import { Point } from '../geometry/Point';
4
+ import { TsMap } from '../map/Map';
3
5
  export declare class Popup extends DivOverlay {
4
6
  _wrapper?: HTMLElement;
5
7
  _tipContainer?: HTMLElement;
@@ -16,3 +18,21 @@ export declare class Popup extends DivOverlay {
16
18
  _adjustPan(): void;
17
19
  _getAnchor(): Point;
18
20
  }
21
+ declare module '../map/Map' {
22
+ interface TsMap {
23
+ openPopup: (popup: Popup | string | HTMLElement, latlng?: unknown, options?: Record<string, unknown>) => this
24
+ closePopup: (popup?: Popup) => this
25
+ }
26
+ }
27
+ declare module './Layer' {
28
+ interface Layer {
29
+ bindPopup: (content: Popup | string | HTMLElement, options?: Record<string, unknown>) => this
30
+ unbindPopup: () => this
31
+ openPopup: (latlng?: unknown) => this
32
+ closePopup: () => this
33
+ togglePopup: () => this
34
+ isPopupOpen: () => boolean
35
+ setPopupContent: (content: string | HTMLElement) => this
36
+ getPopup: () => Popup | undefined
37
+ }
38
+ }
@@ -131,7 +131,6 @@ export declare class TsMap extends Evented {
131
131
  touchRotate?: any;
132
132
  touchPitch?: any;
133
133
  _popup?: any;
134
- closePopup?: () => void;
135
134
  _style?: Style;
136
135
  _featureState?: globalThis.Map<string, Record<string, unknown>>;
137
136
  _layerHandlers?: globalThis.Map<string, Array<{
@@ -40,17 +40,17 @@ var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
40
40
  // src/core-map/core/Util.ts
41
41
  var exports_Util = {};
42
42
  __export(exports_Util, {
43
- wrapNum: () => wrapNum,
44
- throttle: () => throttle,
45
- template: () => template,
46
- stamp: () => stamp,
47
- splitWords: () => splitWords,
48
- setOptions: () => setOptions,
49
- setLastId: () => setLastId,
50
- noop: () => noop,
51
- lastId: () => lastId,
43
+ falseFn: () => falseFn,
52
44
  formatNum: () => formatNum,
53
- falseFn: () => falseFn
45
+ lastId: () => lastId,
46
+ noop: () => noop,
47
+ setLastId: () => setLastId,
48
+ setOptions: () => setOptions,
49
+ splitWords: () => splitWords,
50
+ stamp: () => stamp,
51
+ template: () => template,
52
+ throttle: () => throttle,
53
+ wrapNum: () => wrapNum
54
54
  });
55
55
  function stamp(obj) {
56
56
  if (!("_tsmap_id" in obj)) {
@@ -133,26 +133,26 @@ var init_Util = __esm(() => {
133
133
  // src/core-map/services/index.ts
134
134
  var exports_services = {};
135
135
  __export(exports_services, {
136
- valhallaMatrix: () => valhallaMatrix,
137
- valhallaDirections: () => valhallaDirections,
138
- defaultMatrix: () => defaultMatrix,
139
- defaultIsochrone: () => defaultIsochrone,
140
- defaultGeocoder: () => defaultGeocoder,
141
- defaultDirections: () => defaultDirections,
142
- ValhallaMatrix: () => ValhallaMatrix,
143
- ValhallaIsochrone: () => ValhallaIsochrone,
144
- ValhallaDirections: () => ValhallaDirections,
145
- PhotonGeocoder: () => PhotonGeocoder,
146
- OSRMMatrix: () => OSRMMatrix,
147
- OSRMDirections: () => OSRMDirections,
148
- NominatimGeocoder: () => NominatimGeocoder,
149
- MaptilerGeocoder: () => MaptilerGeocoder,
150
- MapboxMatrix: () => MapboxMatrix,
151
- MapboxIsochrone: () => MapboxIsochrone,
152
- MapboxGeocoder: () => MapboxGeocoder,
153
- MapboxDirections: () => MapboxDirections,
136
+ GoogleDirections: () => GoogleDirections,
154
137
  GoogleGeocoder: () => GoogleGeocoder,
155
- GoogleDirections: () => GoogleDirections
138
+ MapboxDirections: () => MapboxDirections,
139
+ MapboxGeocoder: () => MapboxGeocoder,
140
+ MapboxIsochrone: () => MapboxIsochrone,
141
+ MapboxMatrix: () => MapboxMatrix,
142
+ MaptilerGeocoder: () => MaptilerGeocoder,
143
+ NominatimGeocoder: () => NominatimGeocoder,
144
+ OSRMDirections: () => OSRMDirections,
145
+ OSRMMatrix: () => OSRMMatrix,
146
+ PhotonGeocoder: () => PhotonGeocoder,
147
+ ValhallaDirections: () => ValhallaDirections,
148
+ ValhallaIsochrone: () => ValhallaIsochrone,
149
+ ValhallaMatrix: () => ValhallaMatrix,
150
+ defaultDirections: () => defaultDirections,
151
+ defaultGeocoder: () => defaultGeocoder,
152
+ defaultIsochrone: () => defaultIsochrone,
153
+ defaultMatrix: () => defaultMatrix,
154
+ valhallaDirections: () => valhallaDirections,
155
+ valhallaMatrix: () => valhallaMatrix
156
156
  });
157
157
 
158
158
  // src/core-map/services/providers/Google.ts
@@ -1207,24 +1207,24 @@ var defaultMatrix = () => new OSRMMatrix;
1207
1207
  var valhallaMatrix = () => new ValhallaMatrix;
1208
1208
  var valhallaDirections = () => new ValhallaDirections;
1209
1209
  export {
1210
- valhallaMatrix,
1211
- valhallaDirections,
1212
- defaultMatrix,
1213
- defaultIsochrone,
1214
- defaultGeocoder,
1215
- defaultDirections,
1216
- ValhallaMatrix,
1217
- ValhallaIsochrone,
1218
- ValhallaDirections,
1219
- PhotonGeocoder,
1220
- OSRMMatrix,
1221
- OSRMDirections,
1222
- NominatimGeocoder,
1223
- MaptilerGeocoder,
1224
- MapboxMatrix,
1225
- MapboxIsochrone,
1226
- MapboxGeocoder,
1227
- MapboxDirections,
1210
+ GoogleDirections,
1228
1211
  GoogleGeocoder,
1229
- GoogleDirections
1212
+ MapboxDirections,
1213
+ MapboxGeocoder,
1214
+ MapboxIsochrone,
1215
+ MapboxMatrix,
1216
+ MaptilerGeocoder,
1217
+ NominatimGeocoder,
1218
+ OSRMDirections,
1219
+ OSRMMatrix,
1220
+ PhotonGeocoder,
1221
+ ValhallaDirections,
1222
+ ValhallaIsochrone,
1223
+ ValhallaMatrix,
1224
+ defaultDirections,
1225
+ defaultGeocoder,
1226
+ defaultIsochrone,
1227
+ defaultMatrix,
1228
+ valhallaDirections,
1229
+ valhallaMatrix
1230
1230
  };
@@ -274,10 +274,10 @@ var init_storage = __esm(() => {
274
274
  init_storage();
275
275
 
276
276
  export {
277
- saveOfflineRegion,
278
- resetDefaultCache,
279
- getDefaultCache,
280
- computeTileCoords,
277
+ TileCache,
281
278
  cachedFetch,
282
- TileCache
279
+ computeTileCoords,
280
+ getDefaultCache,
281
+ resetDefaultCache,
282
+ saveOfflineRegion
283
283
  };
@@ -2507,23 +2507,23 @@ init_expressions();
2507
2507
  init_schema();
2508
2508
  init_validate2();
2509
2509
  export {
2510
- validateStyle,
2511
- validateSource,
2512
- validatePaintProperty,
2513
- validateLayoutProperty,
2514
- validateLayer,
2515
- validateExpression,
2516
- sourceTypes,
2517
- parseColor,
2518
- paintPropertySchemas,
2519
- lerpColor,
2520
- layoutPropertySchemas,
2521
- layerTypes,
2522
- isExpression,
2523
- formatColor,
2524
- evaluate as evaluateExpression,
2525
- diffStyles,
2526
- convertLegacyFilter,
2510
+ ExpressionError,
2527
2511
  compile as compileExpression,
2528
- ExpressionError
2512
+ convertLegacyFilter,
2513
+ diffStyles,
2514
+ evaluate as evaluateExpression,
2515
+ formatColor,
2516
+ isExpression,
2517
+ layerTypes,
2518
+ layoutPropertySchemas,
2519
+ lerpColor,
2520
+ paintPropertySchemas,
2521
+ parseColor,
2522
+ sourceTypes,
2523
+ validateExpression,
2524
+ validateLayer,
2525
+ validateLayoutProperty,
2526
+ validatePaintProperty,
2527
+ validateSource,
2528
+ validateStyle
2529
2529
  };
@@ -495,7 +495,7 @@ function isImageData(v) {
495
495
  return typeof anyV.width === "number" && typeof anyV.height === "number" && (anyV.data instanceof Uint8ClampedArray || anyV.data instanceof Uint8Array);
496
496
  }
497
497
  export {
498
- IconAtlas,
498
+ CollisionIndex,
499
499
  GlyphAtlas,
500
- CollisionIndex
500
+ IconAtlas
501
501
  };