ref 11708: Setting initial map location and zoom level for the spatial data inputs in SAI
https://support.d4science.org/issues/11708 Added location and zoom git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/widgets/openlayer-basic-widgets@178768 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
52bd941b98
commit
8810846308
|
@ -1,12 +1,12 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<classpath>
|
<classpath>
|
||||||
<classpathentry kind="src" output="target/openlayer-basic-widgets-1.2.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
|
<classpathentry kind="src" output="target/openlayer-basic-widgets-1.3.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="optional" value="true"/>
|
<attribute name="optional" value="true"/>
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry excluding="**" kind="src" output="target/openlayer-basic-widgets-1.2.0-SNAPSHOT/WEB-INF/classes" path="src/main/resources">
|
<classpathentry excluding="**" kind="src" output="target/openlayer-basic-widgets-1.3.0-SNAPSHOT/WEB-INF/classes" path="src/main/resources">
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
|
@ -22,7 +22,7 @@
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
|
@ -33,5 +33,5 @@
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||||
<classpathentry kind="output" path="target/openlayer-basic-widgets-1.2.0-SNAPSHOT/WEB-INF/classes"/>
|
<classpathentry kind="output" path="target/openlayer-basic-widgets-1.3.0-SNAPSHOT/WEB-INF/classes"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
|
|
|
@ -7,7 +7,7 @@ org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nul
|
||||||
org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled
|
org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled
|
||||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||||
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
|
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
|
||||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
|
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||||
org.eclipse.jdt.core.compiler.compliance=1.7
|
org.eclipse.jdt.core.compiler.compliance=1.7
|
||||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||||
|
|
|
@ -1,4 +1,9 @@
|
||||||
<ReleaseNotes>
|
<ReleaseNotes>
|
||||||
|
<Changeset component="org.gcube.portlets.widgets.openlayer-basic-widgets.1-3-0"
|
||||||
|
date="2019-04-01">
|
||||||
|
<Change>Added location and zoom support [ticket #11708]</Change>
|
||||||
|
<Change>Added coordinates EPSG:4326 and EPSG:3857 support [ticket #11710]</Change>
|
||||||
|
</Changeset>
|
||||||
<Changeset component="org.gcube.portlets.widgets.openlayer-basic-widgets.1-2-0"
|
<Changeset component="org.gcube.portlets.widgets.openlayer-basic-widgets.1-2-0"
|
||||||
date="2017-06-12">
|
date="2017-06-12">
|
||||||
<Change>Support Java 8 compatibility [ticket #8471]</Change>
|
<Change>Support Java 8 compatibility [ticket #8471]</Change>
|
||||||
|
|
13
pom.xml
13
pom.xml
|
@ -12,7 +12,7 @@
|
||||||
|
|
||||||
<groupId>org.gcube.portlets.widgets</groupId>
|
<groupId>org.gcube.portlets.widgets</groupId>
|
||||||
<artifactId>openlayer-basic-widgets</artifactId>
|
<artifactId>openlayer-basic-widgets</artifactId>
|
||||||
<version>1.2.0-SNAPSHOT</version>
|
<version>1.3.0-SNAPSHOT</version>
|
||||||
|
|
||||||
<name>openlayer-basic-widgets</name>
|
<name>openlayer-basic-widgets</name>
|
||||||
<description>openlayer-basic-widgets</description>
|
<description>openlayer-basic-widgets</description>
|
||||||
|
@ -38,11 +38,12 @@
|
||||||
<webappDirectory>${project.build.directory}/${project.build.finalName}</webappDirectory>
|
<webappDirectory>${project.build.directory}/${project.build.finalName}</webappDirectory>
|
||||||
<distroDirectory>distro</distroDirectory>
|
<distroDirectory>distro</distroDirectory>
|
||||||
<configDirectory>config</configDirectory>
|
<configDirectory>config</configDirectory>
|
||||||
|
|
||||||
|
<!-- Java -->
|
||||||
|
<maven.compiler.source>1.7</maven.compiler.source>
|
||||||
|
<maven.compiler.target>1.8</maven.compiler.target>
|
||||||
|
|
||||||
|
|
||||||
<!-- Java Version -->
|
|
||||||
<javaVersion>1.7</javaVersion>
|
|
||||||
|
|
||||||
<!-- GWT configuration -->
|
<!-- GWT configuration -->
|
||||||
<gwtVersion>2.7.0</gwtVersion>
|
<gwtVersion>2.7.0</gwtVersion>
|
||||||
<gwtLogVersion>3.3.2</gwtLogVersion>
|
<gwtLogVersion>3.3.2</gwtLogVersion>
|
||||||
|
@ -198,8 +199,8 @@
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>2.3.2</version>
|
<version>2.3.2</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>${javaVersion}</source>
|
<source>${maven.compiler.source}</source>
|
||||||
<target>${javaVersion}</target>
|
<target>${maven.compiler.target}</target>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,8 @@ import org.gcube.portlets.widgets.openlayerbasicwidgets.client.event.SelectAreaD
|
||||||
import org.gcube.portlets.widgets.openlayerbasicwidgets.client.event.SelectAreaDialogEventType;
|
import org.gcube.portlets.widgets.openlayerbasicwidgets.client.event.SelectAreaDialogEventType;
|
||||||
import org.gcube.portlets.widgets.openlayerbasicwidgets.client.resource.OLBasicResources;
|
import org.gcube.portlets.widgets.openlayerbasicwidgets.client.resource.OLBasicResources;
|
||||||
import org.gcube.portlets.widgets.openlayerbasicwidgets.client.util.GWTMessages;
|
import org.gcube.portlets.widgets.openlayerbasicwidgets.client.util.GWTMessages;
|
||||||
|
import org.gcube.portlets.widgets.openlayerbasicwidgets.shared.data.Coordinates;
|
||||||
|
import org.gcube.portlets.widgets.openlayerbasicwidgets.shared.data.ProjectionType;
|
||||||
|
|
||||||
import com.google.gwt.core.client.GWT;
|
import com.google.gwt.core.client.GWT;
|
||||||
import com.google.gwt.dom.client.Element;
|
import com.google.gwt.dom.client.Element;
|
||||||
|
@ -37,8 +39,7 @@ import com.google.gwt.user.client.ui.VerticalPanel;
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class AreaSelectionDialog extends DialogBox implements
|
public class AreaSelectionDialog extends DialogBox implements SelectAreaDialogEvent.HasSelectAreaDialogEventHandler {
|
||||||
SelectAreaDialogEvent.HasSelectAreaDialogEventHandler {
|
|
||||||
private static final String COMBO_GEOMETY_TYPE_WIDTH = "406px";
|
private static final String COMBO_GEOMETY_TYPE_WIDTH = "406px";
|
||||||
private static final boolean RESIZABLE = false;
|
private static final boolean RESIZABLE = false;
|
||||||
private static final boolean COLLAPSIBLE = true;
|
private static final boolean COLLAPSIBLE = true;
|
||||||
|
@ -52,7 +53,8 @@ public class AreaSelectionDialog extends DialogBox implements
|
||||||
private ListBox comboGeometryType;
|
private ListBox comboGeometryType;
|
||||||
private TextArea wktGeometry;
|
private TextArea wktGeometry;
|
||||||
private String wktData;
|
private String wktData;
|
||||||
private GeometryType initialGeometry;
|
private GeometryType geometryType;
|
||||||
|
private Coordinates coordinates;
|
||||||
|
|
||||||
public void setWktGeometry(String wktData) {
|
public void setWktGeometry(String wktData) {
|
||||||
// wktData = wktData;
|
// wktData = wktData;
|
||||||
|
@ -64,7 +66,8 @@ public class AreaSelectionDialog extends DialogBox implements
|
||||||
public AreaSelectionDialog() {
|
public AreaSelectionDialog() {
|
||||||
try {
|
try {
|
||||||
ShowAllGeometryGeometry = true;
|
ShowAllGeometryGeometry = true;
|
||||||
initialGeometry = GeometryType.Polygon;
|
this.geometryType = GeometryType.Polygon;
|
||||||
|
this.coordinates = null;
|
||||||
initWindow();
|
initWindow();
|
||||||
initHandler();
|
initHandler();
|
||||||
addToolIcon();
|
addToolIcon();
|
||||||
|
@ -78,7 +81,24 @@ public class AreaSelectionDialog extends DialogBox implements
|
||||||
public AreaSelectionDialog(GeometryType geometryType) {
|
public AreaSelectionDialog(GeometryType geometryType) {
|
||||||
try {
|
try {
|
||||||
ShowAllGeometryGeometry = false;
|
ShowAllGeometryGeometry = false;
|
||||||
initialGeometry = geometryType;
|
this.geometryType = geometryType;
|
||||||
|
this.coordinates = null;
|
||||||
|
dialogTitle = "Draw a " + geometryType.getLabel();
|
||||||
|
initWindow();
|
||||||
|
initHandler();
|
||||||
|
addToolIcon();
|
||||||
|
create();
|
||||||
|
} catch (Throwable e) {
|
||||||
|
GWT.log(e.getLocalizedMessage());
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public AreaSelectionDialog(GeometryType geometryType, Coordinates coordinates) {
|
||||||
|
try {
|
||||||
|
ShowAllGeometryGeometry = false;
|
||||||
|
this.geometryType = geometryType;
|
||||||
|
this.coordinates = coordinates;
|
||||||
dialogTitle = "Draw a " + geometryType.getLabel();
|
dialogTitle = "Draw a " + geometryType.getLabel();
|
||||||
initWindow();
|
initWindow();
|
||||||
initHandler();
|
initHandler();
|
||||||
|
@ -101,23 +121,21 @@ public class AreaSelectionDialog extends DialogBox implements
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initHandler() {
|
private void initHandler() {
|
||||||
resizeHandlerRegistration = Window
|
resizeHandlerRegistration = Window.addResizeHandler(new ResizeHandler() {
|
||||||
.addResizeHandler(new ResizeHandler() {
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResize(ResizeEvent event) {
|
public void onResize(ResizeEvent event) {
|
||||||
center();
|
center();
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void create() {
|
private void create() {
|
||||||
|
|
||||||
SimplePanel areaSelectionPanel = new SimplePanel();
|
SimplePanel areaSelectionPanel = new SimplePanel();
|
||||||
areaSelectionPanel.setStyleName(OLBasicResources.INSTANCE.olBasicCSS()
|
areaSelectionPanel.setStyleName(OLBasicResources.INSTANCE.olBasicCSS().getAreaSelectionPanel());
|
||||||
.getAreaSelectionPanel());
|
|
||||||
|
|
||||||
HTML mapContainer = new HTML(
|
HTML mapContainer = new HTML(
|
||||||
"<div id='openLayerMap' class='openLayerMap' style='width:500px;height:250px;'></div>");
|
"<div id='openLayerMap' class='openLayerMap' style='width:500px;height:250px;'></div>");
|
||||||
|
@ -125,11 +143,14 @@ public class AreaSelectionDialog extends DialogBox implements
|
||||||
if (ShowAllGeometryGeometry) {
|
if (ShowAllGeometryGeometry) {
|
||||||
comboGeometryType = new ListBox();
|
comboGeometryType = new ListBox();
|
||||||
comboGeometryType.getElement().setId("combo-geometry-type");
|
comboGeometryType.getElement().setId("combo-geometry-type");
|
||||||
|
|
||||||
//comboGeometryType.getElement().getStyle().setProperty("width", "406px!important");
|
// comboGeometryType.getElement().getStyle().setProperty("width",
|
||||||
|
// "406px!important");
|
||||||
/*comboGeometryType.addStyleName(OLBasicResources.INSTANCE
|
|
||||||
.olBasicCSS().getComboGeometryType());*/
|
/*
|
||||||
|
* comboGeometryType.addStyleName(OLBasicResources.INSTANCE
|
||||||
|
* .olBasicCSS().getComboGeometryType());
|
||||||
|
*/
|
||||||
|
|
||||||
comboGeometryType.setWidth(COMBO_GEOMETY_TYPE_WIDTH);
|
comboGeometryType.setWidth(COMBO_GEOMETY_TYPE_WIDTH);
|
||||||
comboGeometryType.setTabIndex(10001);
|
comboGeometryType.setTabIndex(10001);
|
||||||
|
@ -138,7 +159,7 @@ public class AreaSelectionDialog extends DialogBox implements
|
||||||
comboGeometryType.addItem(gType.getLabel());
|
comboGeometryType.addItem(gType.getLabel());
|
||||||
}
|
}
|
||||||
|
|
||||||
comboGeometryType.setSelectedIndex(initialGeometry.ordinal());
|
comboGeometryType.setSelectedIndex(geometryType.ordinal());
|
||||||
comboGeometryType.addChangeHandler(new ChangeHandler() {
|
comboGeometryType.addChangeHandler(new ChangeHandler() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -146,9 +167,8 @@ public class AreaSelectionDialog extends DialogBox implements
|
||||||
int selected = comboGeometryType.getSelectedIndex();
|
int selected = comboGeometryType.getSelectedIndex();
|
||||||
if (selected >= 0) {
|
if (selected >= 0) {
|
||||||
String geoLabel = comboGeometryType.getValue(selected);
|
String geoLabel = comboGeometryType.getValue(selected);
|
||||||
GeometryType gType = GeometryType
|
GeometryType gType = GeometryType.getFromLabel(geoLabel);
|
||||||
.getFromLabel(geoLabel);
|
onChangeTypeSelect(gType.name());
|
||||||
onChangeTypeSelect(gType.getId());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -161,19 +181,18 @@ public class AreaSelectionDialog extends DialogBox implements
|
||||||
wktGeometry.setVisibleLines(5);
|
wktGeometry.setVisibleLines(5);
|
||||||
wktGeometry.setTabIndex(10002);
|
wktGeometry.setTabIndex(10002);
|
||||||
wktGeometry.getElement().setId("wkt-geometry-text-area");
|
wktGeometry.getElement().setId("wkt-geometry-text-area");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
wktGeometry.addStyleName(OLBasicResources.INSTANCE.olBasicCSS()
|
* wktGeometry.addStyleName(OLBasicResources.INSTANCE.olBasicCSS()
|
||||||
.getWKTGeometryTextArea());
|
* .getWKTGeometryTextArea());
|
||||||
*/
|
*/
|
||||||
// ////////
|
// ////////
|
||||||
// Form
|
// Form
|
||||||
FlexTable layout = new FlexTable();
|
FlexTable layout = new FlexTable();
|
||||||
layout.setCellSpacing(10);
|
layout.setCellSpacing(10);
|
||||||
|
|
||||||
FlexTable selectGeometryFlexTable = new FlexTable();
|
FlexTable selectGeometryFlexTable = new FlexTable();
|
||||||
selectGeometryFlexTable.setStyleName(OLBasicResources.INSTANCE
|
selectGeometryFlexTable.setStyleName(OLBasicResources.INSTANCE.olBasicCSS().getAreaSelectionContent());
|
||||||
.olBasicCSS().getAreaSelectionContent());
|
|
||||||
selectGeometryFlexTable.setCellSpacing(2);
|
selectGeometryFlexTable.setCellSpacing(2);
|
||||||
|
|
||||||
if (ShowAllGeometryGeometry) {
|
if (ShowAllGeometryGeometry) {
|
||||||
|
@ -197,12 +216,10 @@ public class AreaSelectionDialog extends DialogBox implements
|
||||||
dialogContents.setSpacing(4);
|
dialogContents.setSpacing(4);
|
||||||
|
|
||||||
dialogContents.add(mapContainer);
|
dialogContents.add(mapContainer);
|
||||||
dialogContents.setCellHorizontalAlignment(mapContainer,
|
dialogContents.setCellHorizontalAlignment(mapContainer, HasHorizontalAlignment.ALIGN_CENTER);
|
||||||
HasHorizontalAlignment.ALIGN_CENTER);
|
|
||||||
|
|
||||||
dialogContents.add(areaSelectionPanel);
|
dialogContents.add(areaSelectionPanel);
|
||||||
dialogContents.setCellHorizontalAlignment(areaSelectionPanel,
|
dialogContents.setCellHorizontalAlignment(areaSelectionPanel, HasHorizontalAlignment.ALIGN_CENTER);
|
||||||
HasHorizontalAlignment.ALIGN_CENTER);
|
|
||||||
|
|
||||||
// Add Button
|
// Add Button
|
||||||
Button btnSave = new Button("Save");
|
Button btnSave = new Button("Save");
|
||||||
|
@ -237,8 +254,7 @@ public class AreaSelectionDialog extends DialogBox implements
|
||||||
buttonPack.add(btnClose);
|
buttonPack.add(btnClose);
|
||||||
|
|
||||||
dialogContents.add(buttonPack);
|
dialogContents.add(buttonPack);
|
||||||
dialogContents.setCellHorizontalAlignment(buttonPack,
|
dialogContents.setCellHorizontalAlignment(buttonPack, HasHorizontalAlignment.ALIGN_CENTER);
|
||||||
HasHorizontalAlignment.ALIGN_CENTER);
|
|
||||||
|
|
||||||
setWidget(dialogContents);
|
setWidget(dialogContents);
|
||||||
|
|
||||||
|
@ -248,13 +264,49 @@ public class AreaSelectionDialog extends DialogBox implements
|
||||||
public void show() {
|
public void show() {
|
||||||
super.show();
|
super.show();
|
||||||
center();
|
center();
|
||||||
initMap(this, initialGeometry.getId());
|
String projection=null;
|
||||||
|
String longitude= null;
|
||||||
|
String latitude = null;
|
||||||
|
String zoom = null;
|
||||||
|
if (coordinates == null) {
|
||||||
|
projection = ProjectionType.EPSG4326.getLabel();
|
||||||
|
longitude = "0";
|
||||||
|
latitude = "0";
|
||||||
|
zoom = "0";
|
||||||
|
} else {
|
||||||
|
if (coordinates.getProjection() == null || coordinates.getProjection().isEmpty()) {
|
||||||
|
projection = ProjectionType.EPSG4326.getLabel();
|
||||||
|
} else {
|
||||||
|
if (coordinates.getProjection().compareTo(ProjectionType.EPSG4326.getLabel()) == 0
|
||||||
|
|| coordinates.getProjection().compareTo(ProjectionType.EPSG3857.getLabel()) == 0) {
|
||||||
|
projection = coordinates.getProjection();
|
||||||
|
} else {
|
||||||
|
projection = ProjectionType.EPSG4326.getLabel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (coordinates.getX() == null || coordinates.getX().isEmpty()) {
|
||||||
|
longitude = "0";
|
||||||
|
} else {
|
||||||
|
longitude = coordinates.getX();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (coordinates.getY() == null || coordinates.getY().isEmpty()) {
|
||||||
|
latitude = "0";
|
||||||
|
} else {
|
||||||
|
latitude = coordinates.getY();
|
||||||
|
}
|
||||||
|
if (coordinates.getZoom() == null || coordinates.getZoom().isEmpty()) {
|
||||||
|
zoom = "0";
|
||||||
|
} else {
|
||||||
|
zoom = coordinates.getZoom();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
initMap(this, geometryType.name(), projection, longitude, latitude, zoom);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
private void btnClosePressed() {
|
private void btnClosePressed() {
|
||||||
SelectAreaDialogEvent event = new SelectAreaDialogEvent(
|
SelectAreaDialogEvent event = new SelectAreaDialogEvent(SelectAreaDialogEventType.Aborted);
|
||||||
SelectAreaDialogEventType.Aborted);
|
|
||||||
fireEvent(event);
|
fireEvent(event);
|
||||||
hide();
|
hide();
|
||||||
|
|
||||||
|
@ -265,8 +317,7 @@ public class AreaSelectionDialog extends DialogBox implements
|
||||||
if (area == null || area.isEmpty()) {
|
if (area == null || area.isEmpty()) {
|
||||||
GWTMessages.alert("Attention", "Select a valid area!", zIndex);
|
GWTMessages.alert("Attention", "Select a valid area!", zIndex);
|
||||||
} else {
|
} else {
|
||||||
SelectAreaDialogEvent event = new SelectAreaDialogEvent(
|
SelectAreaDialogEvent event = new SelectAreaDialogEvent(SelectAreaDialogEventType.Completed);
|
||||||
SelectAreaDialogEventType.Completed);
|
|
||||||
event.setArea(area);
|
event.setArea(area);
|
||||||
fireEvent(event);
|
fireEvent(event);
|
||||||
hide();
|
hide();
|
||||||
|
@ -280,9 +331,14 @@ public class AreaSelectionDialog extends DialogBox implements
|
||||||
$wnd.addInteraction(value);
|
$wnd.addInteraction(value);
|
||||||
}-*/;
|
}-*/;
|
||||||
|
|
||||||
private static native void initMap(AreaSelectionDialog instance,
|
private static native void initMap(AreaSelectionDialog instance, String geometryName, String projectionName,
|
||||||
String initialGeometry) /*-{
|
String initX, String initY, String initZoom) /*-{
|
||||||
|
console.log(geometryName);
|
||||||
|
console.log(projectionName);
|
||||||
|
console.log(initX);
|
||||||
|
console.log(initY);
|
||||||
|
console.log(initZoom);
|
||||||
|
|
||||||
//window.alert("ol: "+$wnd.ol);
|
//window.alert("ol: "+$wnd.ol);
|
||||||
var ol = $wnd.ol;
|
var ol = $wnd.ol;
|
||||||
$wnd.raster = new ol.layer.Tile({
|
$wnd.raster = new ol.layer.Tile({
|
||||||
|
@ -312,17 +368,25 @@ public class AreaSelectionDialog extends DialogBox implements
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// coords=ol.proj.fromLonLat(coords);
|
||||||
|
// longitude first, then latitude
|
||||||
|
var coords=[initX,initY];
|
||||||
|
console.log(coords);
|
||||||
|
|
||||||
//window.alert("Retrieve map Id: "+$doc.getElementById('map'));
|
//window.alert("Retrieve map Id: "+$doc.getElementById('map'));
|
||||||
|
$wnd.mapView=new ol.View({
|
||||||
|
projection : projectionName,
|
||||||
|
center : coords,
|
||||||
|
zoom : initZoom
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log($wnd.mapView);
|
||||||
$wnd.olMap = new ol.Map({
|
$wnd.olMap = new ol.Map({
|
||||||
layers : [ $wnd.raster, $wnd.vector ],
|
layers : [ $wnd.raster, $wnd.vector ],
|
||||||
target : 'openLayerMap',
|
target : 'openLayerMap',
|
||||||
view : new ol.View({
|
view : $wnd.mapView
|
||||||
projection: 'EPSG:4326',
|
|
||||||
center : [ 0, 0 ],
|
|
||||||
zoom : 0
|
|
||||||
})
|
|
||||||
});
|
});
|
||||||
|
console.log($wnd.olMap);
|
||||||
//window.alert("olMap: "+$wnd.olMap);
|
//window.alert("olMap: "+$wnd.olMap);
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -412,7 +476,7 @@ public class AreaSelectionDialog extends DialogBox implements
|
||||||
// addInteraction();
|
// addInteraction();
|
||||||
//};
|
//};
|
||||||
|
|
||||||
$wnd.addInteraction(initialGeometry);
|
$wnd.addInteraction(geometryName);
|
||||||
}-*/;
|
}-*/;
|
||||||
|
|
||||||
private void addToolIcon() {
|
private void addToolIcon() {
|
||||||
|
@ -421,16 +485,9 @@ public class AreaSelectionDialog extends DialogBox implements
|
||||||
Element dialogTopRight = getCellElement(0, 2);
|
Element dialogTopRight = getCellElement(0, 2);
|
||||||
|
|
||||||
// close button image html
|
// close button image html
|
||||||
dialogTopRight.setInnerHTML("<div class='"
|
dialogTopRight.setInnerHTML("<div class='" + OLBasicResources.INSTANCE.olBasicCSS().getDialogToolButtonText()
|
||||||
+ OLBasicResources.INSTANCE.olBasicCSS()
|
+ "'>" + "<img src='" + OLBasicResources.INSTANCE.toolButtonClose20().getSafeUri().asString()
|
||||||
.getDialogToolButtonText()
|
+ "' class='" + OLBasicResources.INSTANCE.olBasicCSS().getDialogToolButtonIcon() + "' /></div>");
|
||||||
+ "'>"
|
|
||||||
+ "<img src='"
|
|
||||||
+ OLBasicResources.INSTANCE.toolButtonClose20().getSafeUri()
|
|
||||||
.asString()
|
|
||||||
+ "' class='"
|
|
||||||
+ OLBasicResources.INSTANCE.olBasicCSS()
|
|
||||||
.getDialogToolButtonIcon() + "' /></div>");
|
|
||||||
|
|
||||||
// set the event target
|
// set the event target
|
||||||
closeEventTarget = dialogTopRight.getChild(0).getChild(0);
|
closeEventTarget = dialogTopRight.getChild(0).getChild(0);
|
||||||
|
@ -449,10 +506,8 @@ public class AreaSelectionDialog extends DialogBox implements
|
||||||
protected void onPreviewNativeEvent(NativePreviewEvent event) {
|
protected void onPreviewNativeEvent(NativePreviewEvent event) {
|
||||||
NativeEvent nativeEvent = event.getNativeEvent();
|
NativeEvent nativeEvent = event.getNativeEvent();
|
||||||
|
|
||||||
if (!event.isCanceled() && (event.getTypeInt() == Event.ONCLICK)
|
if (!event.isCanceled() && (event.getTypeInt() == Event.ONCLICK) && isCloseEvent(nativeEvent)) {
|
||||||
&& isCloseEvent(nativeEvent)) {
|
final SelectAreaDialogEvent wizardEvent = new SelectAreaDialogEvent(SelectAreaDialogEventType.Aborted);
|
||||||
final SelectAreaDialogEvent wizardEvent = new SelectAreaDialogEvent(
|
|
||||||
SelectAreaDialogEventType.Aborted);
|
|
||||||
fireEvent(wizardEvent);
|
fireEvent(wizardEvent);
|
||||||
this.hide();
|
this.hide();
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,9 +33,6 @@ public enum GeometryType {
|
||||||
return label;
|
return label;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getId() {
|
|
||||||
return name();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
|
@ -0,0 +1,67 @@
|
||||||
|
package org.gcube.portlets.widgets.openlayerbasicwidgets.shared.data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Giancarlo Panichi
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class Coordinates implements Serializable {
|
||||||
|
private static final long serialVersionUID = -1387634056697911513L;
|
||||||
|
private String projection;
|
||||||
|
private String x;
|
||||||
|
private String y;
|
||||||
|
private String zoom;
|
||||||
|
|
||||||
|
public Coordinates() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Coordinates(String projection, String x, String y, String zoom) {
|
||||||
|
super();
|
||||||
|
this.projection = projection;
|
||||||
|
this.x = x;
|
||||||
|
this.y = y;
|
||||||
|
this.zoom = zoom;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getProjection() {
|
||||||
|
return projection;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProjection(String projection) {
|
||||||
|
this.projection = projection;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getX() {
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setX(String x) {
|
||||||
|
this.x = x;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getY() {
|
||||||
|
return y;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setY(String y) {
|
||||||
|
this.y = y;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getZoom() {
|
||||||
|
return zoom;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setZoom(String zoom) {
|
||||||
|
this.zoom = zoom;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Coordinate [projection=" + projection + ", x=" + x + ", y=" + y + ", zoom=" + zoom + "]";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,42 @@
|
||||||
|
package org.gcube.portlets.widgets.openlayerbasicwidgets.shared.data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Giancarlo Panichi
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public enum ProjectionType {
|
||||||
|
|
||||||
|
EPSG4326("EPSG:4326"),
|
||||||
|
EPSG3857("EPSG:3857");
|
||||||
|
|
||||||
|
private final String id;
|
||||||
|
|
||||||
|
private ProjectionType(final String id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLabel() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static ProjectionType getProjectionTypeFromId(String id) {
|
||||||
|
for (ProjectionType projectionType : values()) {
|
||||||
|
if (projectionType.id.compareToIgnoreCase(id) == 0) {
|
||||||
|
return projectionType;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue