有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java Map UI组件未显示在Cuba平台中

我使用了CUBA Platform版本6.0.8,并试图将地图查看器组件添加到屏幕上,但没有显示。 屏幕描述符如下所示:

<window xmlns="http://schemas.haulmont.com/cuba/window.xsd";
        caption="msg://browseCaption"
        class="com.mycompany.gui.mapsample.MapScreen"
        focusComponent="mapBox"            
        xmlns:chart="http://schemas.haulmont.com/charts/charts.xsd">
    <layout margin="true" spacing="true">
        <vbox id="mapBox">
            <chart:mapViewer id="map" height="100%" width="100%"
                             mapType="satellite"/>
        </vbox>
    </layout>
</window>

我遵循this步骤。这些是地图属性:

cuba.charts.map.freeApiKey = ********************************
cuba.charts.map.clientId =  ********************************   
cuba.charts.map.defaultZoom = 13.0
cuba.charts.map.defaultLatitude = 51.5001
cuba.charts.map.defaultLongitude = -0.1262

这是控制器:

public class MapScreen extends AbstractLookup {

    @Inject
    private MapViewer map;

    @Override
    public void init(Map<String, Object> params) {
        GeoPoint center = map.createGeoPoint(53.490905, -2.249558);
        map.setCenter(center);

问题可能是什么,或者至少应该从哪里开始调试


共 (1) 个答案

  1. # 1 楼答案

    首先,给定的链接指向手册的5.6版本,如果您使用版本6,请使用您可以找到的适当文档here

    关于您面临的问题:这不是地图组件的问题,而是布局问题。未指定Vbox高度,因此向Vbox添加height=“100%”可以解决以下问题:

    <vbox id="mapBox"  height="100%">
        <chart:mapViewer id="map"
                         height="100%"
                         mapType="satellite"
                         width="100%"></chart:mapViewer>
    </vbox>
    

    另外,作为一个有用的提示,您可以在运行时分析布局并找出问题所在。要执行此检查,请右键单击选项卡,然后按分析布局(请参见下图)

    Analyze Layout in runtime

    因此,如果分析选项卡中的布局,您将得到以下消息:

    [ERROR] Container 'mapBox', nested component 'map'
    Nested component has relative height 100.0% inside container with undefined height
    

    这清楚地解释了问题所在