函数s
-
import {getRenderPixel} from 'ol/render';从地图视口的 CSS 像素获取事件 canvas 上下文的像素。
Name Type Description eventRenderEvent 渲染事件。
pixelPixel 相对于地图视口左上角的 CSS 像素。
返回值:
Pixel on the event's canvas context.
-
import {getVectorContext} from 'ol/render';获取用于绘制到事件 canvas 的矢量上下文。
Name Type Description eventRenderEvent 渲染事件。
返回值:
Vector context.
-
import {toContext} from 'ol/render';将 Canvas Immediate API 绑定到 canvas 上下文,以允许将几何图形绘制到上下文的 canvas。
几何图形坐标的单位是相对于 canvas 元素左上角的 CSS 像素。
import {toContext} from 'ol/render.js'; import Fill from 'ol/style/Fill.js'; import Polygon from 'ol/geom/Polygon。js'; const canvas = document.createElement('canvas'); const render = toContext( canvas.getContext('2d'), {size: [100, 100]} ); render.setFillStrokeStyle(new Fill({ color: blue })); render.drawPolygon( new Polygon([[[0, 0], [100, 100], [100, 0], [0, 0]]]) );Name Type Description contextCanvasRenderingContext2D Canvas 上下文。
options选项。
Name Type Description sizeSize | undefined 所需的 canvas 尺寸(CSS 像素)。提供时,canvas 和 CSS 尺寸将根据
pixelRatio设置。如果未提供,当前的 canvas 和 CSS 尺寸将不会更改。pixelRationumber (defaults to window.devicePixelRatio) canvas 的像素比(canvas 像素与 CSS 像素的比率)。
返回值:
Canvas Immediate.
Type Definitions
-
-
State{Object}
-
Properties:
Name Type Description contextCanvasRenderingContext2D 图层正在渲染到的 Canvas 上下文。
feature要素Like 要素。
geometrySimpleGeometry 几何对象。
pixelRationumber 图层渲染器使用的像素比。
resolutionnumber 渲染批次创建和优化时的分辨率。这不是正在渲染的视图分辨率。
rotationnumber 渲染图层的旋转角度(弧度)。
-
ToContextOptions{Object}
-
Properties:
Name Type Description sizeSize | undefined 所需的 canvas 尺寸(CSS 像素)。提供时,canvas 和 CSS 尺寸将根据
pixelRatio设置。如果未提供,当前的 canvas 和 CSS 尺寸将不会更改。pixelRationumber
(defaults to window.devicePixelRatio)canvas 的像素比(canvas 像素与 CSS 像素的比率)。