Skip to content

Commit

Permalink
Added level polygon layer
Browse files Browse the repository at this point in the history
  • Loading branch information
nicoleiftekhar committed Aug 26, 2024
1 parent 687d0c3 commit 3991972
Showing 1 changed file with 30 additions and 20 deletions.
50 changes: 30 additions & 20 deletions src/pages/conversion/places-preview-map/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ const PlacesPreviewMap = ({ style, unitsChanged, levelsChanged, footprintChanged
if(selectedLayerId === 'unitButton')
features = map.layers.getRenderedShapes(e.position, 'unitClick');
else if(selectedLayerId === 'levelButton')
features = map.layers.getRenderedShapes(e.position, 'levelClick');
features = map.layers.getRenderedShapes(e.position, 'levelFill');
else if(selectedLayerId === 'footprintButton')
features = map.layers.getRenderedShapes(e.position, 'footprintClick');
else
Expand Down Expand Up @@ -302,28 +302,29 @@ const PlacesPreviewMap = ({ style, unitsChanged, levelsChanged, footprintChanged
// Retrieve information about the level currently chosen by user
levelsChanged(levels);
const selectedLevelDetails = levels.features.filter(item => item.id === selectedLevel.id);
var lineLayer, lineHoverLayer, lineClickLayer;
var layersAdded = [lineLayer, lineHoverLayer, lineClickLayer];
var lineLayer, lineHoverLayer, lineClickLayer, linePolygonLayer;
var layersAdded = [lineLayer, lineHoverLayer, lineClickLayer, linePolygonLayer];

const dataSource = new source.DataSource();
map.sources.add(dataSource);
dataSource.add(selectedLevelDetails);

// Displays outline of level + change in color when cursor is hovering
lineLayer = new layer.LineLayer(dataSource, 'levelClick', getLineStyles('level', 'walkway'));
lineHoverLayer = new layer.LineLayer(dataSource, null, {
strokeColor: 'rgba(135, 206, 250, 0.8)',
linePolygonLayer = new layer.PolygonLayer(dataSource, 'levelFill', getFillStyles('level', 'unspecified'));
lineHoverLayer = new layer.PolygonLayer(dataSource, null, {
fillColor: 'rgba(135, 206, 250, 0.8)',
filter: ['==', ['get', '_azureMapsShapeId'], '']
});

lineClickLayer = new layer.LineLayer(dataSource, 'lineClickLayer', {
strokeColor: 'rgba(75, 146, 210, 0.8)',
lineClickLayer = new layer.PolygonLayer(dataSource, 'lineClickLayer', {
fillColor: 'rgba(75, 146, 210, 0.8)',
filter: ['==', ['get', 'id'], '']
});

map.layers.add([lineLayer, lineHoverLayer, lineClickLayer], 'walkwayPolygons');
layersAdded = [lineLayer, lineHoverLayer, lineClickLayer];
featureHoverClick(lineLayer, lineHoverLayer, lineClickLayer);
map.layers.add([lineLayer, linePolygonLayer, lineHoverLayer, lineClickLayer], 'walkwayPolygons');
layersAdded = [lineLayer, lineHoverLayer, lineClickLayer, linePolygonLayer];
featureHoverClick(linePolygonLayer, lineHoverLayer, lineClickLayer);

var drawingSource = drawingManager.getSource();
drawingSource.add(selectedLevelDetails);
Expand All @@ -339,18 +340,20 @@ const PlacesPreviewMap = ({ style, unitsChanged, levelsChanged, footprintChanged
dmLayers.polygonOutlineLayer.setOptions({ visible: false });

var lineLayer = new layer.LineLayer(drawingManager.getSource(), 'levelClick', getLineStyles('level', 'walkway'));
lineHoverLayer = new layer.LineLayer(drawingManager.getSource(), null, {
strokeColor: 'rgba(135, 206, 250, 1)',
linePolygonLayer = new layer.PolygonLayer(drawingManager.getSource(), 'levelFill', getFillStyles('level', 'unspecified'));
lineHoverLayer = new layer.PolygonLayer(drawingManager.getSource(), null, {
fillColor: 'rgba(135, 206, 250, 0.8)',
filter: ['==', ['get', '_azureMapsShapeId'], '']
});
lineClickLayer = new layer.LineLayer(drawingManager.getSource(), 'lineClickLayer', {
strokeColor: 'rgba(75, 146, 210, 0.7)',

lineClickLayer = new layer.PolygonLayer(drawingManager.getSource(), 'lineClickLayer', {
fillColor: 'rgba(75, 146, 210, 0.8)',
filter: ['==', ['get', 'id'], '']
});

map.layers.add([lineLayer, lineHoverLayer, lineClickLayer], 'walkwayPolygons');
layersAdded = [lineLayer, lineHoverLayer, lineClickLayer];
featureHoverClick(lineLayer, lineHoverLayer, lineClickLayer);
map.layers.add([lineLayer, lineHoverLayer, lineClickLayer, linePolygonLayer], 'walkwayPolygons');
layersAdded = [lineLayer, lineHoverLayer, lineClickLayer, linePolygonLayer];
featureHoverClick(linePolygonLayer, lineHoverLayer, lineClickLayer);

let updatedFeatures = drawingManager.getSource().shapes;
setLevels(prevLevels => updateLevels(prevLevels, selectedLevel, (updatedFeatures[0]).data));
Expand All @@ -361,9 +364,16 @@ const PlacesPreviewMap = ({ style, unitsChanged, levelsChanged, footprintChanged
else if (e === 'edit-geometry') {
drawingModeChanged(layersAdded);
dmLayers.polygonOutlineLayer.setOptions({ visible: true });
dmLayers.polygonLayer.setOptions({ visible: false });
dmLayers.polygonLayer.setOptions({ visible: true });

currentEditData(map, drawingManager, setJsonData);

document.addEventListener('keydown', function (e) {
// Check if the delete or backspace key is pressed
if (e.key === 'Delete' || e.key === 'Backspace') {
drawingManager.setOptions({ mode: 'idle' });
}
});
}
else {
// This will eventually be a visible pop-up
Expand Down

0 comments on commit 3991972

Please sign in to comment.