1)选择“手图”→“图层管理”(图 7.0.1)。
2)选中某个文件后点击“插入”按钮(也可点击“添加”,图像则将加入到文件列表的末尾,在图中将在最顶层显示,覆盖其他图层)(图 7.0.2)。
3)在图层类型组合框中选中“图象层”(图 7.0.3)。
图 7.0.1 图层管理
图 7.0.2 插入或添加图层
图 7.0.3 选择图像层
4)选择图像文件,然后点击“确定”(图 7.0.4)。
图 7.0.4 选择图像文件
5)添加影像后如图 7.0.5 所示。
图 7.0.5 打开影像图
import 'ol/ol.css'
import { Feature } from "ol"
import { Circle as CircleStyle, Fill, Stroke, Style, Icon } from 'ol/style'
import { Draw, Modify, Snap } from 'ol/interaction'
import { Vector as VectorSource } from 'ol/source'
import { Vector as VectorLayer } from 'ol/layer'
import GeoJSON from "ol/format/GeoJSON"
import { boundingExtent } from 'ol/extent'
import { Point } from 'ol/geom'
`// 初始化
init (type) {
`//type为绘制类型``
//清除次图层
if (_that.iconLayer) {
}
// 移除绘制方法
Map.removeInteraction(_that.draw)
Map.removeInteraction(_that.snap)
// 创建矢量容器
_that.source = new VectorSource()
//创建矢量层
_that.iconLayer = new VectorLayer({
})
//创建绘制修改工具
const modify = new Modify({ source: _that.source })
//添加
Map.addInteraction(modify)
//绑定修改绘制图形触发事件
modify.on('modifyend', this.ModifyIconEnd)
//添加绘制工具
_that.addInteractions()
_that.draw = new Draw({
})
// 此方法用于保存拓扑关系
_that.snap = new Snap({ source: _that.source })
// 添加
Map.addInteraction(_that.draw)
Map.addInteraction(_that.snap)
// 监听绘制结束事件
_that.draw.on("drawend", (evt) =>{
// 获取绘制图形,其余同修改时处理数据
let featureGeoJson = new GeoJSON().writeFeature(evt.feature)
})
//图层添加至地图
Map.addLayer(_that.iconLayer)
},
//样式函数
styleFunction (feature) {
const styles = [
]
// 此处添加箭头样式,绘制线绘制箭头
if (this.type == 'LineString' &&this.operate == 'arrow') {
}
//返回样式
return styles
},
// 修改图形
ModifyIconEnd (evt) {
const _that = this
// 获取修改后的图形,并保存
let featureGeoJson = new GeoJSON().writeFeature(evt.features.array_[0])
this.featureData = featureGeoJson
//绘制为圆时,无法通过geoJson回显,获取半径和中点回显
if (_that.type == 'Circle') {
// 圆的半径换算
}
//绘制线段取绘制次序中点备用
else if (_that.type == 'LineString') {
}
//绘制区域时获取其中点
else if (_that.type == 'Polygon') {
//获取边界值
}
},
目前国内主要有以下三种坐标系:WGS84:为一种大地坐标系,也是目前广泛使用的GPS全球卫星定位系统使用的坐标系。
GCJ02:又称火星坐标系,是由中国国家测绘局制订的地理信息系统的坐标系统。由WGS84坐标系经加密后的坐标系。
BD09:为百度坐标系,在GCJ02坐标系基础上再次加密。其中bd09ll表示百度经纬度坐标,bd09mc表示百度墨卡托米制坐标。
非中国地区地图,服务坐标统一使用WGS84坐标。
初始化一幅地图时,至少需要一个可视区域(view),一个或多个图层(layer),和一个地图加载的目标HTML标签(target)。
OpenLayers自带平移和缩放功能,我们也可以自己添加缩放
可以更改坐标投影和中心点来定位到中国
在初始化地图之后还可以再次添加图层
添加图层后可以控制图层的显示和隐藏
WMS地图服务发布好地图后,可以通过url传参params访问到相应的图层
矢量图层一般都是GeoJson格式的数据,可以直接加载在线的GeoJson数据
加载在线GeoJson需要提供url和format属性
或者加载本地json文件,需要提供features属性,通过readFeatures读取json文件
OpenLayers对矢量图层GeoJson中的要素有默认的样式,也可以覆写样式
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)