@antv/l7-map 2.22.7 → 2.23.1

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/es/index.d.ts CHANGED
@@ -1,3 +1,5 @@
1
+ export { MapMouseEvent } from './map/events';
1
2
  export { MercatorCoordinate } from './map/geo/mercator_coordinate';
2
3
  export { Map } from './map/map';
3
4
  export type { MapOptions } from './map/map';
5
+ export { SimpleMapCoord, type ISimpleMapCoord } from './map/util/simpleMapCoord';
package/es/index.js CHANGED
@@ -1,2 +1,4 @@
1
+ export { MapMouseEvent } from "./map/events";
1
2
  export { MercatorCoordinate } from "./map/geo/mercator_coordinate";
2
- export { Map } from "./map/map";
3
+ export { Map } from "./map/map";
4
+ export { SimpleMapCoord } from "./map/util/simpleMapCoord";
package/es/map/events.js CHANGED
@@ -2,6 +2,7 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
2
  import { Event } from "./util/evented";
3
3
  import Point from '@mapbox/point-geometry';
4
4
  import { DOM } from "./util/dom";
5
+ import { SimpleMapCoord } from "./util/simpleMapCoord";
5
6
 
6
7
  /**
7
8
  * `MapEventType` - a mapping between the event name and the event value.
@@ -94,6 +95,14 @@ export class MapMouseEvent extends Event {
94
95
  this.originalEvent = originalEvent;
95
96
  this._defaultPrevented = false;
96
97
  this.target = map;
98
+ if (map.version === 'SIMPLE') {
99
+ const simpleMapCoord = new SimpleMapCoord(map.mapSize);
100
+ const [lng, lat] = simpleMapCoord.project([lngLat.lng, lngLat.lat]);
101
+ this.lngLat = {
102
+ lng,
103
+ lat
104
+ };
105
+ }
97
106
  }
98
107
  }
99
108
 
@@ -457,7 +457,7 @@ export class Transform {
457
457
  }
458
458
  }
459
459
  customLayerMatrix() {
460
- return this.mercatorMatrix.slice();
460
+ return mat4.clone(this.mercatorMatrix);
461
461
  }
462
462
 
463
463
  /**
package/es/map/map.d.ts CHANGED
@@ -25,6 +25,16 @@ import type { TaskID } from './util/task_queue';
25
25
  * The {@link Map} options object.
26
26
  */
27
27
  export type MapOptions = {
28
+ /**
29
+ * The MapType of the map.
30
+ * @defaultValue DEFAUlTMAP
31
+ */
32
+ version?: string;
33
+ /**
34
+ * The map size for SIMPLE map.
35
+ * @defaultValue 10000
36
+ */
37
+ mapSize?: number;
28
38
  /**
29
39
  * If `false`, no mouse, touch, or keyboard listeners will be attached to the map, so it will not respond to interaction.
30
40
  * @defaultValue true
@@ -209,6 +219,8 @@ export declare class Map extends Camera {
209
219
  _mapId: number;
210
220
  _removed: boolean;
211
221
  _clickTolerance: number;
222
+ version: string;
223
+ mapSize: number;
212
224
  /**
213
225
  * The map's {@link ScrollZoomHandler}, which implements zooming in and out with a scroll wheel or trackpad.
214
226
  * Find more details and examples using `scrollZoom` in the {@link ScrollZoomHandler} section.
@@ -508,7 +520,7 @@ export declare class Map extends Camera {
508
520
  * @param type - The type of the event.
509
521
  * @param listener - The listener callback.
510
522
  */
511
- on<T extends keyof MapEventType>(type: T, listener: (ev: MapEventType[T] & Object) => void): this;
523
+ on<T extends keyof MapEventType>(type: T, listener: (ev: MapEventType[T] & object) => void): this;
512
524
  /**
513
525
  * Overload of the `on` method that allows to listen to events without specifying a layer.
514
526
  * @event
@@ -522,7 +534,7 @@ export declare class Map extends Camera {
522
534
  * @param type - The type of the event.
523
535
  * @param listener - The listener callback.
524
536
  */
525
- once<T extends keyof MapEventType>(type: T, listener?: (ev: MapEventType[T] & Object) => void): this | Promise<any>;
537
+ once<T extends keyof MapEventType>(type: T, listener?: (ev: MapEventType[T] & object) => void): this | Promise<any>;
526
538
  /**
527
539
  * Overload of the `once` method that allows to listen to events without specifying a layer.
528
540
  * @event
@@ -536,7 +548,7 @@ export declare class Map extends Camera {
536
548
  * @param type - The type of the event.
537
549
  * @param listener - The function previously installed as a listener.
538
550
  */
539
- off<T extends keyof MapEventType>(type: T, listener: (ev: MapEventType[T] & Object) => void): this;
551
+ off<T extends keyof MapEventType>(type: T, listener: (ev: MapEventType[T] & object) => void): this;
540
552
  /**
541
553
  * Overload of the `off` method that allows to listen to events without specifying a layer.
542
554
  * @event
package/es/map/map.js CHANGED
@@ -319,6 +319,8 @@ export class Map extends Camera {
319
319
  _defineProperty(this, "_mapId", uniqueId());
320
320
  _defineProperty(this, "_removed", void 0);
321
321
  _defineProperty(this, "_clickTolerance", void 0);
322
+ _defineProperty(this, "version", void 0);
323
+ _defineProperty(this, "mapSize", void 0);
322
324
  /**
323
325
  * The map's {@link ScrollZoomHandler}, which implements zooming in and out with a scroll wheel or trackpad.
324
326
  * Find more details and examples using `scrollZoom` in the {@link ScrollZoomHandler} section.
@@ -378,6 +380,8 @@ export class Map extends Camera {
378
380
  this._bearingSnap = resolvedOptions.bearingSnap;
379
381
  this._fadeDuration = resolvedOptions.fadeDuration;
380
382
  this._clickTolerance = resolvedOptions.clickTolerance;
383
+ this.version = options.version;
384
+ this.mapSize = options.mapSize;
381
385
  if (typeof resolvedOptions.container === 'string') {
382
386
  this._container = document.getElementById(resolvedOptions.container);
383
387
  if (!this._container) {
@@ -0,0 +1,31 @@
1
+ export interface ISimpleMapCoord {
2
+ setSize(size: number): void;
3
+ getSize(): [number, number];
4
+ project(lnglat: [number, number]): [number, number];
5
+ unproject(xy: [number, number]): [number, number];
6
+ }
7
+ export declare class SimpleMapCoord implements ISimpleMapCoord {
8
+ private size;
9
+ constructor(size?: number);
10
+ setSize(size: number): void;
11
+ getSize(): [number, number];
12
+ /**
13
+ * coord
14
+ * ^ y (y > 0)
15
+ * |
16
+ * |
17
+ * |
18
+ * |(x = 0, y = 0)
19
+ * ---------------> x (x > 0)
20
+ */
21
+ /***
22
+ * lng: [-180, 180] 360
23
+ * lat: [-85.05112877980659, 85.05112877980659] 170.10225755961318
24
+ */
25
+ mercatorXfromLng(lng: number): number;
26
+ mercatorYfromLat(lat: number): number;
27
+ lngFromMercatorX(x: number): number;
28
+ latFromMercatorY(y: number): number;
29
+ project(lnglat: [number, number]): [number, number];
30
+ unproject(xy: [number, number]): [number, number];
31
+ }
@@ -0,0 +1,54 @@
1
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
+ export class SimpleMapCoord {
3
+ constructor(size) {
4
+ _defineProperty(this, "size", 10000);
5
+ this.size = size ? size : 10000;
6
+ }
7
+ setSize(size) {
8
+ this.size = size;
9
+ }
10
+ getSize() {
11
+ return [this.size, this.size];
12
+ }
13
+
14
+ /**
15
+ * coord
16
+ * ^ y (y > 0)
17
+ * |
18
+ * |
19
+ * |
20
+ * |(x = 0, y = 0)
21
+ * ---------------> x (x > 0)
22
+ */
23
+
24
+ /***
25
+ * lng: [-180, 180] 360
26
+ * lat: [-85.05112877980659, 85.05112877980659] 170.10225755961318
27
+ */
28
+
29
+ mercatorXfromLng(lng) {
30
+ // (0 - 1) * this.size
31
+ return (180 + lng) / 360 * this.size;
32
+ }
33
+ mercatorYfromLat(lat) {
34
+ // (0 - 1) * this.size
35
+ return (1 - (180 - 180 / Math.PI * Math.log(Math.tan(Math.PI / 4 + lat * Math.PI / 360))) / 360) * this.size;
36
+ }
37
+ lngFromMercatorX(x) {
38
+ return x / this.size * 360 - 180;
39
+ }
40
+ latFromMercatorY(y) {
41
+ const y2 = 180 - (1 - y / this.size) * 360;
42
+ return 360 / Math.PI * Math.atan(Math.exp(y2 * Math.PI / 180)) - 90;
43
+ }
44
+ project(lnglat) {
45
+ const x = this.mercatorXfromLng(lnglat[0]);
46
+ const y = this.mercatorYfromLat(lnglat[1]);
47
+ return [x, y];
48
+ }
49
+ unproject(xy) {
50
+ const lng = this.lngFromMercatorX(xy[0]);
51
+ const lat = this.latFromMercatorY(xy[1]);
52
+ return [lng, lat];
53
+ }
54
+ }
package/lib/index.d.ts CHANGED
@@ -1,3 +1,5 @@
1
+ export { MapMouseEvent } from './map/events';
1
2
  export { MercatorCoordinate } from './map/geo/mercator_coordinate';
2
3
  export { Map } from './map/map';
3
4
  export type { MapOptions } from './map/map';
5
+ export { SimpleMapCoord, type ISimpleMapCoord } from './map/util/simpleMapCoord';
package/lib/index.js CHANGED
@@ -9,11 +9,25 @@ Object.defineProperty(exports, "Map", {
9
9
  return _map.Map;
10
10
  }
11
11
  });
12
+ Object.defineProperty(exports, "MapMouseEvent", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _events.MapMouseEvent;
16
+ }
17
+ });
12
18
  Object.defineProperty(exports, "MercatorCoordinate", {
13
19
  enumerable: true,
14
20
  get: function () {
15
21
  return _mercator_coordinate.MercatorCoordinate;
16
22
  }
17
23
  });
24
+ Object.defineProperty(exports, "SimpleMapCoord", {
25
+ enumerable: true,
26
+ get: function () {
27
+ return _simpleMapCoord.SimpleMapCoord;
28
+ }
29
+ });
30
+ var _events = require("./map/events");
18
31
  var _mercator_coordinate = require("./map/geo/mercator_coordinate");
19
- var _map = require("./map/map");
32
+ var _map = require("./map/map");
33
+ var _simpleMapCoord = require("./map/util/simpleMapCoord");
package/lib/map/events.js CHANGED
@@ -9,6 +9,7 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
9
9
  var _evented = require("./util/evented");
10
10
  var _pointGeometry = _interopRequireDefault(require("@mapbox/point-geometry"));
11
11
  var _dom = require("./util/dom");
12
+ var _simpleMapCoord = require("./util/simpleMapCoord");
12
13
  /**
13
14
  * `MapEventType` - a mapping between the event name and the event value.
14
15
  * These events are used with the {@link Map#on} method.
@@ -100,6 +101,14 @@ class MapMouseEvent extends _evented.Event {
100
101
  this.originalEvent = originalEvent;
101
102
  this._defaultPrevented = false;
102
103
  this.target = map;
104
+ if (map.version === 'SIMPLE') {
105
+ const simpleMapCoord = new _simpleMapCoord.SimpleMapCoord(map.mapSize);
106
+ const [lng, lat] = simpleMapCoord.project([lngLat.lng, lngLat.lat]);
107
+ this.lngLat = {
108
+ lng,
109
+ lat
110
+ };
111
+ }
103
112
  }
104
113
  }
105
114
 
@@ -464,7 +464,7 @@ class Transform {
464
464
  }
465
465
  }
466
466
  customLayerMatrix() {
467
- return this.mercatorMatrix.slice();
467
+ return _glMatrix.mat4.clone(this.mercatorMatrix);
468
468
  }
469
469
 
470
470
  /**
package/lib/map/map.d.ts CHANGED
@@ -25,6 +25,16 @@ import type { TaskID } from './util/task_queue';
25
25
  * The {@link Map} options object.
26
26
  */
27
27
  export type MapOptions = {
28
+ /**
29
+ * The MapType of the map.
30
+ * @defaultValue DEFAUlTMAP
31
+ */
32
+ version?: string;
33
+ /**
34
+ * The map size for SIMPLE map.
35
+ * @defaultValue 10000
36
+ */
37
+ mapSize?: number;
28
38
  /**
29
39
  * If `false`, no mouse, touch, or keyboard listeners will be attached to the map, so it will not respond to interaction.
30
40
  * @defaultValue true
@@ -209,6 +219,8 @@ export declare class Map extends Camera {
209
219
  _mapId: number;
210
220
  _removed: boolean;
211
221
  _clickTolerance: number;
222
+ version: string;
223
+ mapSize: number;
212
224
  /**
213
225
  * The map's {@link ScrollZoomHandler}, which implements zooming in and out with a scroll wheel or trackpad.
214
226
  * Find more details and examples using `scrollZoom` in the {@link ScrollZoomHandler} section.
@@ -508,7 +520,7 @@ export declare class Map extends Camera {
508
520
  * @param type - The type of the event.
509
521
  * @param listener - The listener callback.
510
522
  */
511
- on<T extends keyof MapEventType>(type: T, listener: (ev: MapEventType[T] & Object) => void): this;
523
+ on<T extends keyof MapEventType>(type: T, listener: (ev: MapEventType[T] & object) => void): this;
512
524
  /**
513
525
  * Overload of the `on` method that allows to listen to events without specifying a layer.
514
526
  * @event
@@ -522,7 +534,7 @@ export declare class Map extends Camera {
522
534
  * @param type - The type of the event.
523
535
  * @param listener - The listener callback.
524
536
  */
525
- once<T extends keyof MapEventType>(type: T, listener?: (ev: MapEventType[T] & Object) => void): this | Promise<any>;
537
+ once<T extends keyof MapEventType>(type: T, listener?: (ev: MapEventType[T] & object) => void): this | Promise<any>;
526
538
  /**
527
539
  * Overload of the `once` method that allows to listen to events without specifying a layer.
528
540
  * @event
@@ -536,7 +548,7 @@ export declare class Map extends Camera {
536
548
  * @param type - The type of the event.
537
549
  * @param listener - The function previously installed as a listener.
538
550
  */
539
- off<T extends keyof MapEventType>(type: T, listener: (ev: MapEventType[T] & Object) => void): this;
551
+ off<T extends keyof MapEventType>(type: T, listener: (ev: MapEventType[T] & object) => void): this;
540
552
  /**
541
553
  * Overload of the `off` method that allows to listen to events without specifying a layer.
542
554
  * @event
package/lib/map/map.js CHANGED
@@ -325,6 +325,8 @@ class Map extends _camera.Camera {
325
325
  (0, _defineProperty2.default)(this, "_mapId", (0, _util.uniqueId)());
326
326
  (0, _defineProperty2.default)(this, "_removed", void 0);
327
327
  (0, _defineProperty2.default)(this, "_clickTolerance", void 0);
328
+ (0, _defineProperty2.default)(this, "version", void 0);
329
+ (0, _defineProperty2.default)(this, "mapSize", void 0);
328
330
  /**
329
331
  * The map's {@link ScrollZoomHandler}, which implements zooming in and out with a scroll wheel or trackpad.
330
332
  * Find more details and examples using `scrollZoom` in the {@link ScrollZoomHandler} section.
@@ -384,6 +386,8 @@ class Map extends _camera.Camera {
384
386
  this._bearingSnap = resolvedOptions.bearingSnap;
385
387
  this._fadeDuration = resolvedOptions.fadeDuration;
386
388
  this._clickTolerance = resolvedOptions.clickTolerance;
389
+ this.version = options.version;
390
+ this.mapSize = options.mapSize;
387
391
  if (typeof resolvedOptions.container === 'string') {
388
392
  this._container = document.getElementById(resolvedOptions.container);
389
393
  if (!this._container) {
@@ -0,0 +1,31 @@
1
+ export interface ISimpleMapCoord {
2
+ setSize(size: number): void;
3
+ getSize(): [number, number];
4
+ project(lnglat: [number, number]): [number, number];
5
+ unproject(xy: [number, number]): [number, number];
6
+ }
7
+ export declare class SimpleMapCoord implements ISimpleMapCoord {
8
+ private size;
9
+ constructor(size?: number);
10
+ setSize(size: number): void;
11
+ getSize(): [number, number];
12
+ /**
13
+ * coord
14
+ * ^ y (y > 0)
15
+ * |
16
+ * |
17
+ * |
18
+ * |(x = 0, y = 0)
19
+ * ---------------> x (x > 0)
20
+ */
21
+ /***
22
+ * lng: [-180, 180] 360
23
+ * lat: [-85.05112877980659, 85.05112877980659] 170.10225755961318
24
+ */
25
+ mercatorXfromLng(lng: number): number;
26
+ mercatorYfromLat(lat: number): number;
27
+ lngFromMercatorX(x: number): number;
28
+ latFromMercatorY(y: number): number;
29
+ project(lnglat: [number, number]): [number, number];
30
+ unproject(xy: [number, number]): [number, number];
31
+ }
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.SimpleMapCoord = void 0;
8
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
+ class SimpleMapCoord {
10
+ constructor(size) {
11
+ (0, _defineProperty2.default)(this, "size", 10000);
12
+ this.size = size ? size : 10000;
13
+ }
14
+ setSize(size) {
15
+ this.size = size;
16
+ }
17
+ getSize() {
18
+ return [this.size, this.size];
19
+ }
20
+
21
+ /**
22
+ * coord
23
+ * ^ y (y > 0)
24
+ * |
25
+ * |
26
+ * |
27
+ * |(x = 0, y = 0)
28
+ * ---------------> x (x > 0)
29
+ */
30
+
31
+ /***
32
+ * lng: [-180, 180] 360
33
+ * lat: [-85.05112877980659, 85.05112877980659] 170.10225755961318
34
+ */
35
+
36
+ mercatorXfromLng(lng) {
37
+ // (0 - 1) * this.size
38
+ return (180 + lng) / 360 * this.size;
39
+ }
40
+ mercatorYfromLat(lat) {
41
+ // (0 - 1) * this.size
42
+ return (1 - (180 - 180 / Math.PI * Math.log(Math.tan(Math.PI / 4 + lat * Math.PI / 360))) / 360) * this.size;
43
+ }
44
+ lngFromMercatorX(x) {
45
+ return x / this.size * 360 - 180;
46
+ }
47
+ latFromMercatorY(y) {
48
+ const y2 = 180 - (1 - y / this.size) * 360;
49
+ return 360 / Math.PI * Math.atan(Math.exp(y2 * Math.PI / 180)) - 90;
50
+ }
51
+ project(lnglat) {
52
+ const x = this.mercatorXfromLng(lnglat[0]);
53
+ const y = this.mercatorYfromLat(lnglat[1]);
54
+ return [x, y];
55
+ }
56
+ unproject(xy) {
57
+ const lng = this.lngFromMercatorX(xy[0]);
58
+ const lat = this.latFromMercatorY(xy[1]);
59
+ return [lng, lat];
60
+ }
61
+ }
62
+ exports.SimpleMapCoord = SimpleMapCoord;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antv/l7-map",
3
- "version": "2.22.7",
3
+ "version": "2.23.1",
4
4
  "description": "L7 Map",
5
5
  "keywords": [],
6
6
  "homepage": "https://github.com/antvis/L7#readme",
@@ -27,7 +27,7 @@
27
27
  "@mapbox/unitbezier": "^0.0.1",
28
28
  "eventemitter3": "^4.0.4",
29
29
  "gl-matrix": "^3.1.0",
30
- "@antv/l7-utils": "2.22.7"
30
+ "@antv/l7-utils": "2.23.1"
31
31
  },
32
32
  "devDependencies": {
33
33
  "@types/mapbox__point-geometry": "^0.1.4"