Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
G
Géocontrib Frontend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Redmine
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Contributor 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
externe Matthieu
Géocontrib Frontend
Commits
46e325a2
Commit
46e325a2
authored
2 years ago
by
Timothee P
Browse files
Options
Downloads
Patches
Plain Diff
WIP: adding route to feature browsing on map
parent
e21aa0c6
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/services/map-service.js
+37
-14
37 additions, 14 deletions
src/services/map-service.js
with
37 additions
and
14 deletions
src/services/map-service.js
+
37
−
14
View file @
46e325a2
...
...
@@ -116,7 +116,21 @@ const mapService = {
},
addRouterToPopup
(
featureTypeSlug
,
featureId
)
{
addRouterToPopup
({
featureTypeSlug
,
featureId
,
index
})
{
function
goToBrowseFeatureDetail
()
{
router
.
push
({
name
:
'
details-signalement-filtre
'
,
params
:
{
slug_type_signal
:
featureTypeSlug
,
},
query
:
{
ordering
:
/* project.feature_browsing_default_sort */
'
-updated_on
'
,
feature_type
:
/* project.feature_browsing_default_filter ? featureTypeSlug : */
''
,
offset
:
index
}
});
}
function
goToFeatureDetail
()
{
router
.
push
({
name
:
'
details-signalement
'
,
...
...
@@ -126,7 +140,7 @@ const mapService = {
},
});
}
function
goToFeatureTypeDetail
()
{
router
.
push
({
name
:
'
details-type-signalement
'
,
...
...
@@ -135,8 +149,8 @@ const mapService = {
},
});
}
document
.
getElementById
(
'
goToFeatureDetail
'
).
onclick
=
index
?
goToBrowseFeatureDetail
:
goToFeatureDetail
;
document
.
getElementById
(
'
goToFeatureTypeDetail
'
).
onclick
=
goToFeatureTypeDetail
;
document
.
getElementById
(
'
goToFeatureDetail
'
).
onclick
=
goToFeatureDetail
;
},
onMapClick
(
event
)
{
...
...
@@ -153,7 +167,11 @@ const mapService = {
const
popupContent
=
this
.
_createContentPopup
(
features
[
0
],
this
.
featureTypes
);
this
.
content
.
innerHTML
=
popupContent
.
html
;
this
.
overlay
.
setPosition
(
event
.
coordinate
);
this
.
addRouterToPopup
(
popupContent
.
feature_type
.
slug
,
popupContent
.
featureId
);
this
.
addRouterToPopup
({
featureTypeSlug
:
popupContent
.
feature_type
.
slug
,
featureId
:
popupContent
.
featureId
,
index
:
popupContent
.
index
,
});
}
}
//const queryableLayerSelected = document.getElementById(`queryable-layers-selector-${this.wmsParams.basemapId}`).getElementsByClassName('selected')[0].textContent;
...
...
@@ -473,9 +491,13 @@ const mapService = {
console
.
log
(
'
addToMap
'
,
addToMap
);
const
drawSource
=
new
VectorSource
();
let
retour
;
// TODO verifier utilité de cette boucle et remplacer par readFeatures plutot
let
index
=
0
;
features
.
forEach
((
feature
)
=>
{
try
{
if
(
feature
.
properties
)
{
feature
.
properties
[
'
index
'
]
=
index
;
index
+=
1
;
}
retour
=
new
GeoJSON
().
readFeature
(
feature
,
{
dataProjection
:
'
EPSG:4326
'
,
featureProjection
:
'
EPSG:3857
'
},
featureTypes
);
drawSource
.
addFeature
(
retour
);
}
catch
(
err
)
{
...
...
@@ -511,13 +533,14 @@ const mapService = {
};
let
feature_type
;
let
status
;
let
date
_maj
;
let
up
date
d_on
;
let
creator
;
let
index
;
// index is used to retrieve feature by query when browsing features
if
(
feature
.
getProperties
)
{
statu
s
=
feature
.
getProperties
()
.
status
;
date_maj
=
feature
.
getProperties
().
updated_
on
;
c
reator
=
feature
.
getProperties
().
creator
;
const
propertie
s
=
feature
.
getProperties
();
({
status
,
updated_on
,
creator
,
index
}
=
properties
);
// using parenthesis to allow destructuring object without declarati
on
c
onsole
.
log
({
index
})
;
if
(
featureTypes
)
{
feature_type
=
feature
.
getProperties
().
feature_type
||
featureTypes
.
find
((
x
)
=>
x
.
slug
.
split
(
'
-
'
)[
0
]
===
''
+
feature
.
getProperties
().
feature_type_id
);
...
...
@@ -525,14 +548,14 @@ const mapService = {
}
else
{
//? TPD: I couldn't find when this code is used, is this still in use ?
status
=
feature
.
status
;
if
(
status
)
status
=
status
.
name
;
date
_maj
=
feature
.
updated_on
;
up
date
d_on
=
feature
.
updated_on
;
creator
=
feature
.
creator
;
if
(
featureTypes
)
{
feature_type
=
featureTypes
.
find
((
x
)
=>
x
.
slug
===
feature
.
feature_type
.
slug
);
}
}
if
(
date
_maj
&&
!
isNaN
(
new
Date
(
date
_maj
)))
{
//* check if it is already formatted
date
_maj
=
formatDate
(
new
Date
(
date
_maj
));
if
(
up
date
d_on
&&
!
isNaN
(
new
Date
(
up
date
d_on
)))
{
//* check if it is already formatted
up
date
d_on
=
formatDate
(
new
Date
(
up
date
d_on
));
}
if
(
status
)
{
if
(
status
.
label
)
{
//* when the label is already in the feature
...
...
@@ -563,7 +586,7 @@ const mapService = {
Type :
${
feature_type
?
'
<a id="goToFeatureTypeDetail" class="pointer">
'
+
feature_type
.
title
+
'
</a>
'
:
'
Type de signalement inconnu
'
}
</div>
<div>
Dernière mise à jour :
${
date
_maj
}
Dernière mise à jour :
${
up
date
d_on
}
</div>
${
author
}
`
;
...
...
@@ -573,7 +596,7 @@ const mapService = {
feature
.
getProperties
?
feature
.
getProperties
().
feature_id
:
feature
.
id
;
return
{
html
,
feature_type
,
featureId
};
return
{
html
,
feature_type
,
featureId
,
index
};
},
zoom
(
zoomlevel
)
{
...
...
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