repackaged

This commit is contained in:
francesco 2020-10-26 11:01:07 +01:00
parent 3f018feb18
commit 3c80de9703
4 changed files with 37 additions and 30 deletions

View File

@ -1,16 +1,16 @@
package org.gcube.portlets.user.geoportaldataviewer.client;
import org.gcube.portlets.user.geoportaldataviewer.client.gis.OsmExample;
import org.gcube.portlets.user.geoportaldataviewer.client.ui.GeonaDataViewMainPanel;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.core.client.Scheduler;
import com.google.gwt.core.client.Scheduler.ScheduledCommand;
import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.event.logical.shared.ResizeEvent;
import com.google.gwt.event.logical.shared.ResizeHandler;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.SimplePanel;
import com.google.gwt.user.client.ui.TabLayoutPanel;
/**
* Entry point classes define <code>onModuleLoad()</code>.
@ -34,6 +34,10 @@ public class GeoportalDataViewer implements EntryPoint {
public final static String APP_DIV = "geoportal-data-viewer";
private boolean initialized = false;
private OsmExample osmExample = null;
private GeonaDataViewMainPanel mainPanel;
/**
* This is the entry point method.
*/
@ -44,7 +48,7 @@ public class GeoportalDataViewer implements EntryPoint {
// htmlPanel.setHeight("500px");
// htmlPanel.getElement().setId("map");
//
GeonaDataViewMainPanel mainPanel = new GeonaDataViewMainPanel();
mainPanel = new GeonaDataViewMainPanel();
RootPanel.get(APP_DIV).add(mainPanel);
@ -52,29 +56,20 @@ public class GeoportalDataViewer implements EntryPoint {
@Override
public void execute() {
new OsmExample(mainPanel.getMapPanel().getElement().getId());
osmExample = new OsmExample(mainPanel.getMapPanel().getElement().getId());
//new OsmExample(htmlPanel.getElement().getId());
}
});
// SimplePanel sp = new SimplePanel() {
//
// @Override
// public void setVisible(boolean visible) {
// if (visible && !initialized) {
// Scheduler.get().scheduleDeferred(() -> example.getExample().show(example.getExample().toString()));
// initialized = true;
// }
// super.setVisible(visible);
//
// if (visible) {
// History.newItem(example.name());
// }
// }
// };
Window.addResizeHandler(new ResizeHandler() {
@Override
public void onResize(ResizeEvent event) {
GWT.log("onWindowResized width: "+event.getWidth()+" height: "+event.getHeight());
mainPanel.setHeight(event.getHeight()-200);
}
});
}
}

View File

@ -1,4 +1,6 @@
package org.gcube.portlets.user.geoportaldataviewer.client;
package org.gcube.portlets.user.geoportaldataviewer.client.gis;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants;
import com.google.gwt.dom.client.Document;
import com.google.gwt.dom.client.LinkElement;

View File

@ -1,6 +1,9 @@
package org.gcube.portlets.user.geoportaldataviewer.client;
package org.gcube.portlets.user.geoportaldataviewer.client.gis;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants;
import ol.Coordinate;
import ol.Extent;
import ol.Map;
import ol.MapOptions;
import ol.OLFactory;
@ -69,16 +72,19 @@ public class OsmExample {
Projection projection = new Projection(projectionOptions);
viewOptions.setProjection(projection);
viewOptions.setMaxZoom(19);
//viewOptions.setExtent(new Extent(-180, -90, 180, 90));
// create a view
view = new View(viewOptions);
Coordinate centerCoordinate = OLFactory.createCoordinate(-0.1275, 51.507222);
//EPSG_4326_TO_ITALY
Coordinate centerCoordinate = OLFactory.createCoordinate(12.45, 42.98);
Coordinate transformedCenterCoordinate = Projection.transform(centerCoordinate, GeoportalDataViewerConstants.EPSG_4326, GeoportalDataViewerConstants.EPSG_3857);
Coordinate coordinate = new Coordinate(16, 48);
view.setCenter(coordinate);
view.setZoom(10);
view.setCenter(transformedCenterCoordinate);
view.setZoom(5);
// create the map
MapOptions mapOptions = OLFactory.createOptions();

View File

@ -27,6 +27,10 @@ public class GeonaDataViewMainPanel extends Composite {
htmlPanel.setHeight("600px");
mapPanel.add(htmlPanel);
}
public void setHeight(int height) {
htmlPanel.setHeight(height +"px");
}
public HTMLPanel getMapPanel() {
return htmlPanel;