|
From: Chitra C. <ach...@gm...> - 2010-05-26 07:53:20
|
Hi all,
Libraries I Am Using
---------------------------------
openlayers_gwt-0.4.jar
smartgwt.jar
Issue
---------
I have a smartGWT Portal with many smartGWT Portlets. These Portlets contain
smartGWT Canvasses. I am trying to add a MapWidget into a Portlet. The
following is my code:
public class MyWidget extends Canvas
{
private MapWidget mapWidget;
private Map map;
private WMS wmsLayer;
private Markers markers;
private Popup popup;
public MyWidget ()
{
// Create map widget and map objects
mapWidget = new MapWidget("350px", "350px");
map = mapWidget.getMap(); //instantiates map
TMSOptions tmsOptions = new TMSOptions();
tmsOptions.setFormat("image/png");
tmsOptions.setDisplayOutsideMaxExtent(false);
tmsOptions.setProjection("EPSG:4392");
TMS tmsLayer = new TMS("OpenStreetMaps", "
http://tile.openstreetmap.org/", tmsOptions);
map.addLayers(new Layer[] {tmsLayer});
this.addChild(mapWidget);
draw();
}
}
This MyWidget canvas is added into the Portlet by calling:
portlet.addItem(new MyWidget());
When run, a map cannot be seen in my portlet. I can see the Portlet's <div>
element. However, there is no map element within the <div>. Does anyone know
why?
Replicating the above behaviour
----------------------------------------------
Adding the MapWidget directly onto the RootPanel still produced the same
behaviour as above - i.e. I can see the Portlet's <div> element but there is
no map element within the <div>. My code is as follows:
public void onModuleLoad()
{
DockPanel mainPanel = new DockPanel();
mainPanel.setHeight("100%");
mainPanel.setWidth("100%");
// let's create map options
MapOptions mapOptions = new MapOptions();
mapOptions.setControls(new JObjectArray(new JSObject[] {}));
mapOptions.setNumZoomLevels(16);
mapOptions.setProjection("EPSG:4326");
MapWidget mapWidget = new MapWidget("350px","350px", mapOptions);
Map map = mapWidget.getMap();
//Defining a WMSLayer and adding it to a Map
WMSParams wmsParams = new WMSParams();
wmsParams.setFormat("image/png");
wmsParams.setLayers("basic");
wmsParams.setStyles("");
wmsParams.setMaxExtent(new Bounds(-74.047185, 40.679648,
-73.907005, 40.882078));
WMS wmsLayer = new WMS(
"Basic WMS",
"http://labs.metacarta.com/wms/vmap0",
wmsParams);
mapWidget.getMap().addLayers(new Layer[] {wmsLayer});
mainPanel.add(new Label("hello"), DockPanel.EAST);
mainPanel.add(mapWidget, DockPanel.CENTER);
RootPanel.get("content").add(mainPanel);
}
Any ideas anyone?
Thank you.
Kind regards,
Chitra
|