Skip to content

Commit

Permalink
[fix]修改多时相例子时间轴没加载的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
chenxianhuii committed Nov 27, 2024
1 parent 19b7b32 commit 5e5aadb
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 8 deletions.
4 changes: 2 additions & 2 deletions examples/leaflet/multiphaseplay.html
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@
}

function addTimeLine() {
var allTime = allFeatures.map(feature => feature.time.split('/')[0]);
var allTime = ['2009', '2010', '2011', '2012', '2013', '2014', '2015', '2016'];
myChart = echarts.init(document.getElementById('timeline'));
var option = {
timeline: {
Expand Down Expand Up @@ -149,8 +149,8 @@
myChart.on('timelinechanged', function (params) {
var url = wmsUrlCache[params.currentIndex];
layer.setUrl(url);
changeTimelinePlay(false);
layer.once("load", changeTimelinePlay);
changeTimelinePlay(false);
});
}

Expand Down
13 changes: 10 additions & 3 deletions examples/mapboxgl/multiphaseplay.html
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,15 @@
}

function start() {
map.on('sourcedata', onSourceData);
addStaticImageLayer();
map.on('load', addTimeLine);
}

function onSourceData(e) {
if (e.sourceId === 'static-image-layer' && e.isSourceLoaded) {
map.off('sourcedata', onSourceData);
addTimeLine();
}
}

function addStaticImageLayer() {
Expand All @@ -142,7 +149,7 @@
}

function addTimeLine() {
var allTime = allFeatures.map(feature => feature.time.split('/')[0]);
var allTime = ['2009', '2010', '2011', '2012', '2013', '2014', '2015', '2016'];
myChart = echarts.init(document.getElementById('timeline'));
var option = {
timeline: {
Expand Down Expand Up @@ -177,8 +184,8 @@
map.getSource('static-image-layer').updateImage({
url: url
});
changeTimelinePlay(false);
map.once('idle', changeTimelinePlay);
changeTimelinePlay(false);
});
}

Expand Down
11 changes: 9 additions & 2 deletions examples/maplibregl/multiphaseplay.html
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,15 @@
}

function start() {
map.on('sourcedata', onSourceData);
addStaticImageLayer();
map.on('load', addTimeLine)
}

function onSourceData(e) {
if (e.sourceId === 'static-image-layer' && e.isSourceLoaded) {
map.off('sourcedata', onSourceData);
addTimeLine();
}
}

function addStaticImageLayer() {
Expand Down Expand Up @@ -177,8 +184,8 @@
map.getSource('static-image-layer').updateImage({
url: url
});
changeTimelinePlay(false);
map.once('idle', changeTimelinePlay);
changeTimelinePlay(false);
});
}

Expand Down
2 changes: 1 addition & 1 deletion examples/openlayers/multiphaseplay.html
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@
}

function addTimeLine() {
var allTime = allFeatures.map(feature => feature.time.split('/')[0]);
var allTime = ['2009', '2010', '2011', '2012', '2013', '2014', '2015', '2016'];
myChart = echarts.init(document.getElementById('timeline'));
var option = {
timeline: {
Expand Down

0 comments on commit 5e5aadb

Please sign in to comment.