visgl / visgl/deck.gl

[Bug] Color Artifacts When Zooming on Features in MVTLayer

Open
#8,377 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
TypeScript
Stars
14.6k
Forks
2.3k
Avg merge
2d 9h
Merged PRs (30d)
42

Description

Description

When zooming in on some features in a MVT Layer, color aberrations and artifacts sometime appear on features.

Notice fill blue color:
image

How it should look:
image

This is the code we are using to render the MVTLayer:

    const slicksLayer = new MVTLayer({
      id: BASE_LAYER_IDS.SLICK,
      maxRequests: -1,
      data: slickTilesQuery,
      pickable: true,
      updateTriggers: {
        getLineWidth: [zoom],
        getFillColor: [
          selectedSlickId,
          showSlickOutline,
          showOtherSlicks,
          hoveredSlickId,
          selectedSlickOpacity
        ],
        getLineColor: [
          selectedSlickId,
          showSlickOutline,
          showOtherSlicks,
          hoveredSlickId,
          selectedSlickOpacity
        ]
      },
      getLineWidth: () => {
        if (zoom < 3) {
          return 7;
        } else if (zoom < 5) {
          return 5;
        } else if (zoom < 10) {
          return 2;
        } else {
          return 1.5;
        }
      },
      lineWidthMinPixels: 1,
      lineWidthUnits: 'pixels',
      lineWidthMaxPixels: 20,
      tileSize: 256,
      minZoom: 0,
      maxZoom: 23,
      onClick: handleSlickClick,
      onHover: ({ object }) => {
        if (!object) {
          handleHover(null);
        } else {
          handleHover(object.properties.id);
        }
      },
      getFillColor: ({ properties }: SlickFeature) => {
        if (
          !showOtherSlicks &&
          properties.id !== selectedSlickId &&
          selectedSlickId
        ) {
          return [255, 255, 255, 0];
        }
        if (hoveredSlickId === properties.id) {
          return INTERACTIVE_LAYER_COLORS.SLICK.FILL_SELECTED;
        }
        if (selectedSlickId) {
          return selectedSlickId === properties.id
            ? [
                ...INTERACTIVE_LAYER_COLORS.SLICK.FILL_SELECTED,
                selectedSlickOpacity * 255
              ]
            : INTERACTIVE_LAYER_COLORS.SLICK.FILL_NOT_SELECTED;
        }
        return INTERACTIVE_LAYER_COLORS.SLICK.FILL;
      },
      getLineColor: ({ properties }: SlickFeature) => {
        if (!showOtherSlicks && properties.id !== selectedSlickId) {
          return [255, 255, 255, 0];
        }
        if (hoveredSlickId === properties.id) {
          if (showSlickOutline) {
            return INTERACTIVE_LAYER_COLORS.SLICK.LINE_SELECTED;
          } else {
            return [255, 255, 255, 0];
          }
        }
        if (selectedSlickId) {
          if (selectedSlickId === properties.id) {
            if (showSlickOutline) {
              const [r, g, b] = INTERACTIVE_LAYER_COLORS.SLICK.LINE_SELECTED;
              return [r, g, b, selectedSlickOpacity * 255];
            } else {
              return [0, 0, 0, 0];
            }
          } else {
            return INTERACTIVE_LAYER_COLORS.SLICK.LINE_NOT_SELECTED;
          }
        }
        return INTERACTIVE_LAYER_COLORS.SLICK.LINE;
      }
    });
Flavors
  • Script tag
  • React
  • Python/Jupyter notebook
  • MapboxOverlay
  • GoogleMapsOverlay
  • CartoLayer
  • ArcGIS
Expected Behavior

The MVT features should render without any aberrations, artifacts or anomalies.

Steps to Reproduce
  1. Visit: https://cerulean.skytruth.org/?zoom=1.5&lat=51.13404944890749&lng=-101.46738938572297&slickId=978163
  2. Click on "Zoom To Slick" icon in top right of side panel.
  3. Notice the blue coloration in the fill after the zooming completes - it should be transparent.
Environment
  • Framework version: deck.gl@8.9.19
  • Browser: Firefox/Chrome
  • OS: macOS 14.2.1
Logs

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the MVTLayer rendering path and its MapboxOverlay integration, using the linked reproduction to observe the artifact while zooming. Compare the result with the expected transparent fill; done means the reproduced features render without color aberrations or other artifacts.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
data-visualization, frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.