效果:

 创建地图:

var map = new ol.Map({
//设置显示地图的视图
view: new ol.View({
projection:'EPSG:4326',//投影方式
center: [108, 34],//定义初始显示位置
zoom: 3 ,//定义地图显示层级
}),
//创建地图图层
layers: [
//创建一个使用Open Street Map地图源的瓦片图层
new ol.layer.Tile({
source: new ol.source.OSM()
})
],
//让id为map的div作为地图的容器
target: 'map',
//控件初始默认不显示
controls:ol.control.defaults({
attribution: false,
zoom: false
}).extend([])
});

创建图片图层:

//静态图片资源
let source = new ol.source.ImageStatic({
url: 'lib/time.jpg',//图片网址
projection: 'EPSG:4326',//投影
imageExtent: [100,30,102,32]//图像坐标[minLon,minLat,maxLon,maxLat]
})
//wms资源
let wmsSource = new ol.source.ImageWMS({
url: "https://ahocevar.com/geoserver/wms",
params: { LAYERS: "ne:ne" },
serverType: "geoserver",
crossOrigin: "anonymous"
});
let imageLayer = new ol.layer.Image({
source: source,//该层的来源
zIndex:1,//图层渲染的Z索引,默认按加载顺序叠加
extent:[100,30,102,32],//图层渲染范围,可选值,默认渲染全部
visible:true,//是否显示,默认为true
opacity:1,//透明度,默认为1
})
map.addLayer(imageLayer)

图片图层关于map的方法:

//添加图片图层
map.addLayer(imageLayer)
//删除图片图层
map.removeLayer(imageLayer)

图片图层自身方法:

//获取-设置,渲染范围
imageLayer.getExtent()
imageLayer.setExtent([100,30,104,40])
//获取-设置,最大级别
imageLayer.getMaxZoom()
imageLayer.setMaxZoom(18)
//获取-设置,最小级别
imageLayer.getMinZoom()
imageLayer.setMinZoom(2)
//获取-设置,透明度
imageLayer.getOpacity()
imageLayer.setOpacity(0.9)
//获取-设置,图层源
imageLayer.getSource()
imageLayer.setSource(source)
//获取-设置,是否可见
imageLayer.getVisible()
imageLayer.setVisible(true)
//获取-设置,图层的Z-index
imageLayer.getZIndex()
imageLayer.setZIndex(2) //绑定事件-取消事件 type事件类型,listener函数体
imageLayer.on(type,listener)
imageLayer.un(type,listener)

【09】openlayers 图片图层的更多相关文章

  1. CALayer 知识:创建带阴影效果的圆角图片图层和创建自定义绘画内容图层

    效果如下: KMLayerDelegate.h #import <UIKit/UIKit.h> @interface KMLayerDelegate : NSObject @end KML ...

  2. arcgis api 4.x for js 自定义叠加图片图层实现地图叠加图片展示(附源码下载)

    前言 关于本篇功能实现用到的 api 涉及类看不懂的,请参照 esri 官网的 arcgis api 4.x for js:esri 官网 api,里面详细的介绍 arcgis api 4.x 各个类 ...

  3. openlayers筛选图层

    很多时候需要筛选图层,例如选择交互(ol.interaction.Select). 图片来自官方:https://openlayers.org/en/v4.6.5/apidoc/ol.interact ...

  4. openlayers自定义图层控制的实现

    好久没写博文了,今天出来冒个泡. 最近一直在考虑一件事情,那就是openlayers中自定义wms的图层控制.用过openlayers的人都知道,在openlayers中有自带的图层控制的控件,调用方 ...

  5. 【07】openlayers 矢量图层

    创建地图: //创建地图 var map = new ol.Map({ //设置显示地图的视图 view: new ol.View({ center: [0, 0],//义地图显示中心于经度0度,纬度 ...

  6. Openlayers 3 图层探查功能

    <body> <div id="map"></div> <script> var map=new ol.Map({ target:& ...

  7. openlayers 各种图层,持续更新

    /*高德地图*/ var vectorLayerLine = new ol.layer.Tile({ source: new ol.source.XYZ({ urls: [ "http:// ...

  8. 【05】openlayers 网格图层

    效果: 创建地图: //创建地图 var map = new ol.Map({ //设置显示地图的视图 view: new ol.View({ projection: 'EPSG:4326', //投 ...

  9. 【06】openlayers 切片图层

    创建地图: //OSM图层 let source = new ol.source.OSM() //切片图层tilelayer let layers = new ol.layer.Tile({ sour ...

随机推荐

  1. MOOC(10)- 获取响应中的cookie

  2. 线程、volatile与synchronized、Lock

    目录 线程 1.概念: 2.线程生命周期: 3.线程调度 4.线程实现 4.1.实现方式 4.2.之间的区别: 5.线程安全 5.1.volatile与synchronized 5.1.synchro ...

  3. Javascript面试题&知识点汇总

    问题&答案 什么时候 a ==1 && a== 2 && a==3 为 true? var a = { i: 1, toString: function () ...

  4. Docker 安装 CentOS

    Docker 安装 CentOS CentOS(Community Enterprise Operating System)是 Linux 发行版之一,它是来自于 Red Hat Enterprise ...

  5. iphone开发学习之路--基本语法

    关键字:Objective-C(以下简称O-C)是C语言的一个超集,也就是C语言的语法O-C都是兼容的,所以为了避免冲突O-C的关键字都是以@符号开始的,比如:@class.@public .@try ...

  6. caffe之mac下环境搭建

    参考 http://www.linuxidc.com/Linux/2016-09/135026.html 1. 安装brew,也叫homebrew,mac下类似于ubuntu的apt-get功能 cu ...

  7. python 写个冒泡排序吧

    冒泡排序 介绍: 冒泡排序(Bubble Sort,台湾译为:泡沫排序或气泡排序)是一种简单的排序算法.它重复地走访过要排序的数列,一次比较两个元素,如果他们的顺序错误就把他们交换过来.走访数列的工作 ...

  8. <JZOJ5904>刺客信条

    然鹅考场上打错某变量名导致30都没有 调了很久因为 没转换double 死亡 #include<cstdio> #include<algorithm> #include< ...

  9. Catch That Cow (BFS)

    题目: Farmer John has been informed of the location of a fugitive cow and wants to catch her immediate ...

  10. flask_admin+flask_login 整合,jieba分词+echarts数据分析可视化

    项目地址: https://github.com/WES6/list