我使用 CUBA Platform版本 6.0.8 并尝试将 map 查看器组件添加到屏幕,但未显示。 屏幕描述符如下:
<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步。这些是 map 属性:
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
这是 Controller :
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);
可能是什么问题,或者至少我应该从哪里开始调试它?
最佳答案
首先,给定的链接指向 5.6 版的手册,如果您使用的是版本 6,请使用适当的文档,您可以找到 here
关于您遇到的问题:不是 map 组件的问题,而是布局的问题。未指定 Vbox 高度,因此在 vbox 中添加 height="100%"应该可以解决问题:
<vbox id="mapBox" height="100%">
<chart:mapViewer id="map"
height="100%"
mapType="satellite"
width="100%"></chart:mapViewer>
</vbox>
此外,作为一个有用的提示,您始终可以在运行时分析布局并找出问题所在。要执行此检查,请右键单击选项卡并按 Analyze Layout(见下图)。
因此,如果您分析选项卡中的布局,您将收到以下消息:
[ERROR] Container 'mapBox', nested component 'map'
Nested component has relative height 100.0% inside container with undefined height
这清楚地说明了问题出在哪里。
关于java - 古巴平台不显示 map UI 组件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36235917/