openlayers4 入门开发系列之船讯篇
前言
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="aisLayer" style="padding:5px;float: left;">' +
'<input type="checkbox" name="aislayer" style="width: 15px;height: 15px;vertical-align: middle;margin: auto;"/>' +
'<label style="font-weight: normal;vertical-align: middle;margin: auto;">船讯</label>' +
'</div>'
- 点击事件
//船讯
$("#aisLayer input").bind("click", function () {
if (this.checked) {
ais = new bxmap.AIS({
bmap: bmap
});
ais.initSearchPanel($("#map-search-box-panel"));
ais.refresh();
var map = bmap.getMap();
map.getView().setCenter([12867513.634164134, 2589684.2523000734]);
map.getView().setZoom(10);
//图例面板显示
$("#map_tl").css("display","block");
$("#map_tl>img").attr('src', GLOBAL.domainResource+"/Content/img/AISLegend.png");
$("#map_tl>img").css("width","auto");
$("#map_tl>img").css("height","300px");
}
else {
ais.clear();
//图例面板隐藏
$("#map_tl").hide();
}
})
- 地图范围显示船讯核心代码
/**
* @description 刷新船舶位置
*/
bxmap.AIS.prototype.refresh = function () {
var view = this.bmap.getMap().getView();
var resolution = view.getResolution();
//不满足显示渔船的条件
if(resolution > this.displayResolution) {
this.shipLayer && this.shipLayer.setVisible(false);
return;
} if(this.shipLayer){
//显示图层
this.shipLayer.setVisible(true); var center = view.getCenter();
//如果投影坐标系则转为EPSG:4326
if(this.isProjected) {
center = ol.proj.toLonLat(center);
} //获取船舶信息并添加到地图
var self = this;
bxmap.AIS.getShipsByResolution(center, resolution, function (data) {
if (data && data.length) {
//更新船舶
self._updateFeatureToMap(data);
//上次点击选中
if(self._shipInfoFeature){
//设置要素高亮样式
self.setHighlight(self._shipInfoFeature, true);
var info = self._shipInfoFeature["shipInfoData"];
if(this.showDefaultDialog){
this._showInfoDialog(info.shipid, info.source);
}
}
}
});
}
}
更多的详情见:GIS之家小专栏
对本专栏感兴趣的话,可以关注一波
openlayers4 入门开发系列之船讯篇的更多相关文章
- openlayers4 入门开发系列之台风轨迹篇
前言 openlayers4 官网的 api 文档介绍地址 openlayers4 api,里面详细的介绍 openlayers4 各个类的介绍,还有就是在线例子:openlayers4 官网在线例子 ...
- openlayers4 入门开发系列之聚合图篇(附源码下载)
前言 openlayers4 官网的 api 文档介绍地址 openlayers4 api,里面详细的介绍 openlayers4 各个类的介绍,还有就是在线例子:openlayers4 官网在线例子 ...
- openlayers4 入门开发系列之迁徙图篇(附源码下载)
前言 openlayers4 官网的 api 文档介绍地址 openlayers4 api,里面详细的介绍 openlayers4 各个类的介绍,还有就是在线例子:openlayers4 官网在线例子 ...
- openlayers4 入门开发系列之地图工具栏篇(附源码下载)
前言 openlayers4 官网的 api 文档介绍地址 openlayers4 api,里面详细的介绍 openlayers4 各个类的介绍,还有就是在线例子:openlayers4 官网在线例子 ...
- openlayers4 入门开发系列之地图切换篇(附源码下载)
前言 openlayers4 官网的 api 文档介绍地址 openlayers4 api,里面详细的介绍 openlayers4 各个类的介绍,还有就是在线例子:openlayers4 官网在线例子 ...
- openlayers4 入门开发系列之地图展示篇(附源码下载)
前言 openlayers4 官网的 api 文档介绍地址 openlayers4 api,里面详细的介绍 openlayers4 各个类的介绍,还有就是在线例子:openlayers4 官网在线例子 ...
- openlayers4 入门开发系列之小区信号扇形图篇
前言 openlayers4 官网的 api 文档介绍地址 openlayers4 api,里面详细的介绍 openlayers4 各个类的介绍,还有就是在线例子:openlayers4 官网在线例子 ...
- openlayers4 入门开发系列之风场图篇
前言 openlayers4 官网的 api 文档介绍地址 openlayers4 api,里面详细的介绍 openlayers4 各个类的介绍,还有就是在线例子:openlayers4 官网在线例子 ...
- openlayers4 入门开发系列之批量叠加 zip 压缩 SHP 图层篇(附源码下载)
前言 openlayers4 官网的 api 文档介绍地址 openlayers4 api,里面详细的介绍 openlayers4 各个类的介绍,还有就是在线例子:openlayers4 官网在线例子 ...
随机推荐
- 通俗的讲法理解spring的事务实现原理
拿房屋买卖举例,流程:销售房屋 -- 接待员 -- 销售员 -- 财务 售楼处 存放着所有待售和已售的房屋数据(数据源 datasource) 总经理 带领一套自己的班底,下属员工都听自己的,服务于售 ...
- LoadRunner性能测试工具
1:LoadRunner是一款性能测试软件,通过模拟真实的用户行为,通过负载.并发和性能实时监控以及完成后的测试报告,分析系统可能存在的瓶颈,LoadRunner最为有效的手段之一应该就是并发的控制. ...
- FLASK简单入门
假定你已经安装好了 Flask.如果没有,请跳转到 安装 章节. 一个最小的应用¶ 一个最小的 Flask 应用看起来会是这样: from flask import Flask app = Flask ...
- Windows下安装配置go
基于 go 1.9.2 + liteIDE + windows10 先安装 go 安装包,作用如同安装框架. 默认安装路径是 C:\Go,通常都会更改,但这会影响到后面设置环境变量,因此更改到哪里请记 ...
- Linux用户登录日志查询
# 1 utmp.wtmp.btmp文件 Linux用户登录信息放在三个文件中: 1 /var/run/utmp:记录当前正在登录系统的用户信息,默认由who和w记录当前登录用户的信息,uptime记 ...
- map用法
描述: map()会根据提供的参数对指定序列做映射. 语法: map(function,iterable) function:函数以参数列表中的每一个元素调用function函数,返回包含每次func ...
- 利用pytesser识别图形验证码
简单识别 1.一般思路 验证码识别的一般思路为: 图片降噪 图片切割 图像文本输出 1.1 图片降噪 所谓降噪就是把不需要的信息通通去除,比如背景,干扰线,干扰像素等等,只剩下需要识别的文字,让图片变 ...
- mysq数据库相关操作
(一)常用SQL语句 1.SELECT USER() 得到登陆的用户 2.SELECT VERSION() 得到mysql的版本信息 3.SELECT NOW() 得到当前的时间 4.SELECT D ...
- scala 访问阿里云oss
我们的数据一天就一个T,数据量不断增大,集群磁盘有限,所以把冷数据放到了oss,偶尔会使用到冷数据,如果使用的时候还的从oss上拉数据这样很浪费时间后来想了个办法可以直接获取到oss上的数据.案例:o ...
- Python跨目录调程序
#!/usr/bin/python # -*- coding: utf-8 -*- # 导入其它目录下的文件, 需要去帮获取当前程序的绝对路径并加入到环境变量的相对路径中 import os impo ...