-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #145 from Azure/imdf-editor
IMDF Editor: clickable units, layers, geojson info, and editable features
- Loading branch information
Showing
10 changed files
with
906 additions
and
131 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
export const control = { | ||
DrawingToolbar: function (options) { | ||
return options; | ||
} | ||
}; | ||
|
||
export const drawing = { | ||
DrawingManager: function (map, options) { | ||
return [map, options]; | ||
} | ||
}; |
60 changes: 60 additions & 0 deletions
60
src/pages/conversion/places-preview-map/imdf-model-helpers/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import { getFeatureLabel } from '../utils'; | ||
|
||
// Sets polygon, line, and symbol layers to invisible | ||
function drawingModeChanged(allLayers) { | ||
allLayers.forEach(layer => { | ||
layer.setOptions({ visible: false }); | ||
}); | ||
} | ||
|
||
// Displays information of a feature that is being drawn/edited, at time of click | ||
function currentEditData(map, drawingManager) { | ||
map.events.add('drawingstarted', drawingManager, (f) => { | ||
if(f?.data) { | ||
var shapeId = f.data.id; | ||
var geojsonData = drawingManager.getSource().getShapeById(shapeId).data; | ||
document.getElementById('infoPanel-json').value = JSON.stringify(geojsonData, null, 2); | ||
} | ||
}); | ||
} | ||
|
||
// Groups features together by category and filters them by levels | ||
function groupAndSort(units, language, selectedLevel) { | ||
const groupedFeatures = {}; | ||
units.features | ||
.filter(item => item.properties.level_id === selectedLevel.id) | ||
.forEach(feature => { | ||
const { category } = feature.properties; | ||
if (!groupedFeatures[category]) groupedFeatures[category] = { features: [] }; | ||
groupedFeatures[category].features.push({ | ||
...feature, | ||
properties: { ...feature.properties, label: getFeatureLabel(feature, language) }, | ||
}); | ||
}); | ||
|
||
return groupedFeatures; | ||
} | ||
|
||
function writeToInfoPanel(geojsonData) { | ||
const { map, ...obj } = geojsonData; | ||
document.getElementById('infoPanel-json').value = JSON.stringify(obj, null, 2); | ||
} | ||
|
||
// Changes the cursor to be a pointer when a clickable feature is hovered over | ||
function grabToPointer(layerName, map) { | ||
map.events.add('mouseover', layerName, function () { | ||
map.getCanvasContainer().style.cursor = 'pointer'; | ||
}); | ||
|
||
map.events.add('mouseout', layerName, function () { | ||
map.getCanvasContainer().style.cursor = 'grab'; | ||
}); | ||
} | ||
|
||
export { | ||
currentEditData, | ||
groupAndSort, | ||
drawingModeChanged, | ||
writeToInfoPanel, | ||
grabToPointer | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,44 @@ | ||
import { css } from '@emotion/css'; | ||
|
||
export const mapTextWrapper = css ` | ||
display: flex; | ||
gap: 2rem; | ||
` | ||
|
||
export const imdfPreviewMapWrapper = css` | ||
position: relative; | ||
width: 100%; | ||
flex: 5 1 4rem; | ||
`; | ||
|
||
export const imdfPreviewMap = css` | ||
width: 100%; | ||
height: 500px; | ||
height: 30rem; | ||
`; | ||
|
||
export const layerSelect = css ` | ||
position: relative; | ||
top: 65%; | ||
`; | ||
|
||
export const textWrapper = css ` | ||
flex: 1 1 4rem; | ||
position: relative; | ||
display: inline; | ||
margin-top: 1%; | ||
`; | ||
|
||
export const textArea = css ` | ||
width: 95%; | ||
height: 95%; | ||
white-space: nowrap; | ||
resize: none; | ||
`; | ||
|
||
export const saveButtonWrapper = css ` | ||
display: flex; | ||
flex-direction: row; | ||
justify-content: flex-end; | ||
`; | ||
|
||
|
Oops, something went wrong.