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

[Bug] 9.0.1: Deck.pickObject with unproject3D==true returns a 2d coordinate #8704

Closed
7 tasks
Jonas-Witt opened this issue Mar 25, 2024 · 1 comment
Closed
7 tasks
Assignees
Labels

Comments

@Jonas-Witt
Copy link

Jonas-Witt commented Mar 25, 2024

Description

After upgrading to 9.0.1 (from 8.9.32), Deck.pickObject does not seem to work correctly anymore with unproject3D==true. It returns a 2d [lng,lat] coordinate instead of a 3d [lng, lat, alt] one. Downgrading back to 8.9.32 fixes it.

Flavors

  • Script tag
  • React
  • Python/Jupyter notebook
  • MapboxOverlay
  • GoogleMapsOverlay
  • CartoLayer
  • ArcGIS

Expected Behavior

Get a pick with a 3d coordinate [lng, lat, alt]

Steps to Reproduce

index.html

<!doctype html>
<html>
  <head>
    <meta charset='UTF-8' />
    <title>deck.gl example</title>
    <style>
    #map {
      position: fixed;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
    }
    </style>
    <link href='https://api.tiles.mapbox.com/mapbox-gl-js/v1.13.0/mapbox-gl.css' rel='stylesheet' />
  </head>
  <body>
    <div id="map"></div>
    <script type="module" src='app.js'></script>
  </body>
</html>

package.json

{
  "name": "deckgl-example-pure-js-mapbox",
  "version": "0.0.0",
  "private": true,
  "license": "MIT",
  "scripts": {
    "start": "vite --open",
    "start-local": "vite --config ../../../vite.config.local.mjs",
    "build": "vite build"
  },
  "dependencies": {
    "@deck.gl/core": "9.0.1",
    "@deck.gl/layers": "9.0.1",
    "@deck.gl/mapbox": "9.0.1",
    "mapbox-gl": "3.2.0"
  },
  "devDependencies": {
    "vite": "^4.0.0"
  }
}

app.js

import { MapboxOverlay as DeckOverlay } from "@deck.gl/mapbox";
import { GeoJsonLayer, ArcLayer } from "@deck.gl/layers";
import mapboxgl from "mapbox-gl";

// source: Natural Earth http://www.naturalearthdata.com/ via geojson.xyz
const AIR_PORTS =
  "https://d2ad6b4ur7yvpq.cloudfront.net/naturalearth-3.3.0/ne_10m_airports.geojson";

const map = new mapboxgl.Map({
  container: "map",
  style:
    "https://basemaps.cartocdn.com/gl/positron-nolabels-gl-style/style.json",
  center: [0.45, 51.47],
  zoom: 4,
  bearing: 0,
  pitch: 30,
});

const deckOverlay = new DeckOverlay({
  layers: [
    new GeoJsonLayer({
      id: "airports",
      data: AIR_PORTS,
      // Styles
      filled: true,
      pointRadiusMinPixels: 2,
      pointRadiusScale: 2000,
      getPointRadius: (f) => 11 - f.properties.scalerank,
      getFillColor: [200, 0, 80, 180],
      // Interactive props
      pickable: true,
      autoHighlight: true,
      onClick: (info) =>
        // eslint-disable-next-line
        info.object &&
        alert(
          `${info.object.properties.name} (${info.object.properties.abbrev})`
        ),
    }),
    new ArcLayer({
      id: "arcs",
      data: AIR_PORTS,
      dataTransform: (d) =>
        d.features.filter((f) => f.properties.scalerank < 4),
      // Styles
      getSourcePosition: (f) => [-0.4531566, 51.4709959], // London
      getTargetPosition: (f) => f.geometry.coordinates,
      getSourceColor: [0, 128, 200],
      getTargetColor: [200, 0, 80],
      getWidth: 1,
    }),
  ],
});

map.addControl(deckOverlay);
map.addControl(new mapboxgl.NavigationControl());

map.on("mousemove", (event) => {
  const heightPick = deckOverlay.pickObject({
    x: event.point.x,
    y: event.point.y,
    radius: 1,
    layerIds: undefined,
    unproject3D: true,
  });
  console.log(heightPick?.coordinate);
});

Environment

  • Framework version: deck.gl@9.0.1
  • Browser: Chrome 114.0
  • OS: Ubuntu 20.04

Logs

No response

@Pessimistress
Copy link
Collaborator

Fixed in 9.0.4.

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

No branches or pull requests

2 participants