Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
ehasa-frontend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
WIMMA Lab 2019
Overflow
ehasa-frontend
Commits
534fc706
Commit
534fc706
authored
5 years ago
by
Taneli Riihimäki
Browse files
Options
Downloads
Patches
Plain Diff
Add a button to change map layers
parent
33faf98b
No related branches found
Branches containing commit
No related tags found
2 merge requests
!11
Combine gamelist and new game form
,
!7
Change map layers
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/App.js
+13
-3
13 additions, 3 deletions
src/App.js
src/components/Header.js
+2
-0
2 additions, 0 deletions
src/components/Header.js
src/components/UserMap.js
+3
-2
3 additions, 2 deletions
src/components/UserMap.js
with
18 additions
and
5 deletions
src/App.js
+
13
−
3
View file @
534fc706
...
@@ -7,20 +7,30 @@ import Header from './components/Header';
...
@@ -7,20 +7,30 @@ import Header from './components/Header';
class
App
extends
Component
{
class
App
extends
Component
{
constructor
()
{
constructor
()
{
super
();
super
();
// set initial state
// set initial state
this
.
state
=
{
this
.
state
=
{
lat
:
62.2416479
,
lat
:
62.2416479
,
lng
:
25.7597186
,
lng
:
25.7597186
,
zoom
:
13
zoom
:
13
,
mapUrl
:
'
https://tiles.kartat.kapsi.fi/taustakartta/{z}/{x}/{y}.jpg
'
};
};
this
.
handleLayerChange
=
this
.
handleLayerChange
.
bind
(
this
);
}
}
// Toggles through the list and changes the mapUrl state
handleLayerChange
=
()
=>
{
const
maps
=
[
'
https://tiles.kartat.kapsi.fi/taustakartta/{z}/{x}/{y}.jpg
'
,
'
https://tiles.kartat.kapsi.fi/peruskartta/{z}/{x}/{y}.jpg
'
,
'
https://tiles.kartat.kapsi.fi/ortokuva/{z}/{x}/{y}.jpg
'
];
this
.
setState
({
mapUrl
:
maps
.
indexOf
(
this
.
state
.
mapUrl
)
<
maps
.
length
-
1
?
maps
[
maps
.
indexOf
(
this
.
state
.
mapUrl
)
+
1
]
:
maps
[
0
]})
};
render
()
{
render
()
{
const
initialPosition
=
[
this
.
state
.
lat
,
this
.
state
.
lng
];
const
initialPosition
=
[
this
.
state
.
lat
,
this
.
state
.
lng
];
return
(
return
(
<
div
>
<
div
>
<
UserMap
position
=
{
initialPosition
}
zoom
=
{
this
.
state
.
zoom
}
/>
,
<
UserMap
position
=
{
initialPosition
}
zoom
=
{
this
.
state
.
zoom
}
mapUrl
=
{
this
.
state
.
mapUrl
}
/>
,
<
Header
/>
<
Header
handleLayerChange
=
{
this
.
handleLayerChange
}
/>
<
/div
>
<
/div
>
);
);
}
}
...
...
This diff is collapsed.
Click to expand it.
src/components/Header.js
+
2
−
0
View file @
534fc706
...
@@ -77,6 +77,7 @@ class Header extends React.Component {
...
@@ -77,6 +77,7 @@ class Header extends React.Component {
<
button
onClick
=
{
this
.
handleLogout
}
>
logout
<
/button
>
<
button
onClick
=
{
this
.
handleLogout
}
>
logout
<
/button
>
)}
)}
{
this
.
state
.
username
&&
<
button
>
{
this
.
state
.
username
}
<
/button>
}
{
this
.
state
.
username
&&
<
button
>
{
this
.
state
.
username
}
<
/button>
}
<
button
onClick
=
{
this
.
props
.
handleLayerChange
}
>
change
layer
<
/button
>
<
/div
>
<
/div
>
{
this
.
state
.
register
&&
(
{
this
.
state
.
register
&&
(
<
RegisterForm
<
RegisterForm
...
@@ -92,6 +93,7 @@ class Header extends React.Component {
...
@@ -92,6 +93,7 @@ class Header extends React.Component {
toggleView
=
{
this
.
toggleView
}
toggleView
=
{
this
.
toggleView
}
/
>
/
>
)}
)}
<
/div
>
<
/div
>
);
);
}
}
...
...
This diff is collapsed.
Click to expand it.
src/components/UserMap.js
+
3
−
2
View file @
534fc706
...
@@ -14,6 +14,7 @@ class UserMap extends Component {
...
@@ -14,6 +14,7 @@ class UserMap extends Component {
this
.
state
=
{
this
.
state
=
{
ownLat
:
null
,
ownLat
:
null
,
ownLng
:
null
,
ownLng
:
null
,
mapUrl
:
'
https://tiles.kartat.kapsi.fi/taustakartta/{z}/{x}/{y}.jpg
'
}
}
this
.
watchPositionId
=
null
;
this
.
watchPositionId
=
null
;
...
@@ -68,10 +69,10 @@ class UserMap extends Component {
...
@@ -68,10 +69,10 @@ class UserMap extends Component {
<
Map
className
=
'
map
'
center
=
{
this
.
props
.
position
}
zoom
=
{
this
.
props
.
zoom
}
>
<
Map
className
=
'
map
'
center
=
{
this
.
props
.
position
}
zoom
=
{
this
.
props
.
zoom
}
>
<
TileLayer
<
TileLayer
attribution
=
'
© <a href="https://www.maanmittauslaitos.fi/">Maanmittauslaitos</a>
'
attribution
=
'
© <a href="https://www.maanmittauslaitos.fi/">Maanmittauslaitos</a>
'
url
=
'
https://tiles.kartat.kapsi.fi/taustakartta/{z}/{x}/{y}.jpg
'
url
=
{
this
.
props
.
mapUrl
}
/
>
/
>
<
ZoomControl
position
=
'
topright
'
/>
<
ZoomControl
position
=
'
topright
'
/>
<
DrawTools
position
=
{
this
.
props
.
position
}
/
>
<
DrawTools
position
=
{
this
.
props
.
position
}
/
>
<
Marker
position
=
{
this
.
props
.
position
}
>
<
Marker
position
=
{
this
.
props
.
position
}
>
<
Popup
>
<
Popup
>
Se
on
perjantai
,
my
dudes
<
br
/>
Se
on
perjantai
,
my
dudes
<
br
/>
...
...
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