123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202 |
- <!--********************************************************************
- * Copyright© 2000 - 2021 SuperMap Software Co.Ltd. All rights reserved.
- *********************************************************************-->
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <title data-i18n="resources.title_animatorPolygon"></title>
- <script type="text/javascript" src="./data/animationPolygonData.js"></script>
- <style type="text/css">
- body {
- margin: 0;
- overflow: hidden;
- background: #fff;
- width: 100%;
- height: 100%
- }
- #map {
- position: absolute;
- width: 100%;
- height: 100%;
- }
- #toolbar {
- position: absolute;
- top: 50px;
- right: 10px;
- text-align: center;
- z-index: 100;
- border-radius: 4px;
- }
- </style>
- </head>
- <body>
- <div id="toolbar" class="panel panel-primary">
- <div class='panel-heading'>
- <h5 class='panel-title text-center' data-i18n="resources.title_animatorPolygon"></h5></div>
- <div class='panel-body content'>
- <input type="button" class="btn btn-default" data-i18n="[value]resources.btn_play" onclick="startAnimator()"/>
- <input type="button" class="btn btn-default" data-i18n="[value]resources.btn_pause" onclick="pauseAnimator()"/>
- </div>
- </div>
- <div id="map"></div>
- <script type="text/javascript" include="bootstrap,widgets.alert" src="../js/include-web.js"></script>
- <script type="text/javascript" exclude="iclient-classic" src="../../dist/classic/include-classic.js"></script>
- <script>
- var map, layer, animatorVector,
- host = window.isLocal ? window.server : "https://iserver.supermap.io",
- url = host + "/iserver/services/map-china400/rest/maps/China";
- var style1 = {
- fillColor: "#b6fb7e",
- fillOpacity: 0.2,
- strokeOpacity: 0
- };
- var style2 =
- {
- fillColor: "#ffff00",
- fillOpacity: 0.2,
- strokeOpacity: 0
- };
- var style3 =
- {
- fillColor: "#efad3b",
- fillOpacity: 0.2,
- strokeOpacity: 0
- };
- var style4 =
- {
- fillColor: "#ef8425",
- fillOpacity: 0.2,
- strokeOpacity: 0
- };
- var style5 =
- {
- fillColor: "#ef255e",
- fillOpacity: 0.2,
- strokeOpacity: 0
- };
- var style6 =
- {
- fillColor: "#f80f1a",
- fillOpacity: 0.2,
- strokeOpacity: 0
- };
- var style7 =
- {
- fillColor: "#ff000",
- fillOpacity: 0.2,
- strokeOpacity: 0
- };
- init();
- function init() {
- if (!document.createElement('canvas').getContext) {
- widgets.alert.showAlert(resources.msg_supportCanvas, false);
- return;
- }
- //初始化地图
- map = new SuperMap.Map("map", {
- controls: [
- new SuperMap.Control.ScaleLine(),
- new SuperMap.Control.Zoom(),
- new SuperMap.Control.Navigation({
- dragPanOptions: {
- enableKinetic: true
- }
- })],
- projection: "EPSG:3857"
- });
- //初始化图层
- layer = new SuperMap.Layer.TiledDynamicRESTLayer("China", url, null, {maxResolution: "auto"});
- //初始化动画矢量图层
- animatorVector = new SuperMap.Layer.AnimatorVector("Polygon", {}, {
- //设置速度为每帧播放0.01小时的数据
- speed: 0.01,
- //开始时间为12点
- startTime: 12,
- //每秒渲染12次
- frameRate: 12,
- //结束时间为15点
- endTime: 15
- });
- //监听图层信息加载完成事件
- layer.events.on({
- "layerInitialized": function () {
- map.addLayers([layer, animatorVector]);
- map.addControl(selectFeature);
- selectFeature.activate();
- map.setCenter(new SuperMap.LonLat(11586634.286396, 3588716.5813769), 12);
- //增加数据
- addPolygon();
- }
- });
- var selectFeature = new SuperMap.Control.SelectFeature(animatorVector, {
- onSelect: function (fe) {
- console.log(fe);
- },
- hover: false
- });
- }
- //添加面数据
- function addPolygon() {
- var regionFeatures = [];
- for (var i = 0, len = lines.length; i < len; i++) {
- var arr = [];
- for (var j = 0; j < lines[i][3].length; j++) {
- var point = new SuperMap.Geometry.Point(lines[i][3][j][0], lines[i][3][j][1]);
- arr.push(point);
- }
- var line = new SuperMap.Geometry.LinearRing(arr);
- var region = new SuperMap.Geometry.Polygon([line]);
- var style;
- if (lines[i][2] == 31) {
- style = style1;
- }
- else if (lines[i][2] == 32) {
- style = style2;
- }
- else if (lines[i][2] == 33) {
- style = style3;
- }
- else if (lines[i][2] == 34) {
- style = style4;
- }
- else if (lines[i][2] == 35) {
- style = style5;
- }
- else if (lines[i][2] == 36) {
- style = style6;
- }
- else if (lines[i][2] == 37) {
- style = style7;
- }
- var regionFeature = new SuperMap.Feature.Vector(region, {
- FEATUREID: lines[i][0],
- TIME: lines[i][1],
- TEMPERATURE: lines[i][2]
- }, style);
- regionFeatures.push(regionFeature);
- }
- animatorVector.addFeatures(regionFeatures);
- }
- //开始播放动画
- function startAnimator() {
- animatorVector.animator.start();
- }
- //暂停播放动画
- function pauseAnimator() {
- animatorVector.animator.pause();
- }
- </script>
- </body>
- </html>
|