streetscape.gl
streetscape.gl copied to clipboard
Problem with object popup
Hi,
I'm trying to display a popup when an object is selected. The LogViewer looks exactly like in https://github.com/uber/streetscape.gl/blob/master/examples/website-demo/src/map-view.js. First try was with a simple renderObjectLabel, like:
const renderObjectLabel = (props) => {
return props.isSelected && <div>{props.id}</div>;
};
However, nothing happens when the object is clicked. A breakpoint in the function also doesn't get hit. Is there any setting missing or requirement needed to make objects selectable and display the popup?
Used versions are:
- streetscape.gl 1.0.1
- xviz 1.0.1
I also got the same issue. Having the center field of object could solve the issue.
The root cause is in xviz object and parser.
In parse-xviz-stream.js, the objects's vertices are parsed from features and stored into the typed array:
https://github.com/uber/xviz/blob/master/modules/parser/src/parsers/parse-xviz-stream.js#L481
However in xviz-object.js the vertices are checked by if it's normal array, and are identified as invalid and not further populated to the frame.
https://github.com/uber/xviz/blob/master/modules/parser/src/objects/xviz-object.js#L156-L160
So I think it could be helpful to mention that center field of object is needed to display labels in the document, before the fix get done.
Had the same thing.
In xviz-object.js, based on @JscLee's observation i had to add:
var p = feature.center || [].slice.call(feature.vertices);
instead of
var p = feature.center || feature.vertices;
so that the float64array was converted to simple array and the following test would be done correctly.