GWT MapWidget错误 [英] Error in GWT MapWidget

查看:95
本文介绍了GWT MapWidget错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图将MapWidget添加到VerticalPanel中,但添加到
左上角的地图上:



我添加了标记,标记应该以图片为中心
我可以我加载地图时看不到标记。我应该导航到这个
位置来显示地图。



此代码

  private FormPanel form = new FormPanel(); 

私人VerticalPanel main = new VerticalPanel();



public Map(){

ScrollPanel container = new ScrollPanel();

initWidget(container);

container.setStyleName(FuoEgForm);

form.setWidget(main);

main.setSpacing(6);

container.add(main);

$ b $ public MapWidget addMapWidget(){

MapWidget map = new MapWidget();

//map.setSize(\"100%,100%);
map.setStyleName(gwt-map);
map.removeMapType(MapType.getNormalMap());
map.removeMapType(MapType.getSatelliteMap());
map.addMapType(MapType.getPhysicalMap());
map.addMapType(MapType.getHybridMap());
map.setCurrentMapType(MapType.getHybridMap());

//map.setSize(\"100%,100%);
map.setWidth(500px);
map.setHeight(500px);
main.add(map);

}

我该如何解决这个问题?该地图应填充灰色
边界?

解决方案

从gwt-maps-1.1开始,MapWidget实现了RequiresResize接口。当添加到支持此接口的面板(如DockLayoutPanel)时,每当包含窗口小部件的面板调整大小时,窗口小部件都会自动调用map.checkResizeAndCenter()。这项新功能可以将地图大小设置为双向100%,并填充屏幕上的可用空间。要正确使用LayoutPanel子类,请确保您的html页面设置为使用标准模式,方法是在文档中添加第一行。



在gwt-maps 1.0中,它可能有必要在地图最初添加后强制地图调整其布局。你可以使用MapWidget.checkResizeAndCenter()方法来清理它。您可能需要使用DeferredCommand或其他机制来延迟调用此函数,直到调用调整地图大小的DOM布局传递之后。



或者您可以发现意想不到的另一个意外原因,这是我发生的事情



我将地图隐藏了@constructor
,然后在点击按钮时将其设置为可见


解决方案
使地图始终可见:)


I am trying to add MapWidget to VerticalPanel but the map added on the left corner:

And I added marker and the marker should be centered on the image I can't see the marker when I load the map. I should navigate to this location to show map.

The code for this

private FormPanel form = new FormPanel();

private VerticalPanel main = new VerticalPanel();



public Map(){

  ScrollPanel container = new ScrollPanel();

  initWidget(container);

  container.setStyleName("FuoEgForm");

  form.setWidget(main);

  main.setSpacing(6);

  container.add(main);
}

public MapWidget addMapWidget(){

  MapWidget map = new MapWidget();

  //map.setSize("100%", "100%");
  map.setStyleName("gwt-map");
  map.removeMapType(MapType.getNormalMap());
  map.removeMapType(MapType.getSatelliteMap());
  map.addMapType(MapType.getPhysicalMap());
  map.addMapType(MapType.getHybridMap());
  map.setCurrentMapType(MapType.getHybridMap());

  //map.setSize("100%", "100%");
  map.setWidth("500px");
  map.setHeight("500px");
  main.add(map);

}

How can I solve this issue? The map should fill the gray boundary?

解决方案

As of gwt-maps-1.1, the MapWidget implements the RequiresResize interface. When added to a panel that supports this interface (such as DockLayoutPanel), the widget automatically calls map.checkResizeAndCenter() whenever the panel containing the widget is resized. This new feature makes it possible to set your map size to 100% in both directions and fill up the available space on the screen. To use LayoutPanel subclasses properly, make sure your html page is set to use standards mode by adding as the first line in the document.

In gwt-maps 1.0, it may be necessary to force the map to resize its layout after the map is initially added. you can use the MapWidget.checkResizeAndCenter() method to clean this up. You may need to delay calling this function using a DeferredCommand or other mechanism to wait until after the DOM layout pass that resizes the map is called.

or you can find unexpected another unexpected reason that happened with me

i made the map invisible @constructor and then set it visible if clicked on a button

the solution make the map always visible :)

这篇关于GWT MapWidget错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆