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

widgets for tilesets example #32

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

juandjara
Copy link
Contributor

No description provided.

@juandjara juandjara requested review from padawannn and srtena January 17, 2025 12:27
@juandjara juandjara marked this pull request as ready for review January 22, 2025 10:58
Copy link
Contributor

@srtena srtena left a comment

Choose a reason for hiding this comment

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

Looks good! A minor comment only

Other than that, here's a TO-DO for me before approving/merging

  • Add a comment explaining getDroppingPercent
  • Improve copies, including readme
  • Update caption
  • Use the correct token (potentially I'll have to move the tileset to demo-tilesets)

import './style.css';
import maplibregl from 'maplibre-gl';
import 'maplibre-gl/dist/maplibre-gl.css';
import {WebMercatorViewport, Deck, Color} from '@deck.gl/core';
Copy link
Contributor

Choose a reason for hiding this comment

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

You aren't really using Color no? @juandjara

Copy link
Contributor Author

@juandjara juandjara Feb 4, 2025

Choose a reason for hiding this comment

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

No. I installed prettier as per @donmccurdy suggestion. Made it explicit by adding a script to the package.json of this example so now we can format this code with yarn run format. It will detect inconsistencies like this and others.

@srtena
Copy link
Contributor

srtena commented Feb 3, 2025

Approved so I'm not blocked later but please don't merge yet 🙏

Comment on lines 203 to 204
droppingWarningSmall.classList.add('hidden');
droppingWarningBig.classList.add('hidden');
Copy link
Member

Choose a reason for hiding this comment

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

Could we instead show/hide these messages with...

el.style.display = 'none';
el.style.display = '';

Just in the interest of showing best practice , ideally they'd be shown/hidden from accessibility tools like screenreaders as well as visually.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I built this way to have the elements initially hidden before the JS loads.
I could use this other behavior and add the initial display: none to the widgets class

widgets-tileset/index.ts Outdated Show resolved Hide resolved
Copy link
Member

Choose a reason for hiding this comment

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

Some inconsistent formatting like semicolons in the file, let's just be sure to run prettier before merging!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, I added a format script to the package.json of this example to not forget to run prettier on this.

dataSource.widgetSource.loadTiles(tiles)
if (!tilesLoaded) {
tilesLoaded = true;
renderWidgets();
Copy link
Member

Choose a reason for hiding this comment

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

Very minor and doesn't necessarily need to be changed, but would it be better to call something debounced like debouncedUpdateSpatialFilter here? I don't expect the onViewportLoad callback to run that often, but it might trigger just before/after a viewstate change, and so we'd end up doing the calculations twice since they don't share a debounce.

Would matter a bit more for tilesets with many features, or for rasters.

I've done something similar in:

CartoDB/carto-api-client#87

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.
This came from a bug where onViewStateChange was being called before onViewportLoad was called for the first time, so the app was trying to do an extractFeatures before having called loadTiles, so I made sure to set a boolean for a loading state there and to call extractFeatures also depending on that boolean in onViewportLoad

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.

3 participants