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
|
}
|
);
|
};
|