Clearer function name for getting a render pixel
This commit is contained in:
+3
-3
@@ -3,7 +3,7 @@ import View from '../src/ol/View.js';
|
|||||||
import TileLayer from '../src/ol/layer/Tile.js';
|
import TileLayer from '../src/ol/layer/Tile.js';
|
||||||
import {fromLonLat} from '../src/ol/proj.js';
|
import {fromLonLat} from '../src/ol/proj.js';
|
||||||
import BingMaps from '../src/ol/source/BingMaps.js';
|
import BingMaps from '../src/ol/source/BingMaps.js';
|
||||||
import {getPixelFromPixel} from '../src/ol/render.js';
|
import {getRenderPixel} from '../src/ol/render.js';
|
||||||
|
|
||||||
const key = 'As1HiMj1PvLPlqc_gtM7AqZfBL8ZL3VrjaS3zIb22Uvb9WKhuJObROC-qUpa81U5';
|
const key = 'As1HiMj1PvLPlqc_gtM7AqZfBL8ZL3VrjaS3zIb22Uvb9WKhuJObROC-qUpa81U5';
|
||||||
|
|
||||||
@@ -51,8 +51,8 @@ container.addEventListener('mouseout', function() {
|
|||||||
// after rendering the layer, show an oversampled version around the pointer
|
// after rendering the layer, show an oversampled version around the pointer
|
||||||
imagery.on('postrender', function(event) {
|
imagery.on('postrender', function(event) {
|
||||||
if (mousePosition) {
|
if (mousePosition) {
|
||||||
const pixel = getPixelFromPixel(event, mousePosition);
|
const pixel = getRenderPixel(event, mousePosition);
|
||||||
const offset = getPixelFromPixel(event, [mousePosition[0] + radius, mousePosition[1]]);
|
const offset = getRenderPixel(event, [mousePosition[0] + radius, mousePosition[1]]);
|
||||||
const half = Math.sqrt(Math.pow(offset[0] - pixel[0], 2) + Math.pow(offset[1] - pixel[1], 2));
|
const half = Math.sqrt(Math.pow(offset[0] - pixel[0], 2) + Math.pow(offset[1] - pixel[1], 2));
|
||||||
const context = event.context;
|
const context = event.context;
|
||||||
const centerX = pixel[0];
|
const centerX = pixel[0];
|
||||||
|
|||||||
+3
-3
@@ -99,14 +99,14 @@ export function getVectorContext(event) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the pixel of the event's canvas context from the map viewport's css pixel
|
* Gets the pixel of the event's canvas context from the map viewport's CSS pixel.
|
||||||
* @param {import("./render/Event.js").default} event Render event.
|
* @param {import("./render/Event.js").default} event Render event.
|
||||||
* @param {import("./pixel.js").Pixel} pixel Css pixel relative to the top-left
|
* @param {import("./pixel.js").Pixel} pixel CSS pixel relative to the top-left
|
||||||
* corner of the map viewport.
|
* corner of the map viewport.
|
||||||
* @returns {import("./pixel.js").Pixel} Pixel on the event's canvas context.
|
* @returns {import("./pixel.js").Pixel} Pixel on the event's canvas context.
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
export function getPixelFromPixel(event, pixel) {
|
export function getRenderPixel(event, pixel) {
|
||||||
const result = pixel.slice(0);
|
const result = pixel.slice(0);
|
||||||
applyTransform(event.inversePixelTransform.slice(), result);
|
applyTransform(event.inversePixelTransform.slice(), result);
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
Reference in New Issue
Block a user