Skip to content

Commit 5e5aadb

Browse files
committed
[fix]修改多时相例子时间轴没加载的问题
1 parent 19b7b32 commit 5e5aadb

File tree

4 files changed

+22
-8
lines changed

4 files changed

+22
-8
lines changed

examples/leaflet/multiphaseplay.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@
116116
}
117117

118118
function addTimeLine() {
119-
var allTime = allFeatures.map(feature => feature.time.split('/')[0]);
119+
var allTime = ['2009', '2010', '2011', '2012', '2013', '2014', '2015', '2016'];
120120
myChart = echarts.init(document.getElementById('timeline'));
121121
var option = {
122122
timeline: {
@@ -149,8 +149,8 @@
149149
myChart.on('timelinechanged', function (params) {
150150
var url = wmsUrlCache[params.currentIndex];
151151
layer.setUrl(url);
152-
changeTimelinePlay(false);
153152
layer.once("load", changeTimelinePlay);
153+
changeTimelinePlay(false);
154154
});
155155
}
156156

examples/mapboxgl/multiphaseplay.html

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,15 @@
122122
}
123123

124124
function start() {
125+
map.on('sourcedata', onSourceData);
125126
addStaticImageLayer();
126-
map.on('load', addTimeLine);
127+
}
128+
129+
function onSourceData(e) {
130+
if (e.sourceId === 'static-image-layer' && e.isSourceLoaded) {
131+
map.off('sourcedata', onSourceData);
132+
addTimeLine();
133+
}
127134
}
128135

129136
function addStaticImageLayer() {
@@ -142,7 +149,7 @@
142149
}
143150

144151
function addTimeLine() {
145-
var allTime = allFeatures.map(feature => feature.time.split('/')[0]);
152+
var allTime = ['2009', '2010', '2011', '2012', '2013', '2014', '2015', '2016'];
146153
myChart = echarts.init(document.getElementById('timeline'));
147154
var option = {
148155
timeline: {
@@ -177,8 +184,8 @@
177184
map.getSource('static-image-layer').updateImage({
178185
url: url
179186
});
180-
changeTimelinePlay(false);
181187
map.once('idle', changeTimelinePlay);
188+
changeTimelinePlay(false);
182189
});
183190
}
184191

examples/maplibregl/multiphaseplay.html

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,15 @@
122122
}
123123

124124
function start() {
125+
map.on('sourcedata', onSourceData);
125126
addStaticImageLayer();
126-
map.on('load', addTimeLine)
127+
}
128+
129+
function onSourceData(e) {
130+
if (e.sourceId === 'static-image-layer' && e.isSourceLoaded) {
131+
map.off('sourcedata', onSourceData);
132+
addTimeLine();
133+
}
127134
}
128135

129136
function addStaticImageLayer() {
@@ -177,8 +184,8 @@
177184
map.getSource('static-image-layer').updateImage({
178185
url: url
179186
});
180-
changeTimelinePlay(false);
181187
map.once('idle', changeTimelinePlay);
188+
changeTimelinePlay(false);
182189
});
183190
}
184191

examples/openlayers/multiphaseplay.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@
135135
}
136136

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

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy