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.地理查询

 openstreetmap 
5.中国地理数据
http://download.geofabrik.de/asia.html
5.  获取当前视野的范围

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的更多相关文章

  1. Geoserver+Openlayers拉框查询

    1.代码 <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" co ...

  2. OpenLayers在地图上显示统计图,饼图线状图柱状图,修复统计图跳动的问题

    环境介绍 Openlayers ol.js v5.3.0 Highcharts highcharts.js v7.0.1 jquery jquery-3.3.1.js v3.3.1 显示效果 地图放大 ...

  3. openlayers研究(一) 初始化流程

    下载2.13.1.解压缩.根据readme解释,openlayers.js是一个压缩库,.light是一个图像显示的简化库,mobile顾名思义应该是应对移动设备的库.build里面有py写的打包工具 ...

  4. openlayers图层加标注

    <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title&g ...

  5. openlayers添加弹出框

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  6. openlayers按坐标点播放

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  7. openlayers轨迹匀速播放

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  8. openlayers轨迹播放

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  9. openlayers编辑区域

    <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title&g ...

随机推荐

  1. JVM总结-字节码

    在运行过程中,每当调用进入一个 Java 方法,Java 虚拟机会在当前线程的 Java 方法栈中生成一个栈帧,用以存放局部变量以及字节码的操作数.这个栈帧的大小是提前计算好的,而且 Java 虚拟机 ...

  2. 函数的嵌套+nonlocal和global关键字(重点)

    1.在函数中声明函数 在内部函数中使用变量的时候, 查找顺序: 先找自己 -> 上一层 -> 上一层..全局 -> 内置 # 函数的互相调用 # def func1(): # pri ...

  3. iOS第三方登录qq

    http://blog.sina.com.cn/s/blog_7b9d64af0101e5vj.html

  4. 1.js简介

    1.JavaScript 诞生于1995年,起初主要用于处理网页中的前端验证. 2.前端验证:指检查用户输入的内容是否符合一定规则. 3.JavaScript 由网景公司发明. 4.JS 的标准命名为 ...

  5. gzip1

    经过GZIP压缩后页面大小可以变为原来的30%甚至更小.要实现GZIP压缩页面需要浏览器和服务器共同支持, 实际上就是服务器压缩,传到浏览器后浏览器解压并解析.浏览器那边不需要我们担心,因为现在绝大多 ...

  6. zookeeper(1)初识zookeeper

    一.zookeeper的安装 1.下载zookeeper(当然在安装zookeeper之前得先装好jdk,这里就不说了),版本自己随便选一个(后面我再说版本的问题),点击这里下载. 2.然后在usr下 ...

  7. django之runserver命令分析

    def inner_run(self, *args, **options):#runserver命令执行的内容 # If an exception was silenced in Management ...

  8. javascript,移动划过超链接鼠标变手型

    用css控制鼠标样式的语法如下:<span style="cursor:*">文本或其它页面元素</span>把 * 换成如下15个效果的一种: 下面是对这 ...

  9. AES-128-CBC C语言代码

    /** * Copyright (c) 2007, Cameron Rich * * All rights reserved. * * Redistribution and use in source ...

  10. antd-mobile使用报错

    在第一次使用时,按照官网的进行配置,完了报错找不到antd-mobile下面的css 解决方法来源于 :https://github.com/ant-design/ant-design-mobile/ ...