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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
GéoContrib
Géocontrib Frontend
Commits
a8025213
Commit
a8025213
authored
Sep 7, 2023
by
Timothee P
Browse files
Options
Downloads
Patches
Plain Diff
add token to mvt fetch & use only mvt for project details online features
parent
8175813c
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!644
REDMINE_ISSUE-18184 | Régression (?) - temps de chargement carte accueil très lent
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/services/map-service.js
+29
-1
29 additions, 1 deletion
src/services/map-service.js
src/views/Project/ProjectDetail.vue
+12
-22
12 additions, 22 deletions
src/views/Project/ProjectDetail.vue
with
41 additions
and
23 deletions
src/services/map-service.js
+
29
−
1
View file @
a8025213
...
...
@@ -21,6 +21,7 @@ import Geolocation from 'ol/Geolocation.js';
import
Feature
from
'
ol/Feature.js
'
;
import
Point
from
'
ol/geom/Point.js
'
;
import
axios
from
'
@/axios-client.js
'
;
import
router
from
'
@/router
'
;
import
store
from
'
@/store
'
;
...
...
@@ -433,9 +434,36 @@ const mapService = {
const
projectId
=
project_slug
.
split
(
'
-
'
)[
0
];
const
format_cfg
=
{
/*featureClass: Feature*/
};
const
mvt
=
new
MVT
(
format_cfg
);
function
customLoader
(
tile
,
src
)
{
tile
.
setLoader
(
function
(
extent
,
resolution
,
projection
)
{
const
token
=
()
=>
{
const
re
=
new
RegExp
(
'
csrftoken=([^;]+)
'
);
const
value
=
re
.
exec
(
document
.
cookie
);
return
(
value
!=
null
)
?
unescape
(
value
[
1
])
:
null
;
};
fetch
(
src
,
{
credentials
:
'
include
'
,
headers
:
{
'
X-CSRFToken
'
:
token
()
},
}).
then
(
function
(
response
)
{
response
.
arrayBuffer
().
then
(
function
(
data
)
{
const
format
=
tile
.
getFormat
();
// ol/format/MVT configured as source format
const
features
=
format
.
readFeatures
(
data
,
{
extent
:
extent
,
featureProjection
:
projection
});
tile
.
setFeatures
(
features
);
});
});
});
}
const
options
=
{
urls
:
[],
matrixSet
:
'
EPSG:3857
'
matrixSet
:
'
EPSG:3857
'
,
tileLoadFunction
:
customLoader
,
};
options
.
format
=
mvt
;
const
layerSource
=
new
VectorTileSource
(
options
);
...
...
...
...
This diff is collapsed.
Click to expand it.
src/views/Project/ProjectDetail.vue
+
12
−
22
View file @
a8025213
...
...
@@ -420,29 +420,19 @@ export default {
this
.
arraysOffline
.
forEach
((
x
)
=>
(
x
.
geojson
.
properties
.
color
=
'
red
'
));
const
featuresOffline
=
this
.
arraysOffline
.
map
((
x
)
=>
x
.
geojson
);
this
.
GET_PROJECT_FEATURES
({
project_slug
:
this
.
slug
,
ordering
:
'
-created_on
'
,
limit
:
null
,
geojson
:
true
,
})
.
then
(()
=>
{
this
.
featuresLoading
=
false
;
if
(
featuresOffline
&&
featuresOffline
.
length
>
0
)
{
mapService
.
addFeatures
({
addToMap
:
true
,
project_slug
:
this
.
slug
,
features
:
[...
this
.
features
,
...
featuresOffline
]
,
features
:
featuresOffline
,
featureTypes
:
this
.
feature_types
,
queryParams
:
{
ordering
:
this
.
project
.
feature_browsing_default_sort
,
filter
:
this
.
project
.
feature_browsing_default_filter
,
},
});
})
.
catch
((
err
)
=>
{
console
.
error
(
err
);
}
this
.
featuresLoading
=
false
;
});
featureAPI
.
getFeaturesBbox
(
this
.
slug
).
then
((
bbox
)
=>
{
if
(
bbox
)
{
...
...
...
...
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