Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Turn-by-Turn Voice Navigation in the Browser #279

Open
wants to merge 374 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
374 commits
Select commit Hold shift + click to select a range
3d78f71
try sth different
karussell Oct 19, 2022
2f7a6bb
alert to see what is going on
karussell Oct 19, 2022
02c3315
wtf now it is working without a change
karussell Oct 19, 2022
5d3f76c
do proper navigation.stop
karussell Oct 19, 2022
4f9f2cd
format
karussell Oct 19, 2022
17d346b
minor css fix
karussell Oct 19, 2022
80c85eb
merged master
karussell Oct 19, 2022
84e6471
reroute: against react, but for now it seems to work ;)
karussell Oct 19, 2022
2890ece
try enableHighAccuracy: true
karussell Oct 19, 2022
91a1a3d
format
karussell Oct 19, 2022
d9669f3
fix this
karussell Oct 19, 2022
146ad4a
merged master
karussell Oct 27, 2022
5ca34e5
skip warning if already accepted
karussell Oct 27, 2022
963e732
simplify
karussell Oct 27, 2022
8f94c8b
mini refactoring
karussell Oct 27, 2022
750e4f7
cancel previously spoken words to avoid queuing for rerouting
karussell Oct 27, 2022
f7bfe44
move navigation center to the bottom
karussell Oct 27, 2022
d70c8bb
useEffect is the proper way and should avoid unnecessary updates
karussell Oct 27, 2022
503fe1a
much better state concept that also works for rerouting
karussell Oct 28, 2022
a3a518c
use correct profile for rerouting request
karussell Oct 28, 2022
20d6082
ZoomMapToPoint should allow undefined heading (as this comes like thi…
karussell Oct 28, 2022
d56a158
format
karussell Oct 28, 2022
784d865
include heading
karussell Oct 28, 2022
5e07506
fix fake param
karussell Oct 28, 2022
3db8391
proper TNSettingsState merge
karussell Oct 28, 2022
f789da2
use navi icon on map; keep instruction index and active path synced
karussell Oct 28, 2022
20f6339
minor simplify
karussell Oct 28, 2022
c6659bd
fix test
karussell Oct 28, 2022
accb54e
simplify settings back to master
karussell Oct 28, 2022
0f6cb2a
avoid multiple API requests at the same time
karussell Oct 28, 2022
d171e92
warn if rerouting was skipped
karussell Oct 28, 2022
147034b
no need for extra end_turn_navigation.png
karussell Oct 28, 2022
bc8ffb0
current location -> better displacement
karussell Oct 28, 2022
93f1608
format
karussell Oct 28, 2022
9ac8b1e
skip rerouting if not yet enabled (initial path already wrong -> dela…
karussell Oct 28, 2022
4aad5a9
style
karussell Oct 28, 2022
c42e470
use heading if 0
karussell Oct 28, 2022
9a68dce
fix heading
karussell Oct 28, 2022
1d87ecb
add test for TurnNavigationStore and nextWaypointIndex
karussell Oct 29, 2022
d27aac5
more tests
karussell Oct 30, 2022
2bac2b8
more robust waypoint skipping
karussell Oct 30, 2022
d6ee634
better rerouting and tests with via points
karussell Oct 31, 2022
2ad3c41
use filled navigation icon
karussell Oct 31, 2022
bbb9fb3
merged master
karussell Oct 31, 2022
8c2d459
put a number in the turn instruction marker
karussell Oct 31, 2022
5583749
avoid path usage in TurnNavigation.tsx
karussell Nov 6, 2022
6c8e5d7
reset instruction and path detail object on SetSelectedPath action
karussell Nov 6, 2022
03babfc
merged master
karussell Nov 6, 2022
530861b
tweak panel with accept
karussell Nov 6, 2022
e1c6169
merged master
karussell Nov 6, 2022
c56f9e0
make clicking volume easier
karussell Nov 6, 2022
80fb4fe
critical order change to make context menu working again when navi wa…
karussell Nov 6, 2022
c566f5b
less fluctuation in fake mode
karussell Nov 7, 2022
2fb5d6b
merged master
karussell Nov 7, 2022
1720fae
Merge branch 'master' into navi
karussell Nov 11, 2022
c44b2d1
make end navigation icon larger
karussell Nov 11, 2022
664e4f3
Merge branch 'master' into navi
karussell Nov 11, 2022
c2d2f93
translate start navi button
karussell Nov 12, 2022
5b1ab86
cleanup and switch layer to vector tiles when starting navigation
karussell Nov 12, 2022
57622d3
show intermediate UI if waiting for GPS
karussell Nov 13, 2022
0aab99a
do fullscreen only for small screens
karussell Nov 13, 2022
b0910d1
set default layer to TNStore
karussell Nov 13, 2022
5bebfe2
remove duplicate calcDist method
karussell Nov 13, 2022
fa60efe
more space for route result buttons
karussell Nov 13, 2022
b878a7b
merged master
karussell Nov 21, 2022
1b6a439
fix css (why is important necessary?); allow zoom but remove while na…
karussell Nov 21, 2022
cdef54c
Merge branch 'master' into navi
karussell Nov 21, 2022
35270d3
include custom model in rerouting request
karussell Nov 21, 2022
4c78626
show the moving arrow on map
karussell Dec 4, 2022
29b1564
much simpler and working solution (no dup arrows and view is automati…
karussell Dec 6, 2022
add737a
ugly: the always busy rendering (1sec animation vs. every 1sec a loc …
karussell Dec 9, 2022
ce270ae
try increase
karussell Dec 9, 2022
3503651
use estimated speed from path details instead of imprecise path.dist/…
karussell Dec 11, 2022
c138da1
avoid frequent rerouting if current location is more than 50m away
karussell Dec 11, 2022
44ff73c
Revert "avoid frequent rerouting if current location is more than 50m…
karussell Dec 13, 2022
2673a6a
avoid too frequent rerouting
karussell Dec 15, 2022
d90575f
initialize profile
karussell Dec 20, 2022
75fa966
cleanup SpeechSynthesizer
karussell Dec 20, 2022
72e8526
new nice mouse-controlled GPS injection for testing
karussell Dec 20, 2022
aa44860
avoid that jest has to parse index.d.ts from ol
karussell Dec 21, 2022
a4bbad8
create NoSleep only once
karussell Dec 23, 2022
63bb24d
test nosleep w/o fullscreen
karussell Dec 23, 2022
2d4d102
move NoSleep into TN state
karussell Dec 23, 2022
2fa622b
remove nosleep text
karussell Dec 23, 2022
82da4da
proper arrow animation that requires other features in same layer
karussell Jan 1, 2023
3b72423
Merge branch 'master' into navi
karussell Jan 7, 2023
9f87784
move back to simpler view-animation-synchronization, see https://stac…
karussell Jan 7, 2023
b7988b5
use linear easing to make transition smoother
karussell Jan 7, 2023
a063590
show real speed and ignore mouse out of map
karussell Jan 7, 2023
10479bc
optimize for smaller screen
karussell Jan 7, 2023
4d3f155
workaround for Safari
karussell Jan 7, 2023
4c8c09c
more recent NoSleep.js (include directly)
karussell Jan 8, 2023
2adedac
nosleep: try init after fullscreen
karussell Jan 8, 2023
8f38369
duration of 950ms is in practise too long and rerender can take too l…
karussell Jan 9, 2023
793ef09
package-lock.json: revert to master
karussell Jan 10, 2023
e54906a
merged master
karussell Jan 28, 2023
78bffc0
improve rendering via reducing animation duration
karussell Jan 29, 2023
96767ee
make nosleep working in firefox. also create video element again on-d…
karussell Jan 29, 2023
7276619
nosleep: avoid mute and loop for recent iOS
karussell Jan 29, 2023
7674b16
minor fix
karussell Jan 29, 2023
a5d0a04
converter: revert to 1 fraction digit
karussell Jan 29, 2023
e19cea7
for now do not optimize response speed and always use all via points
karussell Jan 29, 2023
9630c75
i18n
karussell Jan 29, 2023
841247d
don't allow finger gesture rotation on mobile but still allow program…
karussell Feb 5, 2023
61c9947
formatting
karussell Feb 5, 2023
da44c3a
use noun
karussell Feb 5, 2023
a022d6f
comment
karussell Feb 5, 2023
3775c58
include arrow in canvas, use tip from https://stackoverflow.com/a/753…
karussell Feb 11, 2023
b9c20d6
until bugs appear let's revert the previous commit as it uses ~15% mo…
karussell Feb 12, 2023
cd259fb
merged master
karussell Feb 20, 2023
50662c1
Merge branch 'master' into navi
karussell Feb 23, 2023
38816f0
i18n update
karussell Mar 13, 2023
db27a33
merged master
karussell Mar 13, 2023
9d24b10
wording
karussell Mar 13, 2023
0ee0abd
i18n fix
karussell Mar 13, 2023
f705dbf
merged master
karussell Mar 24, 2023
c6318b5
option to avoid using vector tiles for navigation
karussell Mar 24, 2023
26228fb
merge master
karussell Mar 24, 2023
11477b6
minor i18n
karussell Mar 24, 2023
e97e5ef
include full screen as option too
karussell Mar 24, 2023
642a7e9
merged master
karussell Mar 29, 2023
37818e5
highlight arrow with transparent white background
karussell Apr 6, 2023
47e116e
merged master
karussell Apr 6, 2023
6f42702
Revert b9c20d65df834bef4382245e2192c460827eab9f because we want to dr…
karussell Apr 6, 2023
a06ec3f
allow zoom and pan while navigation via disabling synchronized view
karussell Apr 6, 2023
3cfe5aa
for now zooming will not disable synced view as it is not easy to dif…
karussell Apr 6, 2023
52fcae7
bind to this for locationUpdate
karussell Apr 7, 2023
01f39ea
increase zoom
karussell Apr 9, 2023
3c44397
optimize css and make buttons a bit bigger
karussell Apr 10, 2023
487c9ed
sync view if 2nd navigation
karussell Apr 10, 2023
3e1fe9d
currentLocationLayer can somehow get empty (for longer zoom durations…
karussell Apr 11, 2023
2419a04
minor cleanup
karussell Apr 11, 2023
55b5e58
make max speed 'sign' look fine for >= 100
karussell Apr 11, 2023
5c5f927
merged master
karussell Apr 16, 2023
f502868
init customModelStr for TurnNavigationStore too
karussell Apr 17, 2023
ec6aae6
test for custom model navigation
karussell Apr 25, 2023
cb6f329
Merge branch 'master' into navi
karussell Apr 25, 2023
690032b
formatting
karussell Apr 25, 2023
59212fa
make it less likely that rm+add background layer causes empty layers …
karussell Apr 25, 2023
0bed7d9
remove less common .info
karussell Apr 25, 2023
1dda087
fix background layer switching for navigation
karussell Apr 25, 2023
31b3e53
better simulation with fake=<gps_delta> parameter
karussell Apr 25, 2023
a957cc7
formatting
karussell Apr 25, 2023
b313b6d
ignore heavy rotation when nearly standstill e.g. often happens at a …
karussell Apr 25, 2023
c87b0f8
do not say reroute if waypoint is just skipped
karussell Apr 25, 2023
dbcea70
add missing steps in simulation to better know when turn is announced
karussell Apr 25, 2023
1d8620b
tweak turn announcements
karussell Apr 25, 2023
e338c26
earlier instruction text and factor=8 only for selected road classes
karussell Apr 29, 2023
c993d9b
less random rotation at standstill
karussell May 2, 2023
a8c7042
announce earlier for slower speeds
karussell May 17, 2023
46015e8
reduce 'ignore'-speed to 1m/s and ignore without big angle change if …
karussell May 18, 2023
b7cf225
for walking it is still too fast
karussell May 18, 2023
16ba678
heading only for motor vehicles
karussell May 21, 2023
852c077
i18n: updated
karussell May 21, 2023
f09123a
i18n: reroute
karussell May 21, 2023
14be001
hide context menu
karussell May 21, 2023
5badb0f
formatting
karussell May 21, 2023
668a363
fix problem with mobile safari and ending navigation; improve css
karussell May 21, 2023
471b9b7
avoid context menu from being created
karussell May 21, 2023
c1ec6e2
make expression more clear
karussell May 21, 2023
341856e
use Math.floor as we are moving and it is better to use smaller value
karussell May 21, 2023
67171c0
one log
karussell May 22, 2023
dbf0202
bug fix and tests for announcements; store announcementsToDo in state
karussell May 22, 2023
98258e7
move animation: set rotation only when changed
karussell May 22, 2023
4feb52f
merged
karussell May 29, 2023
c5422cf
more compact navigation bar
karussell Jun 2, 2023
4c792db
close context menu before going to navi, separate useEffect
easbar Jun 2, 2023
29934f1
bigger maxSpeed circle necessary and minor increase height of bar
karussell Jun 2, 2023
df39629
css tuning
karussell Jun 4, 2023
b4366b9
merged master
karussell Jun 9, 2023
934f6ee
move turn sign to top left
karussell Jun 11, 2023
0ec6127
minor padding
karussell Jun 11, 2023
753b482
support for miles and mph
karussell Jun 11, 2023
1feeafe
bug fix
karussell Jun 11, 2023
0ff5ff4
formatting
karussell Jun 11, 2023
a473eb0
make two fonts and the arrow a bit larger
karussell Jun 11, 2023
c8ebfcf
more padding
karussell Jun 11, 2023
97742c4
show debug info on click
karussell Jun 19, 2023
c9e3265
i18n update
karussell Jun 19, 2023
f0eb1c1
show 'then' instruction sign
karussell Jun 19, 2023
5b37d70
formatting
karussell Jun 19, 2023
10c3312
current speed: minor css tweak
karussell Jun 22, 2023
387bb1f
larger font for next turn text
karussell Jun 22, 2023
6523238
thenInstr: minor bug fix
karussell Jun 25, 2023
12e88dd
added eruda
karussell Jun 28, 2023
c6bf7d9
added maplibre for faster vector tiles
karussell Jun 28, 2023
80dfe20
smoother location update now possible
karussell Jun 28, 2023
822c886
try speed-dependent zoom to get closer to roads for e.g. walking
karussell Jun 28, 2023
63ad885
formatting
karussell Jun 28, 2023
55aeafc
merged master
karussell Jun 28, 2023
ce7d27f
less zooming
karussell Jun 28, 2023
c23958e
fix rotate when navigation ends
karussell Jun 28, 2023
4ba63a5
zoom in earlier
karussell Jun 30, 2023
d9a79e4
separate favicon plugin to avoid calling it for fdroid
karussell Jul 8, 2023
694d0da
minor fix
karussell Jul 8, 2023
e8aa7ee
a few more comments
karussell Jul 8, 2023
8bbdcb4
use root for navi branch
karussell Jul 12, 2023
d886f24
formatting
karussell Jul 13, 2023
150c372
do early announcement more frequent
karussell Jul 13, 2023
a156f70
description
karussell Jul 13, 2023
967f43b
added copy link
karussell Jul 13, 2023
845ffe6
merged master
karussell Jul 13, 2023
1adebf1
formatting
karussell Jul 13, 2023
bbe6051
update package-lock
karussell Jul 13, 2023
088c474
smaller white halo
karussell Jul 13, 2023
5de7af3
smaller screens possible
karussell Jul 17, 2023
6785cf7
move center a bit up if landscape
karussell Jul 18, 2023
cd31f04
Merge branch 'master' into navi
karussell Jul 18, 2023
e17dce4
Merge branch 'master' into navi
karussell Aug 4, 2023
e319686
use explicit domain if localhost
karussell Aug 4, 2023
510cf90
use showSaveFilePicker for chrome and capacitorJS case
karussell Aug 6, 2023
c405ed4
formatting
karussell Aug 6, 2023
d568ef2
don't use showSaveFilePicker and just own global ghSaveFile
karussell Aug 7, 2023
b1cc913
remove unused map tile services
karussell Aug 7, 2023
3039c9f
getCurrentDetails: reduce complexity and duplication
karussell Aug 12, 2023
10a79dd
pick instruction and additionally consider the heading
karussell Aug 13, 2023
62cc97f
fix incorrect zoom out when navigation stops
karussell Aug 13, 2023
b90f2aa
one more zoom out if faster for speeds above 23m/s
karussell Aug 13, 2023
2d60c3d
navigation stop should properly position the map
karussell Aug 13, 2023
cba1be3
Merge branch 'master' into navi
karussell Aug 16, 2023
aca7bcb
block long routing requests with custom_model for re-routing too
karussell Aug 16, 2023
3f6b897
Merge branch 'master' into navi
karussell Aug 16, 2023
d424fa2
merged master
karussell Sep 23, 2023
8e93318
safari: intrinsic width of svg too large in navigation view
karussell Sep 23, 2023
4a71eaa
merged master
karussell Nov 15, 2023
b27bc01
minor i18n fix
karussell Nov 15, 2023
bbbec85
Merge branch 'master' into navi
karussell Nov 15, 2023
76ae682
minor fix
karussell Nov 15, 2023
67a81b9
formatting
karussell Nov 15, 2023
cac184f
Merge branch 'master' into navi
karussell Dec 3, 2023
ceae37a
Merge branch 'master' into navi
karussell Dec 4, 2023
177c392
merged master
karussell Feb 4, 2024
9d51ee3
i18n: update
karussell Feb 4, 2024
344d0e3
merged master
karussell Mar 24, 2024
3def33e
ignore non-existent path details
karussell Mar 24, 2024
3ad5ba7
show motorway_junction if no street_name
karussell Mar 24, 2024
8b5bfac
Merge branch 'master' into navi
karussell Apr 11, 2024
dc49eb0
merged master
karussell Apr 29, 2024
36a5fa9
merged master
karussell Jun 22, 2024
2c205c0
fix package-lock
karussell Jun 22, 2024
843bc93
minor fix
karussell Jun 22, 2024
b0674fc
add missing 'center to map' handling
karussell Jun 22, 2024
fe63cba
fdroid build failed: try sem ver
karussell Jun 23, 2024
4363c5e
merged master
karussell Jul 6, 2024
5f079b1
add zoom to route action to context menu
karussell Jul 6, 2024
8a2f497
move item and fix padding
karussell Jul 6, 2024
1ff1f33
Merge branch 'master' into navi
karussell Jul 6, 2024
a601adf
merged master
karussell Aug 13, 2024
0174133
merged master
karussell Aug 24, 2024
674a473
formatting
karussell Aug 24, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10,168 changes: 537 additions & 9,631 deletions package-lock.json

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,19 @@
"type": "git",
"url": "git+https://github.com/graphhopper/graphhopper-maps.git"
},
"version": "0.7",
"version": "2.0.2",
"license": "Apache-2.0",
"scripts": {
"format": "prettier --write \"src/**/*.{css,ts,tsx,html}\" \"test/**/*.{js,ts,jsx,tsx}\" \"jest.config.js\" \"webpack.*.js\" \"config.js\"",
"serve": "webpack serve --config webpack.dev.js",
"build": "webpack --config webpack.prod.js",
"fdroid": "webpack --config webpack.fdroid.js",
"build-debug": "webpack --config webpack.dev.js",
"test": "jest"
},
"dependencies": {
"maplibre-gl": "^3.1.0",

"custom-model-editor": "github:graphhopper/custom-model-editor#3a46b6981d170b7eb70d621bbb92caed149e5a97",
"geojson": "^0.5.0",
"heightgraph": "github:easbar/Leaflet.Heightgraph#5f4f0b1fff3646aa071981381f5955c9e6f111f0",
Expand Down
53 changes: 32 additions & 21 deletions src/App.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,32 @@
user-select: none; /* firefox does not ignore -webkit-user-select so make this explicit, see #217 */
}

.appNaviWrapper {
width: 100%;
height: 100%;
padding: 0;
margin: 0;
display: grid;
grid-template-columns: 30rem 1fr;
grid-template-rows: 1fr auto;
justify-content: space-between;
overflow: auto;
-webkit-user-select: none;
user-select: none; /* firefox does not ignore -webkit-user-select so make this explicit, see #217 */
}

@media (max-width: 44rem) {
.appWrapper {
grid-template-columns: 100%;
grid-template-rows: auto 0 1fr auto auto;
}

.appNaviWrapper {
grid-template-columns: 100%;
grid-template-rows: 1fr auto;
}
}

.map {
grid-column: 1 / span 3;
grid-row: 1 / span 1;
Expand Down Expand Up @@ -107,14 +133,6 @@
box-shadow: 10px 10px 10px rgba(0, 0, 0, 0.1);
}

.smallScreenRoutingResult {
grid-row: 4 / span 1;
grid-column: 1 / span 1;
margin: 0;
z-index: 2;
background-color: white;
}

.smallScreenPoweredBy {
grid-row: 5 / span 1;
grid-column: 1 / span 1;
Expand All @@ -123,13 +141,6 @@
z-index: 2;
}

@media (max-width: 44rem) {
.appWrapper {
grid-template-columns: 100%;
grid-template-rows: auto 0 1fr auto auto;
}
}

/* mapilion */
@font-face {
font-family: 'Open Sans';
Expand All @@ -152,16 +163,16 @@
src: url(./fonts/RobotoCondensed-Regular.ttf) format('truetype');
}

.sidebarCloseButton {
.sidebarCloseButton svg {
position: absolute;

color: lightgray !important; /* unsure why !important is necessary here but not in ErrorMessage.module.css for same <Cross/> */
fill: lightgray;

height: 10px;
width: 10px;
height: 12px;
width: 12px;

right: 7px;
top: 6px;
right: 6px;
top: 5px;
}

.sidebarCloseButton:hover {
Expand Down
59 changes: 50 additions & 9 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useEffect, useState } from 'react'
import React, { useEffect, useState } from 'react'
import PathDetails from '@/pathDetails/PathDetails'
import styles from './App.module.css'
import {
Expand All @@ -11,6 +11,7 @@ import {
getQueryStore,
getRouteStore,
getSettingsStore,
getTurnNavigationStore,
} from '@/stores/Stores'
import MapComponent from '@/map/MapComponent'
import MapOptions from '@/map/MapOptions'
Expand All @@ -24,6 +25,7 @@ import { MapOptionsStoreState } from '@/stores/MapOptionsStore'
import { ErrorStoreState } from '@/stores/ErrorStore'
import Search from '@/sidebar/search/Search'
import ErrorMessage from '@/sidebar/ErrorMessage'
import { TurnNavigationStoreState } from './stores/TurnNavigationStore'
import useBackgroundLayer from '@/layers/UseBackgroundLayer'
import useQueryPointsLayer from '@/layers/UseQueryPointsLayer'
import usePathsLayer from '@/layers/UsePathsLayer'
Expand All @@ -36,10 +38,12 @@ import useRoutingGraphLayer from '@/layers/UseRoutingGraphLayer'
import useUrbanDensityLayer from '@/layers/UseUrbanDensityLayer'
import useMapBorderLayer from '@/layers/UseMapBorderLayer'
import RoutingProfiles from '@/sidebar/search/routingProfiles/RoutingProfiles'
import PlainButton from '@/PlainButton'
import TurnNavigation from '@/turnNavigation/TurnNavigation'
import MapPopups from '@/map/MapPopups'
import useCurrentLocationLayer from '@/layers/CurrentLocationLayer'
import Menu from '@/sidebar/menu.svg'
import Cross from '@/sidebar/times-solid.svg'
import PlainButton from '@/PlainButton'
import useAreasLayer from '@/layers/UseAreasLayer'
import useExternalMVTLayer from '@/layers/UseExternalMVTLayer'
import LocationButton from '@/map/LocationButton'
Expand All @@ -54,6 +58,7 @@ export default function App() {
const [query, setQuery] = useState(getQueryStore().state)
const [info, setInfo] = useState(getApiInfoStore().state)
const [route, setRoute] = useState(getRouteStore().state)
const [turnNavigation, setTurnNavigation] = useState(getTurnNavigationStore().state)
const [error, setError] = useState(getErrorStore().state)
const [mapOptions, setMapOptions] = useState(getMapOptionsStore().state)
const [pathDetails, setPathDetails] = useState(getPathDetailsStore().state)
Expand All @@ -69,6 +74,7 @@ export default function App() {
const onRouteChanged = () => setRoute(getRouteStore().state)
const onErrorChanged = () => setError(getErrorStore().state)
const onMapOptionsChanged = () => setMapOptions(getMapOptionsStore().state)
const onTurnNavigationChanged = () => setTurnNavigation(getTurnNavigationStore().state)
const onPathDetailsChanged = () => setPathDetails(getPathDetailsStore().state)
const onMapFeaturesChanged = () => setMapFeatures(getMapFeatureStore().state)
const onPOIsChanged = () => setPOIs(getPOIsStore().state)
Expand All @@ -79,6 +85,7 @@ export default function App() {
getRouteStore().register(onRouteChanged)
getErrorStore().register(onErrorChanged)
getMapOptionsStore().register(onMapOptionsChanged)
getTurnNavigationStore().register(onTurnNavigationChanged)
getPathDetailsStore().register(onPathDetailsChanged)
getMapFeatureStore().register(onMapFeaturesChanged)
getPOIsStore().register(onPOIsChanged)
Expand All @@ -88,6 +95,7 @@ export default function App() {
onRouteChanged()
onErrorChanged()
onMapOptionsChanged()
onTurnNavigationChanged()
onPathDetailsChanged()
onMapFeaturesChanged()
onPOIsChanged()
Expand All @@ -99,6 +107,7 @@ export default function App() {
getRouteStore().deregister(onRouteChanged)
getErrorStore().deregister(onErrorChanged)
getMapOptionsStore().deregister(onMapOptionsChanged)
getTurnNavigationStore().deregister(onTurnNavigationChanged)
getPathDetailsStore().deregister(onPathDetailsChanged)
getMapFeatureStore().deregister(onMapFeaturesChanged)
getPOIsStore().deregister(onPOIsChanged)
Expand All @@ -112,15 +121,16 @@ export default function App() {
useAreasLayer(map, settings.drawAreasEnabled, query.customModelStr, query.customModelEnabled)
useRoutingGraphLayer(map, mapOptions.routingGraphEnabled)
useUrbanDensityLayer(map, mapOptions.urbanDensityEnabled)
usePathsLayer(map, route.routingResult.paths, route.selectedPath, query.queryPoints)
usePathsLayer(map, route, query.queryPoints, turnNavigation)
useQueryPointsLayer(map, query.queryPoints)
usePathDetailsLayer(map, pathDetails)
useCurrentLocationLayer(map, turnNavigation)
usePOIsLayer(map, pois)

const isSmallScreen = useMediaQuery({ query: '(max-width: 44rem)' })
return (
<SettingsContext.Provider value={settings}>
<div className={styles.appWrapper}>
<div className={turnNavigation.showUI ? styles.appNaviWrapper : styles.appWrapper}>
<MapPopups
map={map}
pathDetails={pathDetails}
Expand All @@ -129,13 +139,21 @@ export default function App() {
query={query}
/>
<ContextMenu map={map} route={route} queryPoints={query.queryPoints} />
{isSmallScreen ? (
{turnNavigation.showUI ? (
<>
<TurnNavigation turnNavigation={turnNavigation} />
<div className={styles.map}>
<MapComponent map={map} />
</div>
</>
) : isSmallScreen ? (
<SmallScreenLayout
query={query}
route={route}
map={map}
mapOptions={mapOptions}
error={error}
turnNavigation={turnNavigation}
encodedValues={info.encoded_values}
drawAreas={settings.drawAreasEnabled}
/>
Expand All @@ -146,6 +164,7 @@ export default function App() {
map={map}
mapOptions={mapOptions}
error={error}
turnNavigation={turnNavigation}
encodedValues={info.encoded_values}
drawAreas={settings.drawAreasEnabled}
/>
Expand All @@ -163,11 +182,22 @@ interface LayoutProps {
error: ErrorStoreState
encodedValues: object[]
drawAreas: boolean
turnNavigation: TurnNavigationStoreState
}

function LargeScreenLayout({ query, route, map, error, mapOptions, encodedValues, drawAreas }: LayoutProps) {
function LargeScreenLayout({
query,
route,
map,
error,
mapOptions,
encodedValues,
drawAreas,
turnNavigation,
}: LayoutProps) {
const [showSidebar, setShowSidebar] = useState(true)
const [showCustomModelBox, setShowCustomModelBox] = useState(false)

return (
<>
{showSidebar ? (
Expand All @@ -192,14 +222,15 @@ function LargeScreenLayout({ query, route, map, error, mapOptions, encodedValues
drawAreas={drawAreas}
/>
)}
<Search points={query.queryPoints} map={map} />
<Search points={query.queryPoints} map={map} turnNavigationSettings={turnNavigation.settings} />
<div>{!error.isDismissed && <ErrorMessage error={error} />}</div>
<RoutingResults
info={route.routingResult.info}
paths={route.routingResult.paths}
selectedPath={route.selectedPath}
currentRequest={query.currentRequest}
profile={query.routingProfile.name}
turnNavigation={turnNavigation}
/>
<div>
<PoweredBy />
Expand Down Expand Up @@ -229,7 +260,16 @@ function LargeScreenLayout({ query, route, map, error, mapOptions, encodedValues
)
}

function SmallScreenLayout({ query, route, map, error, mapOptions, encodedValues, drawAreas }: LayoutProps) {
function SmallScreenLayout({
query,
route,
map,
error,
mapOptions,
encodedValues,
drawAreas,
turnNavigation,
}: LayoutProps) {
return (
<>
<div className={styles.smallScreenSidebar}>
Expand All @@ -238,6 +278,7 @@ function SmallScreenLayout({ query, route, map, error, mapOptions, encodedValues
route={route}
error={error}
encodedValues={encodedValues}
turnNavigationSettings={turnNavigation.settings}
drawAreas={drawAreas}
map={map}
/>
Expand All @@ -251,14 +292,14 @@ function SmallScreenLayout({ query, route, map, error, mapOptions, encodedValues
<LocationButton queryPoints={query.queryPoints} />
</div>
</div>

<div className={styles.smallScreenRoutingResult}>
<RoutingResults
info={route.routingResult.info}
paths={route.routingResult.paths}
selectedPath={route.selectedPath}
currentRequest={query.currentRequest}
profile={query.routingProfile.name}
turnNavigation={turnNavigation}
/>
</div>

Expand Down
24 changes: 22 additions & 2 deletions src/Converters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,33 @@ export function milliSecondsToText(ms: number) {
}

let distanceFormat: Intl.NumberFormat = new Intl.NumberFormat('en', { maximumFractionDigits: 1 })
export function setDistanceFormat(_distanceFormat: Intl.NumberFormat) {
distanceFormat = _distanceFormat
let distanceFormat2 = new Intl.NumberFormat('en', { maximumFractionDigits: 2 })

export function initDistanceFormat(lang: string) {
distanceFormat = new Intl.NumberFormat(lang, { maximumFractionDigits: 1 })
distanceFormat2 = new Intl.NumberFormat(lang, { maximumFractionDigits: 2 })
}

export function kmToMPHIfMiles(value: number, showDistanceInMiles: boolean, roundTo10 = false) {
return showDistanceInMiles
? roundTo10
? Math.round(value / 1.60934 / 10.0) * 10
: Math.round(value / 1.60934)
: Math.round(value)
}

export function meterToFt(value: number) {
return value / 0.3048

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@karussell I have a doubt, the good formula is rather : meterToFt => value * 3,28084 ?
same for meterToMiles (value * 1609.34) or I'm wrong ?

}

export function meterToMiles(value: number) {
return value / 1609.34
}

export function metersToText(meters: number, showDistanceInMiles: boolean, forceSmallUnits: boolean = false) {
if (showDistanceInMiles) {
if (meters < 160.934 || forceSmallUnits) return Math.floor(meters / 0.3048) + ' ft'
if (meters < 600) return distanceFormat2.format(meters / 1609.34) + ' mi'
return distanceFormat.format(meters / 1609.34) + ' mi'
} else {
if (meters < 1000 || forceSmallUnits) return Math.floor(meters) + ' m'
Expand Down
24 changes: 24 additions & 0 deletions src/SpeechSynthesizer.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
export interface SpeechSynthesizer {
synthesize(text: string): void
}

export class SpeechSynthesizerImpl implements SpeechSynthesizer {
private readonly locale: string
private readonly speechSynthesisAPIAvailable: boolean

constructor(locale: string) {
this.locale = locale
this.speechSynthesisAPIAvailable = 'speechSynthesis' in window
}

synthesize(text: string) {
if (this.speechSynthesisAPIAvailable) {
let utterance = new SpeechSynthesisUtterance(text)
utterance.lang = this.locale
if (speechSynthesis.pending) speechSynthesis.cancel()
speechSynthesis.speak(utterance)
} else {
console.log('no speechSynthesis API available')
}
}
}
Loading
Loading