@evergis/react
Advanced tools
Comparing version 0.1.13 to 0.1.14
@@ -6,3 +6,3 @@ "use strict"; | ||
const byScale = (scale) => ({ zIndex }) => zIndex === scale; | ||
exports.useMaxMinScale = (minScale, maxScale) => { | ||
exports.useMaxMinScale = (minScale, maxScale, currentPosition, currentResolution) => { | ||
const { map } = MapContext_1.useMapContext(); | ||
@@ -23,9 +23,13 @@ react_1.useEffect(() => { | ||
} | ||
exports.updateMapResolution(map); | ||
if (minScale !== undefined || maxScale !== undefined) { | ||
exports.updateMapResolution(map, currentPosition, currentResolution); | ||
} | ||
}, [map, minScale, maxScale]); | ||
}; | ||
exports.updateMapResolution = (map) => { | ||
const newResolution = Math.min(Math.max(map.resolution, map.minResolution || 0), map.maxResolution || Number.MAX_VALUE); | ||
map.animateTo(map.position, newResolution); | ||
exports.updateMapResolution = (map, currentPosition, currentResolution) => { | ||
if (currentPosition && currentResolution) { | ||
const newResolution = Math.min(Math.max(currentResolution, map.minResolution || 0), map.maxResolution || Number.MAX_VALUE); | ||
map.animateTo(currentPosition, newResolution); | ||
} | ||
}; | ||
//# sourceMappingURL=useMaxMinScale.js.map |
@@ -20,3 +20,3 @@ "use strict"; | ||
useUpdateMapView_1.useUpdateMapView({ position, resolution }); | ||
useMaxMinScale_1.useMaxMinScale(minScale, maxScale); | ||
useMaxMinScale_1.useMaxMinScale(minScale, maxScale, position, resolution); | ||
useMapBboxChange_1.useMapBboxChange(handleBboxChange); | ||
@@ -23,0 +23,0 @@ return (React.createElement("div", { className: className, ref: wrapperRef }, children)); |
import { Map } from '@evergis/sgis/es/Map'; | ||
export declare const useMaxMinScale: (minScale?: number | undefined, maxScale?: number | undefined) => void; | ||
export declare const updateMapResolution: (map: Map) => void; | ||
export declare const useMaxMinScale: (minScale?: number | undefined, maxScale?: number | undefined, currentPosition?: [number, number] | undefined, currentResolution?: number | undefined) => void; | ||
export declare const updateMapResolution: (map: Map, currentPosition?: [number, number] | undefined, currentResolution?: number | undefined) => void; |
import { useEffect } from 'react'; | ||
import { useMapContext } from '../MapContext'; | ||
const byScale = (scale) => ({ zIndex }) => zIndex === scale; | ||
export const useMaxMinScale = (minScale, maxScale) => { | ||
export const useMaxMinScale = (minScale, maxScale, currentPosition, currentResolution) => { | ||
const { map } = useMapContext(); | ||
@@ -20,9 +20,13 @@ useEffect(() => { | ||
} | ||
updateMapResolution(map); | ||
if (minScale !== undefined || maxScale !== undefined) { | ||
updateMapResolution(map, currentPosition, currentResolution); | ||
} | ||
}, [map, minScale, maxScale]); | ||
}; | ||
export const updateMapResolution = (map) => { | ||
const newResolution = Math.min(Math.max(map.resolution, map.minResolution || 0), map.maxResolution || Number.MAX_VALUE); | ||
map.animateTo(map.position, newResolution); | ||
export const updateMapResolution = (map, currentPosition, currentResolution) => { | ||
if (currentPosition && currentResolution) { | ||
const newResolution = Math.min(Math.max(currentResolution, map.minResolution || 0), map.maxResolution || Number.MAX_VALUE); | ||
map.animateTo(currentPosition, newResolution); | ||
} | ||
}; | ||
//# sourceMappingURL=useMaxMinScale.js.map |
@@ -17,3 +17,3 @@ import * as React from 'react'; | ||
useUpdateMapView({ position, resolution }); | ||
useMaxMinScale(minScale, maxScale); | ||
useMaxMinScale(minScale, maxScale, position, resolution); | ||
useMapBboxChange(handleBboxChange); | ||
@@ -20,0 +20,0 @@ return (React.createElement("div", { className: className, ref: wrapperRef }, children)); |
{ | ||
"name": "@evergis/react", | ||
"version": "0.1.13", | ||
"version": "0.1.14", | ||
"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
90783
1170