openlayers/// Puppeteer.js
1.定位;https://viglino.github.io/ol3-ext/examples/map.interaction.geolocationdraw.html
2 .添加Overlay div遮住鼠标事件处理
var point_div = document.createElement('div');
point_div.className = "css_animationBui mapEleClass";
point_div.style.background = "rgba(0,250,154,1)"; // "";
var point_overlay = new ol.Overlay({
element: point_div,
positioning: 'center-center',
stopEvent:false//设置为false 说明鼠标在overlay上也起作用
});
map.addOverlay(point_overlay);
point_overlay.setPosition(cor);
3.线闪烁的问题
beyondSource = new ol.source.Vector({
wrapX : false
});
beyondvector = new ol.layer.Vector({
source : beyondSource
});
beyondvector.setZIndex(20)
map.addLayer(beyondvector);
思路:将要闪烁的线放到单独的vector上 设置定时器 让整个vector 设置是否可用
function beyondvectorInterFun(){
var thisVisible=beyondvector.getVisible()
if(thisVisible){
beyondvector.setVisible(false)
$('#map').find('.css_animationBui').hide()
}else{
beyondvector.setVisible(true)
$('#map').find('.css_animationBui').show()
}
}
4.地理查询
var bounds = map.getView().calculateExtent(map.getSize());
bounds = ol.extent.applyTransform(bounds, ol.proj.getTransform("EPSG:3857", "EPSG:4326"));
var polygon = [];
polygon.push(ol.extent.getBottomLeft(bounds))
polygon.push(ol.extent.getBottomRight(bounds))
polygon.push(ol.extent.getTopRight(bounds))
polygon.push(ol.extent.getTopLeft(bounds))
polygon.push(ol.extent.getBottomLeft(bounds))
console.log(JSON.stringify(polygon))
6.鼠标右键
https://github.com/jonataswalker/ol3-contextmenu
7.计算长度
var TtheGeom = "119.96538162231444,36.24911862849349;120.09464263916017,36.24911862849349;120.09464263916017,36.28136778049705;119.96538162231444,36.28136778049705;119.96538162231444,36.24911862849349"
//var TtheGeom = "120.1826,35.9349;120.1855,35.9326;120.1812,35.9286;120.1763,35.9318;120.1794,35.9347;120.1826,35.9349";
var coordinates = TtheGeom.split(";");
var pts = [];
for(var m = 0; m < coordinates.length; m++) {
if(coordinates[m] == "") {
break;
}
var cor = ol.proj.transform([Number(coordinates[m].split(",")[0]), Number(coordinates[m].split(",")[1])], 'EPSG:4326', 'EPSG:3857');
pts.push(cor);
if(pts && $.isArray(pts) && pts.length > 1) {
var feature = new ol.Feature(new ol.geom.LineString(pts));
//var length = feature.getGeometry().getLength(); //计算长度【注意直接使用geom的getLength方法获取长度,openlayers默认的长度单位是m。所有如果长度大于1000,需要转换成km。】
//、、、、、、、、、、、、、、、、、、、、、、
var sphere = new ol.Sphere(6378137);
var lonLatLine = feature.getGeometry().transform('EPSG:3857', 'EPSG:4326');
var lineCoordinates = lonLatLine.getCoordinates();
var length = 0;
for(var i = 0; i < lineCoordinates.length - 1; i += 1) {
length += sphere.haversineDistance(lineCoordinates[i], lineCoordinates[i + 1]);
}
if (length > 1000) {
length = length / 1000;
unit = 'km';
} else {
unit = 'm';
}
console.log(length)
});
}
注:openlayers默认的长度单位是m。所有如果长度大于1000,需要转换成km。
7.1计算管线长度
function calculationPipelineLength(thisPts){//坐标
var thiSfeature = new ol.Feature(new ol.geom.LineString(thisPts));//thisPts 3857坐标
var sphere = new ol.Sphere(6378137);
var lonLatLine = thiSfeature.getGeometry().transform('EPSG:3857','EPSG:4326');
var lineCoordinates = lonLatLine.getCoordinates();
var length = 0;
for(var i = 0; i < lineCoordinates.length - 1; i += 1) {
length += sphere.haversineDistance(lineCoordinates[i], lineCoordinates[i + 1]);
}
return length = (length / 1000).toFixed(4);
}
8、poenlayers集合echarts
https://freegis.github.io/examples/ol3-echarts.html
9。根据ol.layer.vecor 的name获取
var layers = map.getLayers().getArray();
$.each(layers, function(idx, obj) {
console.log(obj.get('names'))
if(obj.get('names') == 'source') {
obj.setVisible(false)//设置层是否可用
}
});
10.流动效果 http://iclient.supermapol.com/examples/openlayers/editor.html#mapvPolylineTime
11.地图 gif
map.on('precompose', function(event) {
doAnimation();
});
map.on('postcompose', function(event) {
doAnimation();
});
map.on('postrender', function(event) {
doAnimation();
});
var pradius=1;
function doAnimation() {
var aa = onlinePSource.getFeatures();
// 增大半径,最大20
pradius += 0.2;
if(pradius > 13) {
pradius = 1;
}
var src = "../static/images/mapLayerImg/xjImg/" + parseInt(pradius) + ".png";
for(var i = 0; i < aa.length; i++) {
aa[i].setStyle(new ol.style.Style({
image: new ol.style.Icon({
anchor: [0.5, 50],
anchorOrigin: 'top-right',
anchorXUnits: 'fraction',
anchorYUnits: 'pixels',
offsetOrigin: 'top-right',
offset: [0, 0], // 位置设定
scale:0.8, // 图标缩放比例
opacity: 1, // 透明度
src: src // 图标的url
}),
text: new ol.style.Text({
textAlign: 'center', // 位置center
textBaseline: 'middle', // 基准线
font: '800 14px 微软雅黑', // 文字样式
text: aa[i].get("name"),
scale:1,
fill: new ol.style.Fill({
color: '#008B8B'
}), // 文本填充样式(即文字颜色)
stroke: new ol.style.Stroke({
color: '#ffcc33',
width: 2
})
})
}));
}
}
12.柱状图
http://www.cnblogs.com/shitao/p/3376495.html
13.圈选 矩形
var geometryFunction = ol.interaction.Draw.createBox();
var aaa = source.getFeatures();
if(draw) {
map.removeInteraction(draw);
}
var geometryFunction, maxPoints;
draw = new ol.interaction.Draw({
source: source,
type: "Circle", // Point 点;LineString">线;Polygon">多边形<Circle 圆
geometryFunction: geometryFunction
});
map.addInteraction(draw);
draw.on('drawstart', function(evt) {
source.clear();
}, this);
draw.on('drawend', function(evt) {
var pts = evt.feature.getGeometry().getExtent() //圆的点
console.log(circleCoordinatesLonlat(pts))
//圆的坐标 转为经纬度坐标
map.removeInteraction(draw);
}, this);
14.加载底图
http://blog.csdn.net/u014529917/article/details/52241389
15.
//地图服务
//1 http://mt3.google.cn/vt/lyrs=t@131,r@216000000&hl=zh-CN&gl=CN&src=app&x={x}&y={y}&z={z}&s=Gal //谷歌地形图
//2 http://www.google.cn/maps/vt/lyrs=s@142&hl=zh-CN&gl=cn&x={x}&y={y}&z={z}&s=Galil 【管网】
//3 http://mt2.google.cn/vt/lyrs=y&hl=zh-CN&gl=CN&src=app&x={x}&y={y}&z={z}&s=G 谷歌混合图
//谷歌交通图
//4 http://www.google.cn/maps/vt/pb=!1m4!1m3!1i{z}!2i{x}!3i{y}!2m3!1e0!2sm!3i345013117!3m8!2szh-CN!3scn!5e1105!12m4!1e68!2m2!1sset!2sRoadmap!4e0
16 判断一个点是否在一个闭合的多边形内
var aa = ol.proj.transform([120.031, 36.26], 'EPSG:4326', 'EPSG:3857');
console.log(aa);
var thisFeature = source.getFeatureById("1111");
var geo = thisFeature.getGeometry(); //feture是几何元素
var isIn = geo.intersectsCoordinate(aa);
if(isIn) {
console.log("该mark点在当前几何元素里。");
} else {
console.log("该mark点bu在当前几何元素里。");
}
17.获取extent
var bounds = map.getView().calculateExtent(map.getSize());
console.log(bounds)
openlayers/// Puppeteer.js的更多相关文章
- Geoserver+Openlayers拉框查询
1.代码 <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" co ...
- OpenLayers在地图上显示统计图,饼图线状图柱状图,修复统计图跳动的问题
环境介绍 Openlayers ol.js v5.3.0 Highcharts highcharts.js v7.0.1 jquery jquery-3.3.1.js v3.3.1 显示效果 地图放大 ...
- openlayers研究(一) 初始化流程
下载2.13.1.解压缩.根据readme解释,openlayers.js是一个压缩库,.light是一个图像显示的简化库,mobile顾名思义应该是应对移动设备的库.build里面有py写的打包工具 ...
- openlayers图层加标注
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title&g ...
- openlayers添加弹出框
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- openlayers按坐标点播放
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- openlayers轨迹匀速播放
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- openlayers轨迹播放
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- openlayers编辑区域
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title&g ...
随机推荐
- eclipse windowbuilder palette 空白
今天在 eclipse 上安装了 windowbuilder 插件,但是 palette 一直是空白的,不能放控件. 版本 eclipse 4.9.0, windowbuilder 1.9.0. 经过 ...
- Django之视图Views
视图 视图接受Web请求并且返回Web响应 视图就是一个python函数,被定义在views.py中 响应可以是一张网页的HTML内容,一个重定向,一个404错误等等 响应处理过程如下图: URLco ...
- 实战ELK(1) 安装ElasticSearch
第一步:环境 linux 系统 Java 1.8.0 elasticsearch-6.5.1 第二步:下载 2.1 JDK:https://mirrors.aliyun.com/centos/7.5 ...
- ROS-by-example的安装
在这里我之前用的VM12安装成功之后,仿真器机器人会有问题,故把电脑做成双系统的形式来重新安装: 环境:Ubuntu14.04 LTS 32bits ROS版本:ROS Indigo 在学习本部分之后 ...
- ROS 进阶学习笔记(13) - Combine Subscriber and Publisher in Python, ROS
Combine Subscriber and Publisher in Python, ROS This article will describe an example of Combining S ...
- iOS如何把所有页面状态栏的字体颜色都设置为白色
第一步:在info.plist中添加一个字段:view controller -base status bar 设置为NO 第二步:在一个所有界面都继承的父类里添加: if (IOS7_OR_LATE ...
- jenkins部署配置
https://www.cnblogs.com/rslai/p/8135460.html 修改jenkins的默认端口号: https://blog.csdn.net/qq_32440951/arti ...
- python __class__属性
>>> class a(object): pass >>> o=a() >>> dir(o) ['__class__', '__delattr__ ...
- 解决git中文乱码问题
三条命令fix乱码问题: git config --global gui.encoding utf-8 git config --global i18n.commitencoding utf-8 gi ...
- elasticSearch-DSL
DSL: query_string match match_phrase match_phrase_prefix multi_match simple_query_string term term ...