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

Show all types for a location on the map #536

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

wbazant
Copy link
Collaborator

@wbazant wbazant commented Oct 22, 2024

Present but not selected types rendered with opacity 0.5.

Closes #535

Copy link
Collaborator

@ezwelty ezwelty left a comment

Choose a reason for hiding this comment

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

@wbazant The change looks great but the site crashes if accessed from any page but the default map page. For example, http://localhost:3000/locations/3383 results in types = [undefined, undefined], and thus the error below.

TypeError: Cannot read properties of undefined (reading 'commonName')

src/components/map/TypeLabels.js:24
  21 | const typeLabels =
  22 |   types && types.length > 0
  23 |     ? types.map((type) => ({
 >24 |         label: type.commonName || type.scientificName,
  25 |         isScientific: !type.commonName && type.scientificName,
  26 |         isSelected: selectedTypes.includes(type.id),
  27 |       }))

Filtering types with the following avoids the error, but leads to labels not appearing immediately. For example, http://localhost:3000/settings/@40.0473606,-105.2596932,19z and click on labels: no labels appear.

if (types) {
  types = types.filter(Boolean)
}

@wbazant wbazant changed the title Show all types for a location Show all types for a location on th emap Oct 25, 2024
@wbazant wbazant changed the title Show all types for a location on th emap Show all types for a location on the map Oct 25, 2024
@ezwelty
Copy link
Collaborator

ezwelty commented Oct 25, 2024

@wbazant Yay! Settings text is back and crashes are gone. But labels are still acting strangely on desktop. A refresh of the labels is not being triggered when it should:

  • If I show labels, then change language, the labels don't change.
  • In fact, the labels only show in the language that the site is set to on refresh. The language selector has no effect until the map is reloaded (e.g. navigating to about page then to map).
  • If the site is loaded from the settings URLs, the labels don't show when Labels is ticked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Map labels for multiple types
2 participants