-
Notifications
You must be signed in to change notification settings - Fork 57
Upgrade maplibre and react-map-gl #1452
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
Changes from all commits
7d35c98
d961b64
d2f2d22
1d4090a
0a4de65
636d740
175b0ea
f4d84e1
3be3901
b42f5ae
12ef610
1e70eef
52a30fe
55b77a4
991f56d
84b55f0
6fe7dd6
5779115
c9da4e9
b8efe28
8ca4dba
576417a
341a7ff
a6e77bc
0796d02
0a0b320
1e4105f
ef5bc72
d5356e3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,8 +3,9 @@ import { connect } from 'react-redux' | |
import { FormattedMessage, useIntl } from 'react-intl' | ||
import { Location } from '@opentripplanner/types' | ||
import { LonLatInput } from '@conveyal/lonlat' | ||
import { MapRef, useMap } from 'react-map-gl' | ||
import { MapRef, useMap, ViewStateChangeEvent } from 'react-map-gl/maplibre' | ||
import { Search } from '@styled-icons/fa-solid/Search' | ||
import { throttle } from '@tanstack/pacer' | ||
import coreUtils from '@opentripplanner/core-utils' | ||
import getGeocoder from '@opentripplanner/geocoder' | ||
import LocationField from '@opentripplanner/location-field' | ||
|
@@ -210,7 +211,8 @@ function NearbyView({ | |
}, [location, setHighlightedLocation]) | ||
|
||
useEffect(() => { | ||
const moveListener = (e: mapboxgl.EventData) => { | ||
const moveListener = (e: ViewStateChangeEvent) => { | ||
// @ts-expect-error TODO: What is this condition supposed to capture? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you explain how the ts error could be solved by answering this question? |
||
if (e.geolocateSource) { | ||
const coords = { | ||
lat: e.viewState.latitude, | ||
|
@@ -221,7 +223,7 @@ function NearbyView({ | |
} | ||
} | ||
|
||
const dragListener = (e: mapboxgl.EventData) => { | ||
const dragListener = (e: ViewStateChangeEvent) => { | ||
const coords = { | ||
lat: e.viewState.latitude, | ||
lon: e.viewState.longitude | ||
|
@@ -279,13 +281,22 @@ function NearbyView({ | |
const onMouseEnter = useCallback( | ||
(location: Location) => { | ||
setHighlightedLocation(location) | ||
map && zoomToPlace(map, location) | ||
map && location && zoomToPlace(map, location) | ||
}, | ||
[setHighlightedLocation, map, zoomToPlace] | ||
) | ||
const onMouseLeave = useCallback(() => { | ||
setHighlightedLocation(null) | ||
}, [setHighlightedLocation]) | ||
|
||
// onMouseLeave is throttled because of a bug on Firefox where | ||
// two mouseleave events are triggered when moving cursor quickly from one card to the next. | ||
const onMouseLeave = useCallback( | ||
throttle( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any concerns with increasing bundle size for this? It looks like a very small package, just curious if you looked at any other solutions |
||
(e) => { | ||
setHighlightedLocation(null) | ||
}, | ||
{ trailing: false, wait: 1000 } | ||
), | ||
[setHighlightedLocation] | ||
) | ||
|
||
// Determine whether the data we have is stale based on whether the coords match the URL | ||
// Sometimes Redux could have data from a previous load of the nearby view | ||
|
Uh oh!
There was an error while loading. Please reload this page.