"simple" project into a 2d plain [x, y]
Hi, I read through all the viewport etc docs, but I'm still not sure how to properly replicate project/unproject with pure DeckGL as you can do with MapBoxGL like so. Documentation from their side:
Returns a Point representing pixel coordinates, relative to the map's container, that correspond to the specified geographical location.
**Parameters**
lnglat(LngLatLike)The geographical location to project.
**Returns**
Point: The Point corresponding to lnglat , relative to the map's container .
**Example**
var coordinate = [-122.420679, 37.772537];
var point = map.project(coordinate);
And it actually works like a charm :)
I'm aware that the project/unproject functions are available on the viewport object, but the results I'm getting are 'strange' and not what I'm looking for.
deckgl.viewManager._viewports[0].projectFlat([9.997488, 53.549555]);
Reveals big numbers
3648643.1076104506
2234374.5491718682
and nothing related to the 2d space which is 500x650px.
I'm sure I'm just doing it wrong, could you help me figure this one out? I assume I'm just using the wrong projection matrices. But how to I get the right one(s)?
Thanks.
check project() , it projects position into pixel space.
@1chandu thanks, but I tried all three project methods available to no avail.
This is how the deck object look likes:

Theses are the numbers I'm getting for all three methods:
[-454.6350867983807, -3689.3613040772807] [261632.4538694427, 160219.8074522336] [261632.4538694427, 160219.8074522336, 0]
None of these make sense in a 500x625 coordinate system?!
Any other pointer?
We are doing the same (projecting a lng/lat to viewport [width, height] bounds) in ScreenGridLayer, you can look at the following code (run ScreenGridLayer with gpuAggregation prop to false to activate below code)
https://github.com/uber/deck.gl/blob/b842628e12992b399acb35b5cc81caa8b76e8b7c/modules/aggregation-layers/src/utils/gpu-grid-aggregation/gpu-grid-aggregator.js#L564
@cschlueter viewport.project is the method you want to use. In your screenshot, the viewport has width: 1, height: 1 so you are probably logging it before Deck is fully initialized.
If you manage the view state external to Deck, you may also do this:
import {WebMercatorViewport} from '@deck.gl/core';
const viewport = new WebMercatorViewport({width, height, longitude, latitude, zoom, pitch, bearing});
viewport.project(...);