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

信息弹框可以支持高度值(单位是米或者three单位)吗 #207

Closed
wuzhenzhen1314 opened this issue Sep 3, 2020 · 3 comments

Comments

@wuzhenzhen1314
Copy link

infowindow或uiMarker信息弹框可以支持高度值(单位是米或者three单位)吗?。我想在threelayer拉伸建筑上点击建筑位置地方弹信息框,信息框位置就是点击位置,具有真实高度,类似于https://maptalks.org/maptalks.three/demo/custom-billboard.html案例中文字的高度。目前只能通过css设置信息框dom像素高度,但像素高度缩放后弹框永远是那么高,不真实。https://maptalks.org/maptalks.three/demo/custom-gpupick.html中点击位置弹框,缩放旋转后,信息框就跑了

@deyihu
Copy link
Collaborator

deyihu commented Sep 3, 2020

infowindow是支持 altitude的

https://github.com/maptalks/maptalks.js/blob/acdd8c318af63136ef6872f35a1b607217425ceb/src/ui/UIComponent.js#L386,
柱子的例子虽然有高度(height),但是柱子的altitude为0,注意垂直高度和海拔的区别

1.你可以把 infowindow的_getViewPoint 方法重写了
2.可以基于 UIComponent 自己自定义个Component,其屏幕坐标可以利用threelayer里的camera来计算,我平时就是这样做的

function vector2Pixel(world_vector, size, camera) {
    const vector = world_vector.project(camera);
    const halfWidth = size.width / 2;
    const halfHeight = size.height / 2;
    const result = {
        x: Math.round(vector.x * halfWidth + halfWidth),
        y: Math.round(-vector.y * halfHeight + halfHeight)
    };
    return result;
}

20200903142704

3.基于three 的css3dRender来做

以上三个方法都是利用dom来做的,无法正确的维持场景的3维关系

另外就是像 billboard的例子那样,构造一个纹理图片来做,但是复杂的html内容其整个纹理的构造和渲染又是个很复杂的事

@deyihu
Copy link
Collaborator

deyihu commented Sep 15, 2020

@deyihu
Copy link
Collaborator

deyihu commented Sep 15, 2020

@deyihu deyihu closed this as completed Sep 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
2 participants