Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
frontend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Jira
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
minerva
frontend
Merge requests
!282
feat(vector-map): text placement for modifications
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
feat(vector-map): text placement for modifications
feat/MIN-62-modifications-text-placement
into
development
Overview
0
Commits
1
Pipelines
2
Changes
2
Merged
Miłosz Grocholewski
requested to merge
feat/MIN-62-modifications-text-placement
into
development
5 months ago
Overview
0
Commits
1
Pipelines
2
Changes
2
Expand
Closes
MIN-62
0
0
Merge request reports
Viewing commit
b1f29be8
Show latest version
2 files
+
38
−
17
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
2
Search (e.g. *.vue) (Ctrl+P)
b1f29be8
feat(vector-map): text placement for modifications
· b1f29be8
Miłosz Grocholewski
authored
5 months ago
src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/MapElement.ts
+
32
−
17
Options
/* eslint-disable no-magic-numbers */
import
{
Style
,
Text
}
from
'
ol/style
'
;
import
{
Style
}
from
'
ol/style
'
;
import
{
UsePointToProjectionResult
}
from
'
@/utils/map/usePointToProjection
'
;
import
getStroke
from
'
@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getStroke
'
;
import
getFill
from
'
@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getFill
'
;
@@ -18,6 +18,8 @@ import {
}
from
'
@/components/Map/MapViewer/MapViewerVector/MapViewerVector.constants
'
;
import
BaseMultiPolygon
from
'
@/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/BaseMultiPolygon
'
;
import
getStyle
from
'
@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getStyle
'
;
import
getTextCoords
from
'
@/components/Map/MapViewer/MapViewerVector/utils/shapes/text/getTextCoords
'
;
import
getTextStyle
from
'
@/components/Map/MapViewer/MapViewerVector/utils/shapes/text/getTextStyle
'
;
export
type
MapElementProps
=
{
shapes
:
Array
<
Shape
>
;
@@ -175,24 +177,37 @@ export default class MapElement extends BaseMultiPolygon {
fill
:
getFill
({
color
:
rgbToHex
(
modification
.
fillColor
)
}),
zIndex
:
modification
.
z
,
});
const
modificationText
=
modification
.
stateAbbreviation
?
modification
.
stateAbbreviation
:
modification
.
name
;
if
(
modificationText
)
{
modificationStyle
.
setText
(
new
Text
({
text
:
modificationText
,
font
:
`
${
modification
.
fontSize
}
pt Arial`
,
textAlign
:
'
center
'
,
textBaseline
:
'
middle
'
,
fill
:
getFill
({
color
:
'
#000
'
}),
overflow
:
true
,
}),
);
this
.
polygonsTexts
.
push
(
modificationText
);
}
this
.
styles
.
push
(
modificationStyle
);
});
const
modificationText
=
modification
.
stateAbbreviation
?
modification
.
stateAbbreviation
:
modification
.
name
;
if
(
modificationText
)
{
const
modificationTextCoords
=
getTextCoords
({
x
:
modification
.
nameX
,
y
:
modification
.
nameY
,
width
:
modification
.
nameWidth
,
height
:
modification
.
nameHeight
,
fontSize
:
modification
.
fontSize
,
verticalAlign
:
modification
.
nameVerticalAlign
,
horizontalAlign
:
modification
.
nameHorizontalAlign
,
pointToProjection
:
this
.
pointToProjection
,
});
const
modificationTextPolygon
=
new
Polygon
([
[
modificationTextCoords
,
modificationTextCoords
],
]);
const
modificationTextStyle
=
getTextStyle
({
text
:
modificationText
,
fontSize
:
modification
.
fontSize
,
color
:
rgbToHex
(
BLACK_COLOR
),
zIndex
:
modification
.
z
,
horizontalAlign
:
modification
.
nameHorizontalAlign
,
});
modificationTextStyle
.
setGeometry
(
modificationTextPolygon
);
this
.
styles
.
push
(
modificationTextStyle
);
this
.
polygonsTexts
.
push
(
modificationText
);
this
.
polygons
.
push
(
modificationTextPolygon
);
}
}
drawActiveBorder
(
homodimerShift
:
number
,
homodimerOffset
:
number
):
void
{
Loading