TWaver GIS制作穹顶之下的雾霾地图
“我不满意,我不想等待,我也不再推诿,我要站出来做一点什么。我要做的事,就在此时,就在此刻,就在此地,就在此生”。自离职央视后,沉寂许久的知名记者、主持人柴静昨日携个人视频新作 《穹顶之下》宣告归来,并在短时间内引起广泛关注。生活在这个地球上,空气质量的好坏决定这我们的健康,每个人都希望能够呼吸新鲜空气,都希望抬起头看到的是蓝天和白云,而不是灰蒙蒙的雾霾。说到雾霾,我们用TWaver GIS实现了一个全国雾霾图的示例供大家参考。

首先要创建地图,如果熟悉TWaver GIS的人,下面的代码应该不难,如果第一次接触TWaver GIS,可以参考html5 gis的官方文档。贴出地图的代码:
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
network = new twaver.vector.Network();map = new twaver.gis.Map(document.getElementById("container"),"test");map.setSize({width:800,height:1200});map.setEnableDoubleZoom(false);map.setBackgroundColor(GISConsts.GOOGLE_COLOR);map.setProjectionType(GISConsts.PROJECTION_MERCATOR);map.addLayer("OSM",GISConsts.EXECUTOR_TYPE_OSM);map.setZoomLevel(4);map.setCenter(new twaver.gis.geometry.GeoCoordinate(40,100));network.adjustBounds({x:0,y:0,width:900,height:800});var box = network.getElementBox();adapter = new twaver.gis.Adapter();adapter.bindNetworkAndMap(network,map);adapter.enableCombineInteraction();var borderPane = new twaver.controls.BorderPane(map);appendChild(borderPane.getView(),document.getElementById("container"),0,0,0,0);var toolbar = new twaver.gis.gadget.MapToolbar("",map);map.installGadget(toolbar.getView());var navigator = new twaver.gis.gadget.Navigator("cn",map);map.installGadget(navigator,{x:20,y:50}); |
接下来是在地图上画出每个省省会的的雾霾指数,可以用网元来表示, 先注册一下网元的样式,用我们的矢量描述来表示:
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
twaver.Util.registerImage('exponent', { w: 80, h: 30, origin: { x: 0, y: 0 }, line: { width: 0, color: 'red' }, v: [ { shape: 'rect', rect: [ 0, 0, 80, 20], fill: 'white', r: 2 }, { shape: 'rect', rect: [ 50, 0, 30, 20], fill: '<%= data.getClient("color") %>', r:2 }, { shape: 'text', text: '<%= data.getClient("name") %>', textAlign: 'left', textBaseline: 'top', x: 5, y: 5 }, { shape: 'text', text: '<%= data.getClient("exponent") %>', textAlign: 'left', textBaseline: 'top', x: 55, y: 5 }, { shape: 'circle', cx: 40, cy: 22, r: 2, fill: 'red' } ] }); |
最后我们创建网元,网元的图片就是上边注册的图片,并且用不同的颜色表示雾霾指数的高低:
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
function createTopo() { var box = network.getElementBox(); var geoDatas = [ {latitude: 39.91667, longitude: 116.41667, name:"北京"}, //北京 {latitude: 31.14, longitude:121.29, name:"上海"},//上海 {latitude: 39.13333, longitude: 117.20000, name:"天津"},//天津 {latitude: 22.20000, longitude:114.10000, name:"香港"}, //香港 {latitude: 23.16667, longitude: 113.23333, name:"广州"}, //广州 {latitude: 30.26667, longitude:120.20000, name:"杭州"},//杭州 {latitude: 29.56667, longitude: 106.45000, name:"重庆"},//重庆 {latitude: 26.08333, longitude:119.30000, name:"福州"},//福州 {latitude: 36.03333, longitude: 103.73333, name:"兰州"},//兰州 {latitude: 26.56667, longitude:106.71667, name:"贵阳"},//贵阳 {latitude: 28.21667, longitude: 113.00000, name:"长沙"},//长沙 {latitude: 32.05000, longitude:118.78333, name:"南京"},//南京 {latitude: 28.68333, longitude: 115.90000, name:"南昌"},//南昌 {latitude: 41.80000, longitude:123.38333, name:"沈阳"},//沈阳 {latitude: 37.86667, longitude: 112.53333, name:"太原"},//太原 {latitude: 30.66667, longitude:104.06667, name:"成都"},//成都 {latitude: 29.60000, longitude: 91.00000, name:"拉萨"},//拉萨 {latitude: 43.76667, longitude:87.68333, name:"乌鲁木齐"},//乌鲁木齐 {latitude: 25.05000, longitude: 102.73333, name:"昆明"},//昆明 {latitude: 34.26667, longitude:108.95000, name:"西安"},//西安 {latitude: 36.56667, longitude: 101.75000, name:"西宁"},//西宁 {latitude: 38.46667, longitude:106.26667, name:"银川"},//银川 {latitude: 45.75000, longitude: 126.63333, name:"哈尔滨"},//哈尔滨 {latitude: 43.88333, longitude:125.35000, name:"长春"},//长春 {latitude: 30.51667, longitude: 114.31667, name:"武汉"},//武汉 {latitude: 34.76667, longitude:113.65000, name:"郑州"},//郑州 {latitude: 38.03333, longitude: 114.48333, name:"石家庄"},//石家庄 {latitude: 20.01667, longitude:110.35000, name:"海口"},//海口 {latitude: 22.20000, longitude: 113.50000, name:"澳门"},//澳门 {latitude: 40.48, longitude: 111.41, name:"呼和浩特"},//呼和浩特 {latitude: 22.48, longitude: 108.19, name:"南宁"},//南宁 {latitude: 36.40, longitude: 117.00, name:"济南"},//济南 {latitude: 31.52, longitude: 117.17, name:"合肥"},//合肥 {latitude: 25.03 , longitude: 121.30, name:"台北"}//台北 ]; for(var i = 0; i < geoDatas.length; i++) { var node = new twaver.Node(); node.setClient(GISSettings.GEOCOORDINATE,new twaver.gis.geometry.GeoCoordinate(geoDatas[i].latitude,geoDatas[i].longitude)); node.setImage("exponent"); node.setClient("name",geoDatas[i].name); node.setClient("exponent",Math.floor(Math.random() * 200) + 20); if(node.getClient("exponent") < 50) { node.setClient("color", "green"); }else if(node.getClient("exponent") >= 50 && node.getClient("exponent") < 100) { node.setClient("color", "#D6C621"); }else if(node.getClient("exponent") >= 100 && node.getClient("exponent") < 150) { node.setClient("color", "#F5582E"); } else if(node.getClient("exponent") >= 150 && node.getClient("exponent") <= 220) { node.setClient("color", "red"); } box.add(node); } } |
这样一个简单的雾霾地图就实现了,上边的数据是模拟数据,如果想反映真实数据,可以直接调用中国天气的实时数据,网址:http://openweather.weather.com.cn/Home/Package/index.html
关于更多产品TWaver信息,可关注官网网站:www.servasoft.com
TWaver GIS制作穹顶之下的雾霾地图的更多相关文章
- 雾霾天出行,如何精确避开“雷区”?2016 SODA数据侠十强
(2016年参加了上海 SODA 竞赛,进入前十,最终获得上海市的两个奖项.) ▍跟踪雾霾,仅靠零星的监测点数据怎么行? 如果雾霾短期内没有办法彻底根治,我们可以做什么,把环境污染物对人的影响尽可能降 ...
- TWaver GIS在电信中的使用
GIS作为信息系统的重要组成部分,在电信行业中的应用由来已久.将GIS引入电信管理系统,GIS强大的功能就会得到充分的体现,GIS技术可以将各类电信信息系统以其特有的表现形有机整合在一起,并为真正做到 ...
- [置顶]
【机器学习PAI实践三】雾霾成因分析
一.背景 如果要人们评选当今最受关注话题的top10榜单,雾霾一定能够入选.如今走在北京街头,随处可见带着厚厚口罩的人在埋头前行,雾霾天气不光影响了人们的出行和娱乐,对于人们的健康也有很大危害.本文通 ...
- 一步一步手写GIS开源项目-(2)地图平移缩放实现
系列文章目录 一步一步手写GIS开源项目-(1)500行代码实现基础GIS展示功能 一步一步手写GIS开源项目-(2)地图平移缩放实现 项目github地址:https://github.com/Hu ...
- 杨柳目-杨柳科-Info-新闻:“北京三害”之一,危害堪比雾霾和沙尘,杨絮为什么会肆虐
ylbtech-杨柳目-杨柳科-Info-新闻:“北京三害”之一,危害堪比雾霾和沙尘,杨絮为什么会肆虐 1.返回顶部 1. “北京三害”之一,危害堪比雾霾和沙尘,杨絮为什么会肆虐 18-05-0817 ...
- java离线地图web GIS制作
因为项目需求,要做一个web地图,之前做过高德的在线地图,它提供了一系列的API,并且由于是国产的,所以开发起来比较容易,现在由于项目是内网使用的,所以需要使用离线地图,由此便开始了: Web GIS ...
- SU+GIS,让SketchUp模型在地图上活起来
一.SU+GIS的场景展示 skp与卫星地图和倾斜摄影模型相结合人工模型与实景模型完美融合 这么一看是不是直接秒杀了单纯看看skp后联想的规划效果? 二.如何快速把草图大师的结果和GIS结合呢?在图新 ...
- VR的世界里没有雾霾!暴风魔镜发布Matrix一体机
在2016年接近尾声的时候,暴风魔镜给VR行业带来一波暖流.12月20日,暴风魔镜宣布推出最新VR一体机--暴风魔镜"3K屏概念机"MATrix及VR眼镜S1两大产品. ...
- 我的Python成长之路---第一天---Python基础(4)---2015年12月26日(雾霾)
五.数据运算与数据运算符 1.算术运算符 算术运算符 运算符 描述 示例 + 加法 >>> 14 - 5 9 - 减法 >>> 14 - 5 9 * 乘法 &g ...
随机推荐
- jquery-mobile 学习笔记之中的一个(基础属性)
写在前面 本文是依据w3c 学习轨迹,自己研习过程中记录下的笔记,仅仅供自己学习轨迹记录之用,不喜勿喷. 0 引入库 引入相应的文件: <link rel="stylesheet&qu ...
- 使用mpxj读取MSPrjoect
import java.util.ArrayList; import java.util.Calendar; import java.util.Hashtable; import java.util. ...
- 2016/1/21 练习 arraylist 1,添加 add() 2,遍历集合
package shuzu; public class Customer { //从源码中 使用字段生成构造函数 public Customer(String good, int price) { s ...
- python安装了2.7之后终端无法使用退格,上下左右
遇到RT问题,原因是由于在编译python的时候去烧readline库造成的 解决办法: yum install readline-devel 然后重新编译安装python,终端控制符可用!
- 蓝桥 ADV-233 算法提高 队列操作 【STL】
算法提高 队列操作 时间限制:1.0s 内存限制:256.0MB 问题描述 队列操作题.根据输入的操作命令,操作队列(1)入队.(2)出队并输出.(3)计算队中元素个数并输出. ...
- UVA 213 Message Decoding 【模拟】
题目链接: https://cn.vjudge.net/problem/UVA-213 https://uva.onlinejudge.org/index.php?option=com_onlinej ...
- exynos 4412 时钟配置
/** ****************************************************************************** * @author Maox ...
- cordova常用命令
安装 cordova: npm install -g cordova 创建应用程序 cordova create hello com.example.hello HelloWorld 添加平台 cor ...
- Java 过滤器、监听器、拦截器的区别
原文:http://www.360doc.com/content/10/0601/09/495229_30616324.shtml 1.过滤器 Servlet中的过滤器Filter是实现了ja ...
- gitlab https
https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/install/installation.md#using-https https:// ...