前言

openlayers4 官网的 api 文档介绍地址 openlayers4 api,里面详细的介绍 openlayers4 各个类的介绍,还有就是在线例子:openlayers4 官网在线例子,这个也是学习 openlayers4 的好素材。

openlayers4 入门开发系列的地图服务基于 Geoserver 发布的,关于 Geoserver 方面操作的博客,可以参考以下几篇文章:

本篇的重点内容是利用 openlayers4 实现风场图功能,效果图如下:

实现思路

  • 界面设计
//风场图
"<div style='height:25px;background:#30A4D5;margin-top:10px;width: 98%;margin-left: 3px;float: left;'>" +
"<span style='margin-left:5px;font-size: 13px;color:white;'>风场图</span>" +
"</div>" +
'<div id="windLayer" style="padding:5px;float: left;">' +
'<input type="checkbox" name="windlayer" style="width: 15px;height: 15px;vertical-align: middle;margin: auto;"/>' +
'<label style="font-weight: normal;vertical-align: middle;margin: auto;">风场图</label>' +
'</div>'
  • 点击事件
//风场图
$("#windLayer input").bind("click", function () {
if (this.checked) {
var layer = bmap.getMapConfig().getShareLayer("GISSERVER_Wind");
bxmap.olWindLayer.Init(bmap);
if(layer){
layer.setVisible(true);
}
//图例面板显示
$("#map_tl").css("display","block");
$("#map_tl>img").attr('src', getRootPath() +"js/main/olWindLayer/windLegend.jpg");
$("#map_tl>img").css("width","auto");
$("#map_tl>img").css("height","300px");
}
else {
var layer = bmap.getMapConfig().getShareLayer("GISSERVER_Wind");
bxmap.olWindLayer.clearWind();
if(layer){
layer.setVisible(false);
}
//图例面板隐藏
$("#map_tl").hide();
}
})
  • 初始化代码
var bxmap = bxmap || {};
bxmap.olWindLayer = {
map:null,
wind:null,
Init:function(bmap){
this.map = bmap.getMap();
this.map.getView().setCenter([13501836.676, 2751733.018]);
this.map.getView().setZoom(3);
//加载风场数据
var wind, data;
axios.get(getRootPath() +"js/main/olWindLayer/gfs.json").then(function (res) {
if (res.data) {
data = res.data
wind = bxmap.olWindLayer.wind = new WindLayer(data, {
projection: 'EPSG:3857',
ratio: 1
})
wind.appendTo(bxmap.olWindLayer.map)
}
});
},
clearWind:function(){
if(bxmap.olWindLayer.wind)
bxmap.olWindLayer.wind.clearWind();
} }
  • 核心代码
/*!
* author: FDD <smileFDD@gmail.com>
* wind-layer v0.0.4
* build-time: 2018-2-6 17:34
* LICENSE: MIT
* (c) 2017-2018 https://sakitam-fdd.github.io/wind-layer
*/
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('openlayers')) :
typeof define === 'function' && define.amd ? define(['openlayers'], factory) :
(global.WindLayer = factory(global.ol));
}(this, (function (ol) { 'use strict'; ol = ol && ol.hasOwnProperty('default') ? ol['default'] : ol; var Windy = function Windy(params) {
var VELOCITY_SCALE = 0.005 * (Math.pow(window.devicePixelRatio, 1 / 3) || 1);
var MIN_TEMPERATURE_K = 261.15;
var MAX_TEMPERATURE_K = 317.15;
var MAX_PARTICLE_AGE = 90;
var PARTICLE_LINE_WIDTH = 1;
var PARTICLE_MULTIPLIER = 1 / 200;
var PARTICLE_REDUCTION = Math.pow(window.devicePixelRatio, 1 / 3) || 1.6;
var FRAME_RATE = 15,
FRAME_TIME = 1000 / FRAME_RATE; var NULL_WIND_VECTOR = [NaN, NaN, null]; var builder;
var grid;
var date;
var λ0, φ0, Δλ, Δφ, ni, nj; var bilinearInterpolateVector = function bilinearInterpolateVector(x, y, g00, g10, g01, g11) {
var rx = 1 - x;
var ry = 1 - y;
var a = rx * ry,
b = x * ry,
c = rx * y,
d = x * y;
var u = g00[0] * a + g10[0] * b + g01[0] * c + g11[0] * d;
var v = g00[1] * a + g10[1] * b + g01[1] * c + g11[1] * d;
var tmp = g00[2] * a + g10[2] * b + g01[2] * c + g11[2] * d;
return [u, v, tmp];
};
……

更多的详情见GIS之家小专栏

对本专栏感兴趣的话,可以关注一波

openlayers4 入门开发系列之风场图篇的更多相关文章

  1. openlayers4 入门开发系列之热力图篇(附源码下载)

    前言 openlayers4 官网的 api 文档介绍地址 openlayers4 api,里面详细的介绍 openlayers4 各个类的介绍,还有就是在线例子:openlayers4 官网在线例子 ...

  2. openlayers4 入门开发系列之小区信号扇形图篇

    前言 openlayers4 官网的 api 文档介绍地址 openlayers4 api,里面详细的介绍 openlayers4 各个类的介绍,还有就是在线例子:openlayers4 官网在线例子 ...

  3. openlayers4 入门开发系列之台风轨迹篇

    前言 openlayers4 官网的 api 文档介绍地址 openlayers4 api,里面详细的介绍 openlayers4 各个类的介绍,还有就是在线例子:openlayers4 官网在线例子 ...

  4. openlayers4 入门开发系列之船讯篇

    前言 openlayers4 官网的 api 文档介绍地址 openlayers4 api,里面详细的介绍 openlayers4 各个类的介绍,还有就是在线例子:openlayers4 官网在线例子 ...

  5. openlayers4 入门开发系列之聚合图篇(附源码下载)

    前言 openlayers4 官网的 api 文档介绍地址 openlayers4 api,里面详细的介绍 openlayers4 各个类的介绍,还有就是在线例子:openlayers4 官网在线例子 ...

  6. openlayers4 入门开发系列之批量叠加 zip 压缩 SHP 图层篇(附源码下载)

    前言 openlayers4 官网的 api 文档介绍地址 openlayers4 api,里面详细的介绍 openlayers4 各个类的介绍,还有就是在线例子:openlayers4 官网在线例子 ...

  7. openlayers4 入门开发系列之地图模态层篇(附源码下载)

    前言 openlayers4 官网的 api 文档介绍地址 openlayers4 api,里面详细的介绍 openlayers4 各个类的介绍,还有就是在线例子:openlayers4 官网在线例子 ...

  8. openlayers4 入门开发系列之迁徙图篇(附源码下载)

    前言 openlayers4 官网的 api 文档介绍地址 openlayers4 api,里面详细的介绍 openlayers4 各个类的介绍,还有就是在线例子:openlayers4 官网在线例子 ...

  9. openlayers4 入门开发系列之地图标绘篇(附源码下载)

    前言 openlayers4 官网的 api 文档介绍地址 openlayers4 api,里面详细的介绍 openlayers4 各个类的介绍,还有就是在线例子:openlayers4 官网在线例子 ...

随机推荐

  1. .NET开发微信小程序-微信支付

    前台MD5加密代码 /* * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message * Digest Algor ...

  2. Python_字符串查找与分隔

    #字符串常用方法 s='apple,peach,banana,peach,pear' #返回第一次出现的位置 print(s.find('peach')) #指定位置开始查找 print(s.find ...

  3. 用shell处理以下内容 1、按单词出现频率降序排序! 2、按字母出现频率降序排序! the squid project provides a number of resources toassist users design,implement and support squid installations. Please browsethe documentation and support

    此题目有多种解法,sed.awk.tr等等,都可以解决此题,命令运用灵活多变. 编写shell脚本no_20.sh 解法1: #!/bin/bash ###-------------CopyRight ...

  4. 【python3】如何建立爬虫代理ip池

    一.为什么需要建立爬虫代理ip池 在众多的网站防爬措施中,有一种是根据ip的访问频率进行限制的,在某段时间内,当某个ip的访问量达到一定的阀值时,该ip会被拉黑.在一段时间内被禁止访问. 这种时候,可 ...

  5. 【转】mysql索引使用技巧及注意事项

    一.索引的作用 一般的应用系统,读写比例在10:1左右,而且插入操作和一般的更新操作很少出现性能问题,遇到最多的,也是最容易出问题的,还是一些复杂的查询操作,所以查询语句的优化显然是重中之重. 在数据 ...

  6. 构建基于Netty 的HTTP/HTTPS 应用程序

    HTTP/HTTPS是最常见的协议套件之一,并且随着智能手机的成功,它的应用也日益广泛,因为对于任何公司来说,拥有一个可以被移动设备访问的网站几乎是必须的.这些协议也被用于其他方面.许多组织导出的用于 ...

  7. 功能强大的swagger-editor的介绍与使用

    一.Swagger Editor简介 Swagger Editor是一个开源的编辑器,并且它也是一个基于Angular的成功案例.在Swagger Editor中,我们可以基于YAML等语法定义我们的 ...

  8. 【转】tomcat logs 目录下各日志文件的含义

    tomcat每次启动时,自动在logs目录下生产以下日志文件,按照日期自动备份   localhost.2016-07-05.txt   //经常用到的文件之一 ,程序异常没有被捕获的时候抛出的地方 ...

  9. Elasticsearch结构化搜索_在案例中实战使用term filter来搜索数据

    1.根据用户ID.是否隐藏.帖子ID.发帖日期来搜索帖子 (1)插入一些测试帖子数据 POST /forum/article/_bulk { "index": { "_i ...

  10. 『网络の转载』px与em的区别

    这里引用的是Jorux的“95%的中国网站需要重写CSS”的文章,题目有点吓人,但是确实是现在国内网页制作方面的一些缺陷.我一直也搞不清楚px与em之间的关系和特点,看过以后确实收获很大.平时都是用p ...