import { getCogStatistics, getCogBounds } from "./ol-api.js";
import { Stroke, Style, Fill, Circle, Text } from 'ol/style';
import { transform, transformExtent, toLonLat, Projection } from 'ol/proj';
import { Vector as VectorLayer, Tile, Image as ImageLayer } from 'ol/layer';
import { Vector as VectorSource, XYZ, ImageStatic, ImageWMS, WMTS } from 'ol/source';
import WMTSTileGrid from 'ol/tilegrid/WMTS';
import * as olControl from 'ol/control';
import Map from 'ol/Map';
import View from 'ol/View';
import Draw, {
createBox,
createRegularPolygon
} from 'ol/interaction/Draw';
import Overlay from 'ol/Overlay'
import {
LineString,
Polygon,
MultiLineString
} from 'ol/geom'
import * as olSphere from 'ol/sphere'
import {
unByKey
} from 'ol/Observable'
import { WKT } from 'ol/format';
import { defaults } from 'ol/interaction/defaults';
// titiler加载中 获取最大最小范围
export function getMinMax (obj) {
let min = null, max = null
Object.keys(obj).forEach((key) => {
if (!min || min > obj[key].percentile_2) {
min = obj[key].percentile_2
}
if (!max || max < obj[key].percentile_98) {
max = obj[key].percentile_98
}
})
return [min, max];
}
/**创建样式
* @param {*} feature
* @param {*} resolution
* @param {*} style
* @returns
*/
export function crtStyle ({
resolution = 300,
style = null,
feature
} = {}) {
var iconSize = 300 / resolution;
var featureStyle = null;
switch (style.type) {
// 几何控方未选择样式
case 'unSelected':
featureStyle = new Style({
stroke: new Stroke({
color: '#54FF9F',
lineDash: [0],
width: 2
}),
fill: new Fill({
color: 'rgb(158,197,255,0.2)'
}),
image: new Circle({
radius: 6,
fill: new Fill({
color: 'blue'
}),
stroke: new Stroke({
color: '#ffffff',
width: 1.5
})
}),
text: new Text({ // 文本样式
text: '10',
offsetX: 0 / resolution,
offsetY: 0 / resolution,
textAlign: 'start',
textBaseline: 'bottom',
font: iconSize + 'px Calibri,sans-serif',
fill: new Fill({
color: '#000'
}),
stroke: new Stroke({
color: '#fff',
width: 3
})
}),
geometry: function (feature) {
var center = feature.getGeometry().getCoordinates();
const top = [center[0], center[1] + 300];
const bottom = [center[0], center[1] - 300];
const left = [center[0] - 300, center[1]];
const right = [center[0] + 300, center[1]];
const geo = [
[top, bottom],
[left, right]
];
return new MultiLineString(geo);
}
});
break;
// 几何控方选择样式
case 'Selected':
featureStyle = [new Style({
stroke: new Stroke({
color: '#54FF9F',
lineDash: [0],
width: 2
}),
text: new Text({ // 文本样式
text: '10',
offsetX: 0 / resolution,
offsetY: 0 / resolution,
textAlign: 'start',
textBaseline: 'bottom',
font: iconSize + 'px Calibri,sans-serif',
fill: new Fill({
color: '#000'
}),
stroke: new Stroke({
color: '#fff',
width: 3
})
}),
geometry: function (feature) {
var center = feature.getGeometry().getCoordinates();
const top = [center[0], center[1] + 300];
const bottom = [center[0], center[1] - 300];
const left = [center[0] - 300, center[1]];
const right = [center[0] + 300, center[1]];
return new MultiLineString([
[top, bottom],
[left, right]
]);
}
}),
new Style({
stroke: new Stroke({
color: '#54FF9F',
lineDash: [10, 5],
width: 2
}),
geometry: function (feature) {
var center = feature.getGeometry().getCoordinates();
const leftTop = [center[0] - 350, center[1] + 350];
const leftBottom = [center[0] - 350, center[1] - 350];
const rightBottom = [center[0] + 350, center[1] - 350];
const rightTop = [center[0] + 350, center[1] + 350];
return new Polygon([
[
leftTop, leftBottom, rightBottom, rightTop
]
]);
}
})
];
break;
//绘制样式
case 'draw':
featureStyle = new Style({
stroke: new Stroke({
color: '#F25521',
lineDash: [0],
width: 0.9
}),
fill: new Fill({
color: 'rgb(158,197,255,0.2)'
}),
image: new Circle({
radius: 6,
fill: new Fill({
color: 'blue'
}),
stroke: new Stroke({
color: '#ffffff',
width: 1.5
})
})
});
break;
// 查询结果样式
case 'result':
featureStyle = new Style({
stroke: new Stroke({
color: 'blue',
lineDash: [0],
width: 0.9
}),
fill: new Fill({
color: 'rgb(158,197,255,0)'
}),
image: new Circle({
radius: 6,
fill: new Fill({
color: 'blue'
}),
stroke: new Stroke({
color: '#ffffff',
width: 1.5
})
}),
text: new Text({ // 文本样式
text: feature ? feature.get('name') : '',
offsetX: 0 / resolution,
offsetY: 0 / resolution,
textAlign: 'center',
font: 'bold 14px 宋体',
fill: new Fill({
color: 'black'
}),
backgroundFill: new Fill({
color: "#FDFDFD"
}),
placement: "point",
overflow: true //超出面的部分不显示
}),
});
break;
// 激活样式
case 'active':
featureStyle = new Style({
fill: new Fill({
color: '#F3B59D'
}),
});
break;
//覆盖图层样式
case 'coverage':
featureStyle = new Style({
stroke: new Stroke({
color: '#E6E6E6',
lineDash: [0],
width: 0.9
}),
fill: new Fill({
color: '#e6e6e6b0'
})
});
break;
//红色样式
case 'red':
featureStyle = new Style({
stroke: new Stroke({
color: 'red',
lineDash: [0],
width: 0.9
})
});
break;
//通用样式
case 'normal':
featureStyle = new Style({
stroke: new Stroke({
color: 'blue',
lineDash: [0],
width: 0.9
}),
fill: new Fill({
color: 'rgb(158,197,255,0)'
}),
});
break;
//高亮样式
case 'highligh':
featureStyle = new Style({
stroke: new Stroke({
color: '#43FF12',
lineDash: [0],
width: 0.9
})
});
break;
case 'GF1':
featureStyle = new Style({
stroke: new Stroke({
color: '#0000FF',
lineDash: [0],
width: 0.9
}),
fill: new Fill({
color: 'rgb(158,197,255,0)'
}),
});
break;
case 'GF6':
featureStyle = new Style({
stroke: new Stroke({
color: '#FFFF00',
lineDash: [0],
width: 0.9
}),
fill: new Fill({
color: 'rgb(158,197,255,0)'
}),
});
break;
case 'Sentinel-2':
featureStyle = new Style({
stroke: new Stroke({
color: '#F24F4E',
lineDash: [0],
width: 0.9
}),
fill: new Fill({
color: 'rgb(158,197,255,0)'
}),
});
break;
case 'LandSat 8':
featureStyle = new Style({
stroke: new Stroke({
color: '#00FFC6',
lineDash: [0],
width: 0.9
}),
fill: new Fill({
color: 'rgb(158,197,255,0)'
}),
});
break;
case 'MODIS':
featureStyle = new Style({
stroke: new Stroke({
color: '#F59B22',
lineDash: [0],
width: 0.9
}),
fill: new Fill({
color: 'rgb(158,197,255,0)'
}),
});
break;
default:
break;
}
return featureStyle;
}
/**创建地图
* @param target {string} dom容器id
* @param centerPoint {Array} 中心点坐标
* @param dataCrs {Array} 数据坐标
* @param sysCrs {Array} 系统坐标
* @param zoom {Number} 层级
* @returns {Map}
*/
export function crtMap ({
target,
cent
没有合适的资源?快使用搜索试试~ 我知道了~
OpenLayers地图组件
共3个文件
js:2个
vue:1个
需积分: 0 1 下载量 138 浏览量
2024-02-21
14:13:48
上传
评论
收藏 8KB RAR 举报
温馨提示
对OpenLayers常用的功能进行组件封装,目前包括创建地图、创建9种类型的图层和创建常用样式的封装。
资源推荐
资源详情
资源评论
收起资源包目录
ol-map.rar (3个子文件)
ol-map.vue 5KB
ol-map.js 28KB
ol-api.js 591B
共 3 条
- 1
资源评论
鲤鱼跳龙门的鱼
- 粉丝: 29
- 资源: 4
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- Q1.py
- 企业政府灵智电子政务网站系统-lingzhi.rar
- Thinkphp内核开发Lsky Pro兰空图床网站源码.rar
- 基于FPGA(XC6SLX9)+SDRAM+AD7829多通道数据采集板硬件(原理图+PCB)工程文件.zip
- 阿里巴巴精准测试体系:基于代码链路分析的性能优化方案
- mmexport1714217773503.jpg
- 【图片网盘外链系统5.0】全新前端UI界面设计 支持图片违规检测网站自适应H5源码.rar
- jsp+sql的BBS论坛系统.zip
- 网盘外链PHP开发彩虹网盘外链程序源码.rar
- 2023年最新文件快递柜系统网站源码 保护用户隐私的匿名口令分享和临时文件分享功能.rar
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功