surprise
2023-12-29 18377dc5d61caf3a6a0835e17015ac2601f8709d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
function yzPanorama() {
  this._x_PI = (3e3 * Math.PI) / 180;
  this._ee = 0.006693421622965943;
  this._ellipsoid = {
    x: 6378245,
    y: 6378245,
    z: 6356863.0188
  };
}
yzPanorama.prototype.open = function(option) {
  this.elementId = option.id;
  this.closeId = option.closeId;
  let closeBtn = document.getElementById(this.closeId);
  document.getElementById(this.elementId).style = "display:block";
  closeBtn.style = "display:block";
  let _this = this;
  closeBtn.onclick = function (){
    _this.close();
  }
  let panorama = new BMap.Panorama(this.elementId);
 
  let py = this._wgs84togcj02({
    lng: option.lng,
    lat: option.lat
  });
 
  let bdzb = this._gcj02tobd09({
    lng: py.lng,
    lat: py.lat
  });
 
  panorama.setPosition(new BMap.Point(bdzb.lng, bdzb.lat));
  panorama.setOptions({
    navigationControl: true,
    albumsControl: false,
    closeControl: false,
    enableScrollWheelOutPanorama: true
  });
};
yzPanorama.prototype.close = function() {
  document.getElementById(this.elementId).style = "display:none";
  document.getElementById(this.closeId).style = "display:none";
};
yzPanorama.prototype._out_of_china = function(t, e) {
  return (e = +e), !((t = +t) > 73.66 && t < 135.05 && e > 3.86 && e < 53.55);
};
 
yzPanorama.prototype._transformlat = function(t, e) {
  var i =
    2 * (t = +t) -
    100 +
    3 * (e = +e) +
    0.2 * e * e +
    0.1 * t * e +
    0.2 * Math.sqrt(Math.abs(t));
  return (
    (i +=
      (2 * (20 * Math.sin(6 * t * Math.PI) + 20 * Math.sin(2 * t * Math.PI))) /
      3),
    (i +=
      (2 * (20 * Math.sin(e * Math.PI) + 40 * Math.sin((e / 3) * Math.PI))) /
      3) +
      (2 *
        (160 * Math.sin((e / 12) * Math.PI) +
          320 * Math.sin((e * Math.PI) / 30))) /
        3
  );
};
yzPanorama.prototype._transformlng = function(t, e) {
  var i =
    300 +
    (t = +t) +
    2 * (e = +e) +
    0.1 * t * t +
    0.1 * t * e +
    0.1 * Math.sqrt(Math.abs(t));
  return (
    (i +=
      (2 * (20 * Math.sin(6 * t * Math.PI) + 20 * Math.sin(2 * t * Math.PI))) /
      3),
    (i +=
      (2 * (20 * Math.sin(t * Math.PI) + 40 * Math.sin((t / 3) * Math.PI))) /
      3) +
      (2 *
        (150 * Math.sin((t / 12) * Math.PI) +
          300 * Math.sin((t / 30) * Math.PI))) /
        3
  );
};
yzPanorama.prototype._gcj02tobd09 = function(t) {
  var e = +t.lat,
    i = +t.lng,
    o = Math.sqrt(i * i + e * e) + 2e-5 * Math.sin(e * this._x_PI),
    n = Math.atan2(e, i) + 3e-6 * Math.cos(i * this._x_PI);
  return {
    lng: o * Math.cos(n) + 0.0065,
    lat: o * Math.sin(n) + 0.006
  };
};
yzPanorama.prototype._wgs84togcj02 = function(t) {
  var e = +t.lat,
    i = +t.lng;
  if (this._out_of_china(i, e)) return t;
  var o = this._transformlat(i - 105, e - 35),
    n = this._transformlng(i - 105, e - 35),
    r = (e / 180) * Math.PI,
    a = Math.sin(r);
  a = 1 - this._ee * a * a;
  var s = Math.sqrt(a);
  return (
    (o =
      (180 * o) / (((this._ellipsoid.x * (1 - this._ee)) / (a * s)) * Math.PI)),
    {
      lng:
        i + (n = (180 * n) / ((this._ellipsoid.x / s) * Math.cos(r) * Math.PI)),
      lat: e + o
    }
  );
};