Skip to content

Commit

Permalink
fix extend + cleanup code
Browse files Browse the repository at this point in the history
  • Loading branch information
claudiaifrim committed Sep 17, 2020
1 parent e46850d commit 302398a
Showing 1 changed file with 9 additions and 14 deletions.
23 changes: 9 additions & 14 deletions src/components/manage/Blocks/DiscodataOpenlayersMapBlock/View.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,19 +98,6 @@ let Map,
defaultsInteractions,
DragRotateAndZoom;
let OL_LOADED = false;
const initialExtent = [
-10686671.0000035,
-2430148.00000588,
6199975.99999531,
10421410.9999871,
];
let renderExtent = [];

const getDistance = (P1, P2) => {
const cathetus_1 = Math.pow(P1[0] - P2[0], 2);
const cathetus_2 = Math.pow(P1[1] - P2[1], 2);
return Math.sqrt(cathetus_1 + cathetus_2);
};

const OpenlayersMapView = (props) => {
const stateRef = useRef({
Expand Down Expand Up @@ -838,7 +825,7 @@ const OpenlayersMapView = (props) => {
visible: true,
title: 'ly_IED_SiteMap_WM',
});
// Regions source layer
// Regions source layerq
if (hasRegionsFeatures) {
regionsSourceLayer = new VectorLayer({
source: regionsSource,
Expand Down Expand Up @@ -908,6 +895,11 @@ const OpenlayersMapView = (props) => {
}
});
}

map.once('postrender', function(event) {
sitesSourceLayer.getSource().refresh();
});

map.on('moveend', function (e) {
if (mounted.current) {
if (hasSidebar && document.getElementById('dynamic-filter')) {
Expand All @@ -927,6 +919,9 @@ const OpenlayersMapView = (props) => {
let newZoom = map.getView().getZoom();
if (currentZoom !== newZoom) {
if (newZoom > zoomSwitch) {
if (!sitesSourceLayer.getVisible()) {
sitesSourceLayer.getSource().refresh();
}
sitesSourceLayer.setVisible(true);
hasRegionsFeatures && regionsSourceLayer.setVisible(false);
} else if (newZoom > 2) {
Expand Down

0 comments on commit 302398a

Please sign in to comment.