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
b7ef8f4a
Commit
b7ef8f4a
authored
4 years ago
by
Tor-Einar Skog
Browse files
Options
Downloads
Patches
Plain Diff
Changed background layer to Statkart's
parent
22e47f18
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/webapp/js/modules/barkbeetle/seasonTrapsiteFormMap.js
+48
-32
48 additions, 32 deletions
...ain/webapp/js/modules/barkbeetle/seasonTrapsiteFormMap.js
with
48 additions
and
32 deletions
src/main/webapp/js/modules/barkbeetle/seasonTrapsiteFormMap.js
+
48
−
32
View file @
b7ef8f4a
...
@@ -27,7 +27,7 @@
...
@@ -27,7 +27,7 @@
function
initMap
(
season
,
currentSeasonTrapsiteId
,
currentSeasonTrapsiteCoordinate
){
function
initMap
(
season
,
currentSeasonTrapsiteId
,
currentSeasonTrapsiteCoordinate
){
// Background layer is OpenStreetMap
// Background layer is OpenStreetMap
var
backgroundLayer
=
new
ol
.
layer
.
Tile
({
/*
var backgroundLayer = new ol.layer.Tile({
source: new ol.source.OSM({
source: new ol.source.OSM({
attributions: [
attributions: [
new ol.Attribution({
new ol.Attribution({
...
@@ -35,7 +35,7 @@
...
@@ -35,7 +35,7 @@
})
})
]
]
})
})
});
});
*/
// The trapsite layer
// The trapsite layer
var
trapLayer
=
new
ol
.
layer
.
Vector
({
var
trapLayer
=
new
ol
.
layer
.
Vector
({
...
@@ -45,37 +45,53 @@
...
@@ -45,37 +45,53 @@
format
:
new
ol
.
format
.
KML
()
format
:
new
ol
.
format
.
KML
()
})
})
});
});
var
parser
=
new
ol
.
format
.
WMTSCapabilities
();
fetch
(
'
https://opencache.statkart.no/gatekeeper/gk/gk.open_wmts?Version=1.0.0&service=wmts&request=getcapabilities
'
).
then
(
function
(
response
)
{
return
response
.
text
();
}).
then
(
function
(
text
)
{
var
result
=
parser
.
read
(
text
);
var
options
=
ol
.
source
.
WMTS
.
optionsFromCapabilities
(
result
,
{
layer
:
'
topo4
'
,
matrixSet
:
'
EPSG:3857
'
});
var
topo4
=
new
ol
.
layer
.
Tile
({
opacity
:
1
,
source
:
new
ol
.
source
.
WMTS
(
/** @type {!olx.source.WMTSOptions} */
(
options
))
});
// Creating the map
// Creating the map
map
=
new
ol
.
Map
({
map
=
new
ol
.
Map
({
target
:
'
seasonTrapsiteFormMap
'
,
target
:
'
seasonTrapsiteFormMap
'
,
layers
:
[
backgroundLayer
,
trapLayer
],
layers
:
[
topo4
,
trapLayer
],
//overlays: [popOverlay],
//overlays: [popOverlay],
renderer
:
'
canvas
'
renderer
:
'
canvas
'
});
});
// Setting zoom and center for the map (need to do this after creating map. so that we kan transform our
// Setting zoom and center for the map (need to do this after creating map. so that we kan transform our
// center to correct map projection)
// center to correct map projection)
var
view
=
new
ol
.
View
({
var
view
=
new
ol
.
View
({
center
:
ol
.
proj
.
transform
([
10.0
,
63.0
],
'
EPSG:4326
'
,
map
.
getView
().
getProjection
().
getCode
()),
center
:
ol
.
proj
.
transform
([
10.0
,
63.0
],
'
EPSG:4326
'
,
map
.
getView
().
getProjection
().
getCode
()),
zoom
:
5
zoom
:
5
});
});
map
.
setView
(
view
);
map
.
setView
(
view
);
// Marker overlay
// Marker overlay
trapMarker
=
new
ol
.
Overlay
({
trapMarker
=
new
ol
.
Overlay
({
position
:
currentSeasonTrapsiteId
!==
null
?
ol
.
proj
.
transform
(
currentSeasonTrapsiteCoordinate
,
'
EPSG:4326
'
,
map
.
getView
().
getProjection
().
getCode
())
:
undefined
,
position
:
currentSeasonTrapsiteId
!==
null
?
ol
.
proj
.
transform
(
currentSeasonTrapsiteCoordinate
,
'
EPSG:4326
'
,
map
.
getView
().
getProjection
().
getCode
())
:
undefined
,
positioning
:
'
bottom-center
'
,
positioning
:
'
bottom-center
'
,
element
:
document
.
getElementById
(
'
trapMarker
'
),
element
:
document
.
getElementById
(
'
trapMarker
'
),
stopEvent
:
false
stopEvent
:
false
});
});
map
.
addOverlay
(
trapMarker
);
map
.
addOverlay
(
trapMarker
);
// Listening for single clicks, position observation pin and updating form element
// Listening for single clicks, position observation pin and updating form element
map
.
on
([
'
singleclick
'
],
function
(
evt
)
{
map
.
on
([
'
singleclick
'
],
function
(
evt
)
{
updateLocationPosition
(
evt
.
coordinate
);
updateLocationPosition
(
evt
.
coordinate
);
});
});
});
// END FETCH
}
}
function
updateLocationPosition
(
coordinate
)
function
updateLocationPosition
(
coordinate
)
...
...
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