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
3ed1ac21
Commit
3ed1ac21
authored
1 year ago
by
Tor-Einar Skog
Browse files
Options
Downloads
Patches
Plain Diff
Auto zoom/pan WMS layer
parent
ae5e6d95
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
spatial/static/spatial/js/gridmap.js
+13
-5
13 additions, 5 deletions
spatial/static/spatial/js/gridmap.js
spatial/templates/spatial/gridmap.html
+1
-1
1 addition, 1 deletion
spatial/templates/spatial/gridmap.html
with
14 additions
and
6 deletions
spatial/static/spatial/js/gridmap.js
+
13
−
5
View file @
3ed1ac21
...
...
@@ -48,11 +48,11 @@ function getCurrentVisibleOLLayer()
// The WMS layer returned from mapserver is found
let
currentWMSLayer
=
WMSLayersDateBucket
[
currentTimestamp
][
currentParameter
];
// We have the ordering in the openlayers Map as a property, use that to return the OpenLayers layer
return
layers
[
currentLayer
[
"
ordering
"
]];
return
layers
[
current
WMS
Layer
[
"
ordering
"
]];
}
async
function
initGridMap
(
inputModelId
,
lonLat
,
zoomLevel
,
mapAttribution
)
{
async
function
initGridMap
(
inputModelId
,
mapAttribution
)
{
modelId
=
inputModelId
;
var
backgroundLayer
=
new
ol
.
layer
.
Tile
({
source
:
new
ol
.
source
.
OSM
({
...
...
@@ -159,9 +159,9 @@ msLoadMap(): Unable to access file. (/disks/data01/mapserver/wms/SEPTREFFUM/SEPT
// Setting zoom and center for the map (need to do this after creating map. so that we can transform our
// center to correct map projection)
var
view
=
new
ol
.
View
({
center
:
ol
.
proj
.
transform
(
lonLat
,
'
EPSG:4326
'
,
map
.
getView
().
getProjection
().
getCode
()),
zoom
:
5
,
maxMapZoom
:
10
,
//
center: ol.proj.transform(lonLat, 'EPSG:4326', map.getView().getProjection().getCode()),
//
zoom: 5,
//
maxMapZoom: 10,
});
map
.
setView
(
view
);
...
...
@@ -172,6 +172,14 @@ 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
;
// Assuming this is always EPSG:4326???
let
extent
=
ol
.
proj
.
transformExtent
(
WMSExtent
,
'
EPSG:4326
'
,
map
.
getView
().
getProjection
());
map
.
getView
().
fit
(
extent
,
map
.
getSize
());
popup
=
new
ol
.
Overlay
({
element
:
document
.
getElementById
(
'
popup
'
)
});
...
...
This diff is collapsed.
Click to expand it.
spatial/templates/spatial/gridmap.html
+
1
−
1
View file @
3ed1ac21
...
...
@@ -18,7 +18,7 @@
var
longitude
=
{{
settings
.
MAP_CENTER_LONGITUDE
|
unlocalize
}};
var
latitude
=
{{
settings
.
MAP_CENTER_LATITUDE
|
unlocalize
}};
var
zoomLevel
=
{{
settings
.
MAP_ZOOMLEVEL
}};
initGridMap
(
"
{{model_id}}
"
,
[
longitude
,
latitude
],
zoomLevel
,
"
{{settings.MAP_ATTRIBUTION|safe}}
"
);
initGridMap
(
"
{{model_id}}
"
,
"
{{settings.MAP_ATTRIBUTION|safe}}
"
);
});
</script>
{% endblock %}
...
...
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