var yyfx_currentTime = '';
|
var yyfx_currentSpeed = '1x';
|
var timer = null;
|
var sgworld = parent.sgworld;
|
|
|
$('#speed').on('input propertychange', function (event) {
|
yyfx_currentSpeed = $(this).html();
|
});
|
|
$('#timeShadow').on('input propertychange', function (event) {
|
yyfx_handleSetCurrentTime($(this).html());
|
});
|
$(document).click(function (e) {
|
if($('.dateBox').css('display') == 'none') return;
|
var e = e || window.event;
|
if(e.target.id == 'timeShadow') return;
|
window.parent.fnLayerHauto(window.parent.SmartEarthPopupData.layerProp,'290')
|
})
|
|
// 时间设置
|
function yyfx_handleSetCurrentTime(params) {
|
timer = sgworld.Command.execute(3, 0, params);
|
clearInterval(timer);
|
timer = null;
|
yyfx_handleGetCurrentTime();
|
}
|
|
// 时间获取
|
function yyfx_handleGetCurrentTime() {
|
sgworld._Viewer.shadows = true;
|
yyfx_currentSpeed = $(parent.document).find('.cesium-viewer-animationContainer .cesium-animation-svgText tspan').eq(2).html();
|
$('#speed').val(yyfx_currentSpeed);
|
clearInterval(timer);
|
timer = null;
|
timer = setInterval(() => {
|
yyfx_currentTime = utcToBeijing(sgworld._Viewer.animation.viewModel.dateLabel, sgworld._Viewer.animation.viewModel.timeLabel);
|
$('#timeShadow').val(yyfx_currentTime);
|
}, 1000);
|
}
|
|
// 加速
|
function yyfx_handleSpeedIncress() {
|
sgworld.Command.execute(3, 1);
|
yyfx_currentSpeed = $(parent.document).find('.cesium-viewer-animationContainer .cesium-animation-svgText tspan').eq(2).html();
|
$('#speed').val(yyfx_currentSpeed);
|
if ((yyfx_currentSpeed[0] != '-') && (parent.currentPlayMode != '0')) {
|
parent.currentPlayMode = '1';
|
}
|
}
|
|
// 减速
|
function yyfx_handleSpeedDecress() {
|
sgworld.Command.execute(3, 2);
|
yyfx_currentSpeed = $(parent.document).find('.cesium-viewer-animationContainer .cesium-animation-svgText tspan').eq(2).html();
|
$('#speed').val(yyfx_currentSpeed);
|
if ((yyfx_currentSpeed[0] == '-') && (parent.currentPlayMode != '0')) {
|
parent.currentPlayMode = '2';
|
}
|
}
|
|
// 往前播放
|
function yyfx_handleForword() {
|
sgworld.Command.execute(3, 3);
|
parent.currentPlayMode = '1';
|
if (yyfx_currentSpeed[0] == '-') {
|
yyfx_currentSpeed = yyfx_currentSpeed.slice(1);
|
$('#speed').val(yyfx_currentSpeed);
|
}
|
}
|
|
// 往后播放
|
function yyfx_handleBacword() {
|
sgworld.Command.execute(3, 4);
|
parent.currentPlayMode = '2';
|
if (yyfx_currentSpeed[0] != '-') {
|
yyfx_currentSpeed = '-' + yyfx_currentSpeed;
|
$('#speed').val(yyfx_currentSpeed);
|
}
|
}
|
|
// 暂停
|
function yyfx_handlePause() {
|
if(parent.currentPlayMode !== '0'){
|
sgworld.Command.execute(3, 5);
|
parent.currentPlayMode = '0';
|
}
|
}
|
|
// utc时间转为北京时间
|
function utcToBeijing(date, time) {
|
// 转为正常的时间格式 年-月-日 时:分:秒
|
date = date.replace(/January|Jan/, '01').replace(/February|Feb/, '02')
|
.replace(/March|Mar/, '03').replace(/April|Apr/, '04')
|
.replace(/May/, '05').replace(/June|Jun/, '06')
|
.replace(/July|Jul/, '07').replace(/August|Aug/, '08')
|
.replace(/September|Sept/, '09').replace(/October|Oct/, '10')
|
.replace(/November|Nov/, '11').replace(/December|Dec/, '12');
|
|
const dateArr = date.split(' ');
|
date = `${dateArr[2]}-${dateArr[0]}-${dateArr[1]}`;
|
|
const timeArr = time.split(' ');
|
time = timeArr[0];
|
let timestamp = new Date(Date.parse(`${date} ${time}`));
|
timestamp = timestamp.getTime();
|
timestamp = timestamp / 1000;
|
|
// 增加8个小时,北京时间比utc时间多八个时区
|
timestamp = timestamp + 8 * 60 * 60;
|
|
// 时间戳转为时间
|
var beijing_datetime = new Date(parseInt(timestamp) * 1000).toLocaleString('chinese', {hour12: false}).replace(/年|月|\//g, "-").replace(/日/g, " ");
|
return beijing_datetime; // 2017-03-31 16:02:06
|
}
|