-
-
Notifications
You must be signed in to change notification settings - Fork 143
Conversation
src/components/Geolocation.react.js
Outdated
|
||
updatePosition() { | ||
if (!navigator.geolocation) { | ||
alert('Your browser does not support Geolocation'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we reuse this.error
here? Something like
this.error({
code: 'N/A',
message: 'Your browser does not support Geolocation'
})
That way (a) we respect props.show_alert
, and (b) props.position_error
reflects this status.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, yes - that's much better. I made the change and it works great.
src/components/Geolocation.react.js
Outdated
alt: crd.altitude, | ||
alt_accuracy: crd.altitudeAccuracy, | ||
speed: crd.speed, | ||
heading: crd.heading, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there anything in pos.coords
that we don't want in position_obj
? If not, we can just use pos.coords
directly. Unless the goal is to ensure that when there's always an entry for each item by the time this gets to Python, but if we pass an undefined
to JSON.stringify
it'll be deleted anyway, so if we want that we'll have to do something like speed: crd.speed ?? null
(that's the null coalescing operator)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to have everything from pos.coords
available. The only advantage I see of doing it this way is to rename the props. lat
and lon
are much easier to type than latitude
and longitude
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yes, I didn’t notice the name changes, you have it right. Then perhaps just the null
fallback for items that may be missing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok added the null
fallback
…into geolocation � Conflicts: � CHANGELOG.md
Moved to dash [PR #2349] (plotly/dash#2349) |
Geolocation
The Geolocation component uses the Geolocation API. This will cause the user's browser to ask for permission to access location data. If they accept, then the browser will use the best available functionality on the device to access this information (for example, GPS).
Component Properties
lat
latitude in degreeslon
longitude in degreesaccuracy
of the lat/lon in metersWhen available:
alt
altitude in metersalt_accuracy
in metersheading
in degreesspeed
in meters per secTrue
in a callback, the browser will update the position data and resetupdate_now
back to False. This can, for example, be used to update the position with a button click or an interval timer.Quickstart
Demo app
To see a full demo, run
dl_geolocation_demo.py
. Note - it's a Dash Labs app 😺Here is a preview: