-
Notifications
You must be signed in to change notification settings - Fork 282
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
12fc838
commit 6520af5
Showing
14 changed files
with
877 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,189 @@ | ||
<!--******************************************************************** | ||
* Copyright© 2000 - 2024 SuperMap Software Co.Ltd. All rights reserved. | ||
*********************************************************************--> | ||
<!--******************************************************************** | ||
* 该示例需要引入 | ||
* Echarts (https://github.com/apache/echarts) | ||
*********************************************************************--> | ||
<!DOCTYPE html> | ||
<html> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<title data-i18n="resources.title_multiphaseplay"></title> | ||
<style> | ||
#timeline { | ||
position: absolute; | ||
bottom: 50px; | ||
width: 100%; | ||
height: 100px; | ||
z-index: 9999; | ||
} | ||
|
||
#title { | ||
position: absolute; | ||
top: 50px; | ||
left: 50%; | ||
transform: translateX(-50%); | ||
z-index: 9999; | ||
text-align: center; | ||
font-size: 24px; | ||
font-weight: bold; | ||
color: rgba(0, 0, 0, 0.85); | ||
} | ||
.subTitle { | ||
font-size: 16px; | ||
font-weight: normal | ||
} | ||
</style> | ||
<script type="text/javascript" src="../js/include-web.js"></script> | ||
</head> | ||
|
||
<body style=" margin: 0;overflow: hidden;background: #fff;width: 100%;height:100%;position: absolute;top: 0;"> | ||
<div id="title"> | ||
<div data-i18n="resources.text_multiphaseplay"></div> | ||
<div data-i18n="resources.text_2009To2016NDVI" class="subTitle"></div> | ||
</div> | ||
<div id="map" style="width: 100%;height:100%"></div> | ||
<div id="timeline"></div> | ||
<script type="text/javascript" include="echarts" src="../../dist/leaflet/include-leaflet.js"></script> | ||
<script type="text/javascript"> | ||
var host = window.isLocal ? window.server : "https://iserver.supermap.io", | ||
url = host + "/iserver/services/map-china400/rest/maps/China_4326"; | ||
var config = { | ||
imageService: host + "/iserver/services/imageservice-image/restjsr", | ||
imageWMSService: host + "/iserver/services/imageservice-image/wms130/nvdi", | ||
collection: "nvdi", | ||
tileSize: "1028,1028", | ||
}; | ||
var map, allFeatures = [], | ||
myChart, | ||
layer, proj, | ||
wmsUrlCache = []; | ||
|
||
initMap(); | ||
|
||
function initMap() { | ||
map = new L.map('map', { | ||
preferCanvas: true, | ||
crs: L.CRS.EPSG4326, | ||
center: { | ||
lon: 100, | ||
lat: 35 | ||
}, | ||
maxZoom: 18, | ||
zoom: 3 | ||
}); | ||
new L.supermap.TiledMapLayer(url).addTo(map); | ||
} | ||
|
||
getAllFeatures(); | ||
|
||
function getAllFeatures() { | ||
var url = config.imageService + "/search.json?collections=" + config.collection; | ||
$.get(config.imageService + "/collections/" + config.collection + "/tileInfo.json").then(res => { | ||
proj = res.crs; | ||
}); | ||
$.get(url).then(res => { | ||
res.features.forEach(feature => { | ||
allFeatures.push({ | ||
collection: feature.collection, | ||
name: feature.assets.data.title, | ||
time: feature.properties.createtime, | ||
bbox: feature.bbox | ||
}); | ||
}); | ||
allFeatures.forEach(feature => { | ||
var imageExtent = feature.bbox; | ||
var wmsurl = formatWMSURL(feature.time, imageExtent); | ||
wmsUrlCache.push(wmsurl); | ||
}); | ||
start(); | ||
}); | ||
} | ||
|
||
function start() { | ||
addStaticImageLayer(); | ||
layer.once("load", addTimeLine); | ||
} | ||
|
||
function addStaticImageLayer() { | ||
var feature = allFeatures[0]; | ||
var imageExtent = feature.bbox; | ||
var url = formatWMSURL(feature.time, imageExtent); | ||
layer = buildImageLayer(url, imageExtent); | ||
layer.addTo(map); | ||
} | ||
|
||
function addTimeLine() { | ||
var allTime = allFeatures.map(feature => feature.time.split('/')[0]); | ||
myChart = echarts.init(document.getElementById('timeline')); | ||
var option = { | ||
timeline: { | ||
axisType: 'category', | ||
show: true, | ||
autoPlay: true, | ||
playInterval: 1000, | ||
data: allTime, | ||
label: { | ||
normal: { | ||
textStyle: { | ||
color: '#111' | ||
} | ||
}, | ||
emphasis: { | ||
textStyle: { | ||
color: '#000' | ||
} | ||
} | ||
}, | ||
controlStyle: { | ||
normal: { | ||
color: '#666', | ||
borderColor: '#666' | ||
} | ||
} | ||
} | ||
} | ||
myChart.setOption(option); | ||
myChart.on('timelinechanged', function (params) { | ||
var url = wmsUrlCache[params.currentIndex]; | ||
layer.setUrl(url); | ||
changeTimelinePlay(false); | ||
layer.once("load", changeTimelinePlay); | ||
}); | ||
} | ||
|
||
function changeTimelinePlay(state = true) { | ||
myChart.dispatchAction({ | ||
type: 'timelinePlayChange', | ||
playState: state | ||
}) | ||
} | ||
|
||
function formatWMSURL(time, extent) { | ||
var commentSetting = config.imageWMSService + | ||
'?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&LAYERS=0.0.3'; | ||
var SQLFilter = "SQLFILTER=createtime='" + time.replaceAll("/", "-") + "'"; | ||
var crs = "CRS=" + proj; | ||
var width = "WIDTH=" + config.tileSize.split(",")[0]; | ||
var height = "HEIGHT=" + config.tileSize.split(",")[1]; | ||
var bbox = [extent[1], extent[0], extent[3], extent[2]]; | ||
var bboxStr = "BBOX=" + bbox.join(","); | ||
return commentSetting + "&" + SQLFilter + "&" + crs + "&" + width + "&" + height + "&" + bboxStr; | ||
} | ||
|
||
function buildImageLayer(url, imageExtent) { | ||
var imageBounds = [ | ||
[imageExtent[1], imageExtent[0]], | ||
[imageExtent[3], imageExtent[2]] | ||
]; | ||
return L.imageOverlay(url, imageBounds, { | ||
opacity: 0.7 | ||
}); | ||
} | ||
|
||
</script> | ||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.