Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
V
VIPSWeb
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
VIPSWeb
Commits
124c6fe4
Commit
124c6fe4
authored
1 year ago
by
Tor-Einar Skog
Browse files
Options
Downloads
Patches
Plain Diff
Remember zoom and pan between browser sessions
parent
0d4c4436
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
spatial/static/spatial/js/gridmap.js
+36
-7
36 additions, 7 deletions
spatial/static/spatial/js/gridmap.js
with
36 additions
and
7 deletions
spatial/static/spatial/js/gridmap.js
+
36
−
7
View file @
124c6fe4
...
...
@@ -193,13 +193,30 @@ msLoadMap(): Unable to access file. (/disks/data01/mapserver/wms/SEPTREFFUM/SEPT
setCurrentDate
(
todayLayerIndex
);
switchLayer
(
todayLayerIndex
);
// Zoom and center the map to fit to the extent of the WMS layer.
// If the current WMS layer has a lot of no-data / invisible values surrounding the
// visible values, the zoom might appear to be a bit too far out
let
currentWMSLayer
=
WMSLayersDateBucket
[
currentTimestamp
][
currentParameter
]
let
WMSExtent
=
currentWMSLayer
.
EX_GeographicBoundingBox
;
let
extent
=
ol
.
proj
.
transformExtent
(
WMSExtent
,
getCurrentVisibleOLLayer
().
getSource
().
getProjection
().
getCode
(),
map
.
getView
().
getProjection
());
map
.
getView
().
fit
(
extent
,
map
.
getSize
());
var
storedMapSettings
=
getLocalSettings
([
"
gridmap.longitude
"
,
"
gridmap.latitude
"
,
"
gridmap.zoomLevel
"
],
true
);
if
(
storedMapSettings
!=
null
)
{
longitude
=
parseFloat
(
storedMapSettings
[
"
gridmap.longitude
"
]);
latitude
=
parseFloat
(
storedMapSettings
[
"
gridmap.latitude
"
]);
let
lonLat
=
[
longitude
,
latitude
];
zoomLevel
=
parseInt
(
storedMapSettings
[
"
gridmap.zoomLevel
"
]);
map
.
getView
().
setCenter
(
ol
.
proj
.
transform
(
lonLat
,
'
EPSG:4326
'
,
map
.
getView
().
getProjection
().
getCode
()));
map
.
getView
().
setZoom
(
zoomLevel
);
}
else
{
// Zoom and center the map to fit to the extent of the WMS layer.
// If the current WMS layer has a lot of no-data / invisible values surrounding the
// visible values, the zoom might appear to be a bit too far out
let
currentWMSLayer
=
WMSLayersDateBucket
[
currentTimestamp
][
currentParameter
]
let
WMSExtent
=
currentWMSLayer
.
EX_GeographicBoundingBox
;
let
extent
=
ol
.
proj
.
transformExtent
(
WMSExtent
,
getCurrentVisibleOLLayer
().
getSource
().
getProjection
().
getCode
(),
map
.
getView
().
getProjection
());
map
.
getView
().
fit
(
extent
,
map
.
getSize
());
}
popup
=
new
ol
.
Overlay
({
element
:
document
.
getElementById
(
'
popup
'
)
...
...
@@ -208,6 +225,17 @@ msLoadMap(): Unable to access file. (/disks/data01/mapserver/wms/SEPTREFFUM/SEPT
map
.
on
(
'
singleclick
'
,
displayQueryResult
);
map
.
on
(
'
moveend
'
,
function
(
evt
)
{
// Store map settings
var
centerCoordinate
=
ol
.
proj
.
transform
(
map
.
getView
().
getCenter
(),
map
.
getView
().
getProjection
().
getCode
(),
'
EPSG:4326
'
);
var
settings
=
{
"
gridmap.longitude
"
:
centerCoordinate
[
0
],
"
gridmap.latitude
"
:
centerCoordinate
[
1
],
"
gridmap.zoomLevel
"
:
map
.
getView
().
getZoom
()
};
storeLocalSettings
(
settings
);
});
// Add the parameter selector
let
radioHTML
=
""
;
for
(
let
i
=
0
;
i
<
parameters
.
length
;
i
++
)
...
...
@@ -250,6 +278,7 @@ async function displayQueryResult(evt)
let
response
=
await
fetch
(
url
);
let
responseXML
=
await
response
.
text
();
console
.
info
(
responseXML
);
// User clicked outside of layer extent
if
(
responseXML
.
trim
().
length
==
0
)
{
...
...
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