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
31817ed3
Commit
31817ed3
authored
5 years ago
by
Joni Laukka
Browse files
Options
Downloads
Patches
Plain Diff
Geolocation options added to get more accurate location
parent
1807a6ba
No related branches found
No related tags found
1 merge request
!3
Get own location
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/components/UserMap.js
+25
-15
25 additions, 15 deletions
src/components/UserMap.js
with
25 additions
and
15 deletions
src/components/UserMap.js
+
25
−
15
View file @
31817ed3
...
@@ -12,27 +12,33 @@ class UserMap extends Component {
...
@@ -12,27 +12,33 @@ class UserMap extends Component {
componentDidMount
(){
componentDidMount
(){
this
.
getCurrentPosition
((
position
)
=>
{
this
.
getCurrentPosition
((
position
)
=>
{
if
(
position
!=
null
){
this
.
setState
({
this
.
setState
({
ownLat
:
position
.
coords
.
latitude
,
ownLat
:
position
.
lat
,
ownLng
:
position
.
coords
.
longitude
,
ownLng
:
position
.
lng
,
});
});
}
});
});
}
}
getCurrentPosition
(
callback
){
getCurrentPosition
(
callback
){
if
(
!
navigator
.
geolocation
){
if
(
!
navigator
.
geolocation
){
console
.
log
(
"
Can't get geolocation :/
"
);
console
.
log
(
"
Can't get geolocation :/
"
);
callback
(
null
);
}
}
else
{
else
{
navigator
.
geolocation
.
getCurrentPosition
((
position
)
=>
{
// Position tracking options
callback
({
const
options
=
{
lat
:
position
.
coords
.
latitude
,
enableHighAccuracy
:
true
,
lng
:
position
.
coords
.
longitude
timeout
:
30000
,
});
maximumAge
:
0
});
}
navigator
.
geolocation
.
getCurrentPosition
((
position
)
=>
{
//success
if
(
position
!=
null
){
callback
(
position
);
}
},
(
error
)
=>
{
console
.
log
(
error
);
},
options
);
}
}
}
}
...
@@ -48,10 +54,14 @@ class UserMap extends Component {
...
@@ -48,10 +54,14 @@ class UserMap extends Component {
Se
on
perjantai
,
my
dudes
<
br
/>
Se
on
perjantai
,
my
dudes
<
br
/>
<
/Popup
>
<
/Popup
>
<
/Marker
>
<
/Marker
>
{
this
.
state
.
ownLat
!==
null
&&
<
Marker
position
=
{[
this
.
state
.
ownLat
,
this
.
state
.
ownLng
]}
><
/Marker>
}
{
this
.
state
.
ownLat
!==
null
&&
<
Marker
position
=
{[
this
.
state
.
ownLat
,
this
.
state
.
ownLng
]}
>
<
Popup
>
User
'
s real position.<br />
</Popup>
</Marker>}
</Map>
</Map>
);
);
}
}
}
}
export
default
UserMap
;
export default UserMap;
\ No newline at end of file
This diff is collapsed.
Click to expand it.
H9031
@H9031
mentioned in issue
#12 (closed)
·
5 years ago
mentioned in issue
#12 (closed)
mentioned in issue #12
Toggle commit list
H9031
@H9031
mentioned in issue
#17 (closed)
·
5 years ago
mentioned in issue
#17 (closed)
mentioned in issue #17
Toggle commit list
H9031
@H9031
mentioned in issue
#19 (closed)
·
5 years ago
mentioned in issue
#19 (closed)
mentioned in issue #19
Toggle commit list
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