Responsive DIVs in CesiumViewer [CesiumJS]

邮差的信 提交于 2019-12-10 19:57:01

问题


I am working on customizing a Cesium map that has an overlay with a variety of information inside, the style of the overlay I'm implementing with bootsrap, unfortunately the divs that I put remain in a specific position and ignore the resizing of the page. Is there a way to make a DIV added to cesium viewer responsive?

What i do now is

    var position = Cesium.Cartesian3.fromDegrees(-76.59777, 39.03883);
    var scratch = new Cesium.Cartesian2();
    
    var canvasPosition = viewer.scene.cartesianToCanvasCoordinates(position, scratch);
    
    viewer.scene.preRender.addEventListener(function () {
        if (Cesium.defined(canvasPosition)) {
            
            htmlOverlayBoxInfo.style.left = '600px';
            htmlOverlayBoxInfo.style.top = '180px';
            
        }
    });
<div id="box-info" style="position: absolute" class="circles push-50 visibility">

            <div class="visibility-hidden" data-toggle="appear" data-class="animated fadeIn">
                <span class="circle circle-0"></span>
            </div>
            <div class="visibility-hidden" data-toggle="appear" data-class="animated fadeIn" data-timeout="100">
                <span class="circle circle-1"></span>
            </div>
            <div class="visibility-hidden" data-toggle="appear" data-class="animated fadeIn" data-timeout="200">
                <span class="circle circle-2"></span>
            </div>
            <div class="visibility-hidden" data-toggle="appear" data-class="animated fadeIn" data-timeout="300">
                <span class="circle circle-3"></span>
            </div>
            <div class="visibility-hidden " data-toggle="appear" data-class="animated fadeIn" data-timeout="400">
                <span class="circle circle-4"></span>
            </div>
            <div class="visibility-hidden" data-toggle="appear" data-class="animated fadeIn" data-timeout="500">
                <span class="circle circle-5"></span>
            </div>
            <div class="visibility-hidden" data-toggle="appear" data-class="animated fadeIn" data-timeout="600">
                <span class="circle circle-6"></span>
            </div>

            <span class="circle circles-main-content visibility-hidden" data-toggle="appear"
                  data-class="animated fadeIn" data-timeout="100">
                <h4>
                    New </h4>

                             </span>
        </div>

I am forced to put [style="position: absolute"] otherwise the div I need to overlay the map is not displayed at all. What am I doing wrong?


回答1:


I will solve the problem using Reactjs to do all the data presentation. Expanding this: https://www.npmjs.com/package/cesium-react



来源:https://stackoverflow.com/questions/53278693/responsive-divs-in-cesiumviewer-cesiumjs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!