@evergis/react
Advanced tools
Comparing version 0.1.15 to 0.1.16
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const es_1 = require("@evergis/api/es"); | ||
const commonEvents_1 = require("@evergis/sgis/es/commonEvents"); | ||
const react_1 = require("react"); | ||
@@ -8,3 +9,3 @@ const useMount_1 = require("./useMount"); | ||
exports.useMapPick = () => { | ||
const { map } = MapContext_1.useMapContext(); | ||
const { map, painter } = MapContext_1.useMapContext(); | ||
const [geometryParams, setGeometryParams] = react_1.useState(); | ||
@@ -16,16 +17,9 @@ // TODO map layers now is not evergis layers | ||
const pick = react_1.useCallback((event) => { | ||
const clickEvent = event; | ||
const { browserEvent } = clickEvent; | ||
if (!browserEvent.target || !browserEvent.view) { | ||
console.warn('browserEvent have no target or view properties'); | ||
if (!(event instanceof commonEvents_1.sGisClickEvent)) { | ||
return; | ||
} | ||
const { clientWidth, clientHeight } = browserEvent.target; | ||
const { innerWidth, innerHeight } = browserEvent.view; | ||
const xOffset = innerWidth - clientWidth; | ||
const yOffset = innerHeight - clientHeight; | ||
const clickPoint = [browserEvent.x - xOffset, browserEvent.y - yOffset]; | ||
const imageRectangle = [0, 0, clientWidth, clientHeight]; | ||
const imageRectangle = [0, 0, painter.width, painter.height]; | ||
const [x, y] = painter.getPxPosition(event.point.position); | ||
setGeometryParams({ | ||
clickPoint, | ||
clickPoint: [Math.round(x), Math.round(y)], | ||
envelopes: collectLayerEnvelopes(evergisLayers), | ||
@@ -32,0 +26,0 @@ imageRectangle, |
import { isEvergisDynamicLayer, } from '@evergis/api/es'; | ||
import { sGisClickEvent } from '@evergis/sgis/es/commonEvents'; | ||
import { useCallback, useMemo, useState } from 'react'; | ||
@@ -6,3 +7,3 @@ import { useMount } from './useMount'; | ||
export const useMapPick = () => { | ||
const { map } = useMapContext(); | ||
const { map, painter } = useMapContext(); | ||
const [geometryParams, setGeometryParams] = useState(); | ||
@@ -14,16 +15,9 @@ // TODO map layers now is not evergis layers | ||
const pick = useCallback((event) => { | ||
const clickEvent = event; | ||
const { browserEvent } = clickEvent; | ||
if (!browserEvent.target || !browserEvent.view) { | ||
console.warn('browserEvent have no target or view properties'); | ||
if (!(event instanceof sGisClickEvent)) { | ||
return; | ||
} | ||
const { clientWidth, clientHeight } = browserEvent.target; | ||
const { innerWidth, innerHeight } = browserEvent.view; | ||
const xOffset = innerWidth - clientWidth; | ||
const yOffset = innerHeight - clientHeight; | ||
const clickPoint = [browserEvent.x - xOffset, browserEvent.y - yOffset]; | ||
const imageRectangle = [0, 0, clientWidth, clientHeight]; | ||
const imageRectangle = [0, 0, painter.width, painter.height]; | ||
const [x, y] = painter.getPxPosition(event.point.position); | ||
setGeometryParams({ | ||
clickPoint, | ||
clickPoint: [Math.round(x), Math.round(y)], | ||
envelopes: collectLayerEnvelopes(evergisLayers), | ||
@@ -30,0 +24,0 @@ imageRectangle, |
{ | ||
"name": "@evergis/react", | ||
"version": "0.1.15", | ||
"version": "0.1.16", | ||
"description": "React components for creating GIS apps with evergis server", | ||
@@ -5,0 +5,0 @@ "author": "everpoint", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
89818
1158