UNPKG

2.34 kBJavaScriptView Raw
1import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2import _createClass from "@babel/runtime/helpers/createClass";
3import WebMercatorViewport from 'viewport-mercator-project';
4
5var Viewport = function () {
6 function Viewport() {
7 _classCallCheck(this, Viewport);
8
9 this.viewport = void 0;
10 }
11
12 _createClass(Viewport, [{
13 key: "syncWithMapCamera",
14 value: function syncWithMapCamera(mapCamera) {
15 var center = mapCamera.center,
16 zoom = mapCamera.zoom,
17 pitch = mapCamera.pitch,
18 bearing = mapCamera.bearing,
19 viewportHeight = mapCamera.viewportHeight,
20 viewportWidth = mapCamera.viewportWidth;
21 this.viewport = new WebMercatorViewport({
22 width: viewportWidth,
23 height: viewportHeight,
24 longitude: center && center[0],
25 latitude: center && center[1],
26 zoom: zoom,
27 pitch: pitch,
28 bearing: bearing
29 });
30 }
31 }, {
32 key: "getZoom",
33 value: function getZoom() {
34 return this.viewport.zoom;
35 }
36 }, {
37 key: "getZoomScale",
38 value: function getZoomScale() {
39 return Math.pow(2, this.getZoom());
40 }
41 }, {
42 key: "getCenter",
43 value: function getCenter() {
44 return [this.viewport.longitude, this.viewport.latitude];
45 }
46 }, {
47 key: "getProjectionMatrix",
48 value: function getProjectionMatrix() {
49 return this.viewport.projectionMatrix;
50 }
51 }, {
52 key: "getViewMatrix",
53 value: function getViewMatrix() {
54 return this.viewport.viewMatrix;
55 }
56 }, {
57 key: "getViewMatrixUncentered",
58 value: function getViewMatrixUncentered() {
59 return this.viewport.viewMatrixUncentered;
60 }
61 }, {
62 key: "getViewProjectionMatrix",
63 value: function getViewProjectionMatrix() {
64 return this.viewport.viewProjectionMatrix;
65 }
66 }, {
67 key: "getViewProjectionMatrixUncentered",
68 value: function getViewProjectionMatrixUncentered() {
69 return this.viewport.viewProjectionMatrix;
70 }
71 }, {
72 key: "getFocalDistance",
73 value: function getFocalDistance() {
74 return 1;
75 }
76 }, {
77 key: "projectFlat",
78 value: function projectFlat(lngLat, scale) {
79 return this.viewport.projectFlat(lngLat, scale);
80 }
81 }]);
82
83 return Viewport;
84}();
85
86export { Viewport as default };
87//# sourceMappingURL=Viewport.js.map
\No newline at end of file