Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
xilanhuaweidapao committed Oct 18, 2024
2 parents 00aeb71 + 605a8a2 commit e145d15
Show file tree
Hide file tree
Showing 20 changed files with 945 additions and 10 deletions.
7 changes: 7 additions & 0 deletions examples/leaflet/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,13 @@ var exampleConfig = {
version: "10.2.0",
thumbnail: "imageService.png",
fileName: "imageService"
},
{
name: "多时相播放",
name_en: "Multiphase play",
version: '11.3.0',
thumbnail: "multiphaseplay.png",
fileName: "multiphaseplay"
}
]
},
Expand Down
Binary file added examples/leaflet/img/multiphaseplay.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
189 changes: 189 additions & 0 deletions examples/leaflet/multiphaseplay.html
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>
3 changes: 3 additions & 0 deletions examples/locales/en-US/resources.js
Original file line number Diff line number Diff line change
Expand Up @@ -812,6 +812,7 @@ window.examplesResources = {
"title_ugcResample": "Resample Analysis",
"title_ugcPointPosition": "Point And Line Analysis",
"title_ugcSpatial": "Spacial Analysis",
"title_multiphaseplay": "Multiphase Play",

"text_graphmap_shortest_analysis": "Shortest Path Analysis",
"text_startNode": "start node",
Expand Down Expand Up @@ -1692,6 +1693,8 @@ window.examplesResources = {
"text_lastPage": "Last",
"text_queryDistance": "Query Distance(Degree)",
"text_queryDistanceLimit": "The query distance must be greater than zero",
"text_multiphaseplay": "Multiphase Play(2009-2016 years of NDVI)",
"text_2009To2016NDVI": "2009-2016 years of NDVI",

"btn_previous":"Previous",
"btn_next":"Next",
Expand Down
3 changes: 3 additions & 0 deletions examples/locales/zh-CN/resources.js
Original file line number Diff line number Diff line change
Expand Up @@ -777,6 +777,7 @@ window.examplesResources = {
"title_l7_3d_terrain": "自定义3D地形(LOD)",
"title_l7_snow_particle": "雪花粒子",
"title_l7_rain_particle": "雨滴粒子",
"title_multiphaseplay": "多时相播放",

"text_district_search": "行政区检索",
"text_rectangle_search": "矩形检索",
Expand Down Expand Up @@ -1648,6 +1649,8 @@ window.examplesResources = {
"text_lastPage": "尾页",
"text_queryDistance": "查询距离(度)",
"text_queryDistanceLimit": "查询距离必须大于零",
"text_multiphaseplay": "多时相播放",
"text_2009To2016NDVI": "2009-2016年5月植被指数",



Expand Down
7 changes: 7 additions & 0 deletions examples/mapboxgl/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,13 @@ var exampleConfig = {
version: "10.2.0",
thumbnail: "imageService.png",
fileName: "imageService"
},
{
name: "多时相播放",
name_en: "Multiphase play",
version: '11.3.0',
thumbnail: "multiphaseplay.png",
fileName: "multiphaseplay"
}
]
},
Expand Down
Binary file added examples/mapboxgl/img/multiphaseplay.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit e145d15

Please sign in to comment.