Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
V
VIPSLogic
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
VIPS
VIPSLogic
Commits
bf5108fc
Commit
bf5108fc
authored
8 months ago
by
Lene Wasskog
Browse files
Options
Downloads
Patches
Plain Diff
feat: Ensure map works without poi type information
parent
12b39a37
No related branches found
No related tags found
1 merge request
!191
Add map module and Open-Meteo support
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/webapp/js/mapModal.js
+35
-14
35 additions, 14 deletions
src/main/webapp/js/mapModal.js
with
35 additions
and
14 deletions
src/main/webapp/js/mapModal.js
+
35
−
14
View file @
bf5108fc
...
@@ -58,6 +58,7 @@ class MapModal {
...
@@ -58,6 +58,7 @@ class MapModal {
submitLocation
:
'
OK
'
,
submitLocation
:
'
OK
'
,
zoomToLocation
:
'
Zoom to My Location
'
,
zoomToLocation
:
'
Zoom to My Location
'
,
geolocationNotSupported
:
'
Geolocation is not supported by this browser
'
,
geolocationNotSupported
:
'
Geolocation is not supported by this browser
'
,
geolocationNotSupported
:
'
Geolocation is not supported by this browser
'
,
geolocationFailed
:
'
Unable to retrieve your location
'
,
geolocationFailed
:
'
Unable to retrieve your location
'
,
closeMap
:
'
Close Map
'
closeMap
:
'
Close Map
'
}
}
...
@@ -65,7 +66,7 @@ class MapModal {
...
@@ -65,7 +66,7 @@ class MapModal {
/**
/**
* @param mapModalId The id of the HTML element in which the modal should be opened
* @param mapModalId The id of the HTML element in which the modal should be opened
* @param typeNameMap A mapping from pointOfInterestTypeIds to their localized names
* @param typeNameMap A mapping from pointOfInterestTypeIds to their localized names
- expects names for ids 0,1,2,3,5,6,7
* @param geoJsonData GeoJson containing all features which should be displayed on the map
* @param geoJsonData GeoJson containing all features which should be displayed on the map
* @param language The language in which texts should be displayed, either 'nb' or 'en'
* @param language The language in which texts should be displayed, either 'nb' or 'en'
* @param allowNewPoints Whether or not the user should be allowed to add new points
* @param allowNewPoints Whether or not the user should be allowed to add new points
...
@@ -75,7 +76,11 @@ class MapModal {
...
@@ -75,7 +76,11 @@ class MapModal {
this
.
mapModalElement
=
document
.
getElementById
(
mapModalId
);
this
.
mapModalElement
=
document
.
getElementById
(
mapModalId
);
this
.
mapContainerId
=
mapModalId
+
"
-container
"
;
this
.
mapContainerId
=
mapModalId
+
"
-container
"
;
this
.
mapContainerElement
=
this
.
addMapContainer
(
this
.
mapModalElement
,
this
.
mapContainerId
);
this
.
mapContainerElement
=
this
.
addMapContainer
(
this
.
mapModalElement
,
this
.
mapContainerId
);
this
.
typeNameMap
=
typeNameMap
;
this
.
typeNameMap
=
typeNameMap
;
// Empty or invalid typeNameMap means that type information should not be displayed
this
.
includeTypeInformation
=
Object
.
keys
(
typeNameMap
).
length
===
7
;
this
.
geoJsonData
=
geoJsonData
;
this
.
geoJsonData
=
geoJsonData
;
if
(
language
in
MapModal
.
TRANSLATIONS
)
{
if
(
language
in
MapModal
.
TRANSLATIONS
)
{
this
.
translations
=
MapModal
.
TRANSLATIONS
[
language
];
this
.
translations
=
MapModal
.
TRANSLATIONS
[
language
];
...
@@ -186,13 +191,16 @@ class MapModal {
...
@@ -186,13 +191,16 @@ class MapModal {
this
.
markersByType
[
typeId
].
push
(
layer
);
this
.
markersByType
[
typeId
].
push
(
layer
);
}
}
}).
addTo
(
this
.
map
);
}).
addTo
(
this
.
map
);
this
.
legendControl
=
new
LegendControl
({
typeColorMap
:
this
.
typeColorMap
,
if
(
this
.
includeTypeInformation
)
{
typeNameMap
:
this
.
typeNameMap
,
this
.
legendControl
=
new
LegendControl
({
markersByType
:
this
.
markersByType
,
typeColorMap
:
this
.
typeColorMap
,
mapModalInstance
:
this
typeNameMap
:
this
.
typeNameMap
,
});
markersByType
:
this
.
markersByType
,
this
.
map
.
addControl
(
this
.
legendControl
);
mapModalInstance
:
this
});
this
.
map
.
addControl
(
this
.
legendControl
);
}
// Enable adding new points if allowed
// Enable adding new points if allowed
if
(
this
.
allowNewPoints
)
{
if
(
this
.
allowNewPoints
)
{
...
@@ -300,6 +308,21 @@ class MapModal {
...
@@ -300,6 +308,21 @@ class MapModal {
const
typeInput
=
newPointFormElement
.
querySelector
(
'
#type
'
);
const
typeInput
=
newPointFormElement
.
querySelector
(
'
#type
'
);
const
submitButton
=
newPointFormElement
.
querySelector
(
'
#submit-button
'
);
const
submitButton
=
newPointFormElement
.
querySelector
(
'
#submit-button
'
);
// Add options for the allowed types - or remove the select list altogether
if
(
this
.
includeTypeInformation
)
{
[
"
2
"
,
"
3
"
,
"
5
"
].
forEach
(
value
=>
{
const
option
=
document
.
createElement
(
"
option
"
);
option
.
value
=
value
;
option
.
text
=
this
.
typeNameMap
[
value
];
typeInput
.
appendChild
(
option
);
})
}
else
{
const
formGroup
=
typeInput
.
closest
(
'
.form-group
'
);
if
(
formGroup
){
formGroup
.
remove
()
}
}
const
validateInputs
=
()
=>
{
const
validateInputs
=
()
=>
{
const
isValidLat
=
!
isNaN
(
parseFloat
(
latitudeInput
.
value
))
&&
isFinite
(
latitudeInput
.
value
);
const
isValidLat
=
!
isNaN
(
parseFloat
(
latitudeInput
.
value
))
&&
isFinite
(
latitudeInput
.
value
);
const
isValidLng
=
!
isNaN
(
parseFloat
(
longitudeInput
.
value
))
&&
isFinite
(
longitudeInput
.
value
);
const
isValidLng
=
!
isNaN
(
parseFloat
(
longitudeInput
.
value
))
&&
isFinite
(
longitudeInput
.
value
);
...
@@ -362,7 +385,6 @@ class MapModal {
...
@@ -362,7 +385,6 @@ class MapModal {
}
}
createFeatureForPoint
(
name
,
type
,
longitude
,
latitude
)
{
createFeatureForPoint
(
name
,
type
,
longitude
,
latitude
)
{
console
.
info
(
"
Create feature for [
"
+
longitude
+
"
,
"
+
latitude
+
"
,
"
+
name
+
"
,
"
+
type
+
"
]
"
);
return
{
return
{
"
type
"
:
"
Feature
"
,
"
type
"
:
"
Feature
"
,
"
geometry
"
:
{
"
geometry
"
:
{
...
@@ -430,9 +452,6 @@ class MapModal {
...
@@ -430,9 +452,6 @@ class MapModal {
<div class="form-group">
<div class="form-group">
<label for="poiTypeSelect">
${
this
.
translations
.
type
}
:</label>
<label for="poiTypeSelect">
${
this
.
translations
.
type
}
:</label>
<select class="form-control" id="type" name="type">
<select class="form-control" id="type" name="type">
<option value="2">
${
this
.
typeNameMap
[
2
]}
</option>
<option value="3">
${
this
.
typeNameMap
[
3
]}
</option>
<option value="5">
${
this
.
typeNameMap
[
5
]}
</option>
</select>
</select>
</div>
</div>
<div class="form-group text-right">
<div class="form-group text-right">
...
@@ -506,8 +525,10 @@ const DisplaySelectedFeatureInfoControl = Control.extend({
...
@@ -506,8 +525,10 @@ const DisplaySelectedFeatureInfoControl = Control.extend({
infoMessageDiv
.
innerHTML
=
`
infoMessageDiv
.
innerHTML
=
`
<h4>
${
name
}
</h4>
<h4>
${
name
}
</h4>
<b>
${
this
.
options
.
translations
.
latitude
}
</b>
${
latitude
}
<br>
<b>
${
this
.
options
.
translations
.
latitude
}
</b>
${
latitude
}
<br>
<b>
${
this
.
options
.
translations
.
longitude
}
</b>
${
longitude
}
<br>
<b>
${
this
.
options
.
translations
.
longitude
}
</b>
${
longitude
}
`
;
<b>
${
this
.
options
.
translations
.
type
}
</b>
${
type
}
`
;
if
(
type
)
{
infoMessageDiv
.
innerHTML
+=
`<br><b>
${
this
.
options
.
translations
.
type
}
</b>
${
type
}
`
}
confirmButton
.
innerHTML
=
feature
.
properties
.
pointOfInterestId
confirmButton
.
innerHTML
=
feature
.
properties
.
pointOfInterestId
?
this
.
options
.
translations
.
selectLocation
?
this
.
options
.
translations
.
selectLocation
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment