前言

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 入门开发系列之船讯篇的更多相关文章

  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 入门开发系列之地图展示篇(附源码下载)

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

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

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

  8. openlayers4 入门开发系列之风场图篇

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

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

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

随机推荐

  1. Linux环境安装配置JDK

    本文安装环境为Ubuntu14 64位,jdk版本为jdk1.6.0_38,安装文件名为jdk-6u38-linux-x64.bin(根据系统不同,下载不同的安装文件) 下载地址:http://www ...

  2. 语音识别中的CTC算法的基本原理解释

    欢迎大家前往腾讯云+社区,获取更多腾讯海量技术实践干货哦~ 本文作者:罗冬日 目前主流的语音识别都大致分为特征提取,声学模型,语音模型几个部分.目前结合神经网络的端到端的声学模型训练方法主要CTC和基 ...

  3. mysql 和 oracle 的一些小知识

    有很多应用项目, 刚起步的时候用MYSQL数据库基本上能实现各种功能需求,随着应用用户的增多,数据量的增加,MYSQL渐渐地出现不堪重负的情况:连接很慢甚至宕机,于是就有把数据从MYSQL迁到ORAC ...

  4. 并发库应用之五 & ReadWriteLock场景应用

    Lock比传统线程模型中的synchronized方式更加面向对象,与生活中的锁类似,锁本身也应该是一个对象.两个线程执行的代码片段要实现同步互斥的效果,它们必须用同一个Lock对象. 读写锁:分为读 ...

  5. Maven通俗讲解

    也许是本人不才,初识Maven时,被各种不明所以的教程搞得一头雾水,而在后来的使用中,我发现Maven大部分功能没有想象的那么困难. 本片文章面向Maven初学者,希望能让其以最快的速度了解Maven ...

  6. EasyUI集成Kindeditor使用

    在实际的项目中,我们需要在项目中集成富文本编辑器,而kindeditor作为一款优良的编辑器,在项目中或多或少都会用到! 实际效果图     使用方法: 1.首先下载Kindeditor编辑器,我这里 ...

  7. js 数据加载loading封装

    <!-- 模态框(Modal) --> <div class="modal fade" id="qst_loading" tabindex=& ...

  8. SDKManager连不上墙外的网,列表刷新不出来怎么办?

    现在我们都无法正常访问外国的网站了,尤其是Google,这个也没了,问题出不去,好多东西都解决的不是很好,包括SDKManager这个都无法刷新列表,当然在这里,我没有介绍你使用VPN的使用,这样做就 ...

  9. 如何发布jar包到maven中央仓库

    自使用maven以来,没少使用maven中央仓库中的各种jar包,方便有效,但是咱们也不能总是只取不予,也应该懂得奉献,当你写好了一个十分好用的jar包,想贡献出去给大家使用的时候,应该怎么做呢?当然 ...

  10. version.go

    package blog4go const ( // 版本号 VERSION = "0.5.6" )