Skip to content

Commit

Permalink
Update labels accordingly with edits/deletions
Browse files Browse the repository at this point in the history
  • Loading branch information
nicoleiftekhar committed Jul 30, 2024
1 parent bd579dc commit 39d5e88
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/pages/conversion/places-preview-map/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ const PlacesPreviewMap = ({ style }) => {

// Entry point when "unit.geojson" is pressed; the following code should be refactored due to redundancy
function unitInteractions(units, drawingManager, map) {
var unitLayer, unitLines, polygonHoverLayer;
var layersAdded = [unitLayer, unitLines, polygonHoverLayer];
var unitLayer, unitLines, polygonHoverLayer, unitSymbols;
var layersAdded = [unitLayer, unitLines, polygonHoverLayer, unitSymbols];
const groupedFeatures = groupAndSort(units, language, selectedLevel);
const keys = Object.keys(groupedFeatures);

Expand All @@ -167,25 +167,27 @@ const PlacesPreviewMap = ({ style }) => {
fillColor: 'rgba(150, 50, 255, 0.2)',
filter: ['==', ['get', 'id'], '']
});

unitSymbols = new layer.SymbolLayer(dataSource, null, getTextStyle(category));

map.layers.add([unitLayer, polygonHoverLayer, unitLines], 'roomPolygons');
map.layers.add([unitLayer, polygonHoverLayer, unitLines, unitSymbols], 'roomPolygons');

grabToPointer([unitLayer, polygonHoverLayer], map);
featureHover(unitLayer, polygonHoverLayer);

map.layers.add(new layer.SymbolLayer(dataSource, null, getTextStyle(category)), 'roomLabels');
// map.layers.add(new layer.SymbolLayer(dataSource, null, getTextStyle(category)), 'roomLabels');

var drawingSource = drawingManager.getSource();
drawingSource.add(features);

let dmLayers = drawingManager.getLayers();
dmLayers.polygonLayer.setOptions({ visible: false });
dmLayers.polygonOutlineLayer.setOptions({ visible: false });
layersAdded = [unitLayer, unitLines, polygonHoverLayer];
layersAdded = [unitLayer, unitLines, polygonHoverLayer, unitSymbols];

map.events.add('drawingmodechanged', drawingManager, (e) => {
let dmLayers = drawingManager.getLayers();
layersAdded = [unitLayer, unitLines, polygonHoverLayer];
layersAdded = [unitLayer, unitLines, polygonHoverLayer, unitSymbols];

if (e === 'idle') {
dmLayers.polygonLayer.setOptions({ visible: false });
Expand All @@ -198,12 +200,13 @@ const PlacesPreviewMap = ({ style }) => {
fillColor: 'rgba(150, 50, 255, 0.2)',
filter: ['==', ['get', 'id'], '']
});
unitSymbols = new layer.SymbolLayer(drawingManager.getSource(), null, getTextStyle(category));

map.layers.add([unitLayer, polygonHoverLayer, unitLines], 'roomPolygons');
map.layers.add([unitLayer, polygonHoverLayer, unitLines, unitSymbols], 'roomPolygons');

grabToPointer([unitLayer, polygonHoverLayer], map);
featureHover(unitLayer, polygonHoverLayer);
layersAdded = [unitLayer, unitLines, polygonHoverLayer];
layersAdded = [unitLayer, unitLines, polygonHoverLayer, unitSymbols];
}
else if (e === 'edit-geometry' || e === 'erase-geometry' || e === 'draw-polygon') {
drawingModeChanged(layersAdded);
Expand Down

0 comments on commit 39d5e88

Please sign in to comment.