#24506 done. Locate/Highlight the Layer
This commit is contained in:
parent
7247c3d4b6
commit
67e4275b55
|
@ -4,6 +4,13 @@
|
|||
All notable changes to this project will be documented in this file.
|
||||
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [v3.2.0-SNAPSHOT] - 2023-01-31
|
||||
|
||||
#### Enhancements
|
||||
|
||||
- [#24506] Added Locate/Highlight the Layer facility on the Map
|
||||
- Moved to gwt 2.10
|
||||
|
||||
## [v3.1.0] - 2023-01-12
|
||||
|
||||
#### Enhancements
|
||||
|
|
4
pom.xml
4
pom.xml
|
@ -14,13 +14,13 @@
|
|||
<groupId>org.gcube.portlets.user</groupId>
|
||||
<artifactId>geoportal-data-viewer-app</artifactId>
|
||||
<packaging>war</packaging>
|
||||
<version>3.1.0</version>
|
||||
<version>3.2.0-SNAPSHOT</version>
|
||||
<name>GeoPortal Data Viewer App</name>
|
||||
<description>The GeoPortal Data Viewer App is an application to access, discovery and navigate the Geoportal projects/documents by a Web-Map Interface</description>
|
||||
|
||||
<properties>
|
||||
<!-- Convenience property to set the GWT version -->
|
||||
<gwt.version>2.9.0</gwt.version>
|
||||
<gwt.version>2.10.0</gwt.version>
|
||||
<gwt.compiler.style>PRETTY</gwt.compiler.style>
|
||||
<gson.version>2.6.2</gson.version>
|
||||
<webappDirectory>${project.build.directory}/${project.build.finalName}</webappDirectory>
|
||||
|
|
|
@ -8,10 +8,11 @@ import java.util.Set;
|
|||
|
||||
import org.gcube.application.geoportalcommon.shared.GNADataViewerConfigProfile;
|
||||
import org.gcube.application.geoportalcommon.shared.GeoportalItemReferences;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.geojson.GeoJSON;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.materialization.IndexLayerDV;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.project.ProjectDV;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.project.RelationshipDV;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.view.ProjectView;
|
||||
import org.gcube.application.geoportalcommon.shared.gis.BoundsMap;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants.MAP_PROJECTION;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants.MapEventType;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.client.events.AddLayerToMapEvent;
|
||||
|
@ -556,7 +557,7 @@ public class GeoportalDataViewer implements EntryPoint {
|
|||
applicationBus.addHandler(DoActionOnDetailLayersEvent.TYPE, new DoActionOnDetailLayersEventHandler() {
|
||||
|
||||
@Override
|
||||
public void onDoActionOnDetailLayers(DoActionOnDetailLayersEvent doLayerActionEvent) {
|
||||
public void onDoActionOnDetailLayers(final DoActionOnDetailLayersEvent doLayerActionEvent) {
|
||||
|
||||
DO_LAYER_ACTION doAction = doLayerActionEvent.getDoAction();
|
||||
GWT.log("event: " + doAction);
|
||||
|
@ -585,44 +586,14 @@ public class GeoportalDataViewer implements EntryPoint {
|
|||
break;
|
||||
case LOCATE_LAYER:
|
||||
|
||||
LayerItem layerItem = doLayerActionEvent.getLayerItem();
|
||||
final LayerItem layerItem = doLayerActionEvent.getLayerItem();
|
||||
|
||||
ol.layer.Image layer = olMap.getWmsDetailsLayerMap().get(layerItem.getName());
|
||||
|
||||
|
||||
|
||||
ExtentWrapped sourceExt = olMap.getSourceExtentForLayer(layerItem.getName());
|
||||
|
||||
GWT.log("extent: "+sourceExt);
|
||||
|
||||
// BoundsMap theBBOX = new BoundsMap(layer.getExtent().getLowerLeftX(), layer.getExtent().getLowerLeftY(), layer.getExtent().getUpperRightX(), layer.getExtent().getUpperRightY(),
|
||||
// null);
|
||||
|
||||
// Coordinate lower = OLFactory.createCoordinate(olMap.getBBOX().getLowerLeftX(), olMap.getBBOX().getLowerLeftY());
|
||||
// Coordinate lowerCoord = MapUtils.transformCoordiante(lower, MAP_PROJECTION.EPSG_4326.getName(),
|
||||
// MAP_PROJECTION.EPSG_3857.getName());
|
||||
//
|
||||
// Coordinate upper = OLFactory.createCoordinate(olMap.getBBOX().getUpperRightX(), olMap.getBBOX().getUpperRightY());
|
||||
// Coordinate upperCoord = MapUtils.transformCoordiante(upper, MAP_PROJECTION.EPSG_4326.getName(),
|
||||
// MAP_PROJECTION.EPSG_3857.getName());
|
||||
|
||||
|
||||
BoundsMap theBBOX = new BoundsMap(sourceExt.getLowerLeftX(), sourceExt.getLowerLeftY(), sourceExt.getUpperRightX(), sourceExt.getUpperRightY(), null);
|
||||
GWT.log("theBBOX: "+theBBOX);
|
||||
// if (bbox != null) {
|
||||
|
||||
// Coordinate lower = OLFactory.createCoordinate(olMap.getBBOX().getLowerLeftX(), olMap.getBBOX().getLowerLeftY());
|
||||
// Coordinate lowerCoord = MapUtils.transformCoordiante(lower, MAP_PROJECTION.EPSG_4326.getName(),
|
||||
// MAP_PROJECTION.EPSG_3857.getName());
|
||||
//
|
||||
// Coordinate upper = OLFactory.createCoordinate(olMap.getBBOX().getUpperRightX(), olMap.getBBOX().getUpperRightY());
|
||||
// Coordinate upperCoord = MapUtils.transformCoordiante(upper, MAP_PROJECTION.EPSG_4326.getName(),
|
||||
// MAP_PROJECTION.EPSG_3857.getName());
|
||||
//
|
||||
// ew = new ExtentWrapped(lowerCoord.getX(), lowerCoord.getY(), upperCoord.getX(), upperCoord.getY());
|
||||
|
||||
// }
|
||||
boolean layerHighlighted = olMap.areLayerFeaturesAsHighlight(layerItem);
|
||||
|
||||
if(layerHighlighted) {
|
||||
olMap.removeLayerFeaturesAsHighlight(layerItem.getName());
|
||||
return;
|
||||
}
|
||||
|
||||
GeoportalDataViewerServiceAsync.Util.getInstance().getWFSRequest(layerItem,
|
||||
olMap.getProjectionCode(), null, 0, "json",
|
||||
|
@ -651,7 +622,7 @@ public class GeoportalDataViewer implements EntryPoint {
|
|||
|
||||
GeoJsonFeatureOptions fo = new GeoJsonFeatureOptions();
|
||||
ProjectionOptions projectionOptions = new ProjectionOptions();
|
||||
projectionOptions.setCode(MAP_PROJECTION.EPSG_3857.getName());
|
||||
projectionOptions.setCode(MAP_PROJECTION.EPSG_4326.getName());
|
||||
Projection fp = new Projection(projectionOptions);
|
||||
fo.setFeatureProjection(fp);
|
||||
fo.setDataProjection(fp);
|
||||
|
@ -663,16 +634,25 @@ public class GeoportalDataViewer implements EntryPoint {
|
|||
Feature[] features = geoJson.readFeatures(response.getText());
|
||||
GWT.log("features: "+features);
|
||||
//Feature[] features = new GeoJson().readFeatures(jsonObject, projectionOptions);
|
||||
olMap.addFeaturesAsHighlight(features);
|
||||
olMap.addLayerFeaturesAsHighlight(layerItem, features);
|
||||
|
||||
ProjectDV projectDV = doLayerActionEvent.getLayerObject().getProjectDV();
|
||||
if(projectDV!=null) {
|
||||
GeoJSON spatialReference = projectDV.getSpatialReference();
|
||||
|
||||
GWT.log("spatialReference is: "+spatialReference);
|
||||
Coordinate transfCoord = MapUtils.geoJSONTToBBoxCenter(spatialReference, MAP_PROJECTION.EPSG_4326.getName(),
|
||||
MAP_PROJECTION.EPSG_3857.getName());
|
||||
GWT.log("transfCoord is: "+transfCoord);
|
||||
if(transfCoord!=null)
|
||||
olMap.setCenter(transfCoord);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
} catch (RequestException e) {
|
||||
// Code omitted for clarity
|
||||
|
||||
}
|
||||
|
||||
//olMap.locateLayer(doLayerActionEvent.getLayerItem());
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -412,6 +412,7 @@ public class LayerManager {
|
|||
public void removeAllDetailLayers() {
|
||||
mapOtherLayerObjects.clear();
|
||||
olMap.removeAllDetailLayers();
|
||||
olMap.removeAllLayerFeaturesAsHighlight();
|
||||
overlayLayerManager.resetLayers();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package org.gcube.portlets.user.geoportaldataviewer.client.events;
|
||||
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerItem;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerObject;
|
||||
|
||||
import com.google.gwt.event.shared.GwtEvent;
|
||||
|
||||
|
@ -31,15 +32,16 @@ public class DoActionOnDetailLayersEvent extends GwtEvent<DoActionOnDetailLayers
|
|||
private boolean visibility;
|
||||
private SwapLayer sourceLayerSwap;
|
||||
private SwapLayer targetLayerSwap;
|
||||
private LayerObject layerObject;
|
||||
|
||||
/**
|
||||
* The Class SwapLayer.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Oct 15, 2021
|
||||
* Oct 15, 2021
|
||||
*/
|
||||
public static class SwapLayer{
|
||||
public static class SwapLayer {
|
||||
private LayerItem layerItem;
|
||||
private int position;
|
||||
|
||||
|
@ -47,9 +49,9 @@ public class DoActionOnDetailLayersEvent extends GwtEvent<DoActionOnDetailLayers
|
|||
* Instantiates a new swap layer.
|
||||
*
|
||||
* @param layerItem the layer item
|
||||
* @param position the position
|
||||
* @param position the position
|
||||
*/
|
||||
public SwapLayer(LayerItem layerItem, int position){
|
||||
public SwapLayer(LayerItem layerItem, int position) {
|
||||
this.layerItem = layerItem;
|
||||
this.position = position;
|
||||
}
|
||||
|
@ -76,11 +78,13 @@ public class DoActionOnDetailLayersEvent extends GwtEvent<DoActionOnDetailLayers
|
|||
/**
|
||||
* Instantiates a new do action on detail layers event.
|
||||
*
|
||||
* @param action the action
|
||||
* @param layerItem the layer item
|
||||
* @param action the action
|
||||
* @param layerItem the layer item
|
||||
* @param layerObject the layer object
|
||||
*/
|
||||
public DoActionOnDetailLayersEvent(DO_LAYER_ACTION action, LayerItem layerItem) {
|
||||
public DoActionOnDetailLayersEvent(DO_LAYER_ACTION action, LayerItem layerItem, LayerObject layerObject) {
|
||||
this.layerItem = layerItem;
|
||||
this.layerObject = layerObject;
|
||||
this.doAction = action;
|
||||
}
|
||||
|
||||
|
@ -135,6 +139,24 @@ public class DoActionOnDetailLayersEvent extends GwtEvent<DoActionOnDetailLayers
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the layer object.
|
||||
*
|
||||
* @return the layer object
|
||||
*/
|
||||
public LayerObject getLayerObject() {
|
||||
return layerObject;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the layer object.
|
||||
*
|
||||
* @param layerObject the new layer object
|
||||
*/
|
||||
public void setLayerObject(LayerObject layerObject) {
|
||||
this.layerObject = layerObject;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the do action.
|
||||
*
|
||||
|
|
|
@ -78,7 +78,7 @@ import ol.style.Style;
|
|||
*/
|
||||
public abstract class OpenLayerMap {
|
||||
|
||||
private static final int MAX_LENGHT_CQL_FOR_GET_REQUEST = 1600; //1600 characters
|
||||
private static final int MAX_LENGHT_CQL_FOR_GET_REQUEST = 1600; // 1600 characters
|
||||
|
||||
public static final int SET_CENTER_ANIMATED_DURATION = 500;
|
||||
|
||||
|
@ -151,6 +151,8 @@ public abstract class OpenLayerMap {
|
|||
|
||||
private LinkedHashMap<String, Image> wmsLayerMap;
|
||||
|
||||
private LinkedHashMap<String, ol.layer.Vector> vectorLayersHighlighted = new LinkedHashMap<String, ol.layer.Vector>();
|
||||
|
||||
private Layer baseLayerTile;
|
||||
|
||||
private LayerOrder layerOrder = new LayerOrder();
|
||||
|
@ -316,7 +318,7 @@ public abstract class OpenLayerMap {
|
|||
animations.setDuration(SET_CENTER_ANIMATED_DURATION);
|
||||
view.animate(animations);
|
||||
|
||||
//view.setCenter(centerCoordinate);
|
||||
// view.setCenter(centerCoordinate);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -329,7 +331,7 @@ public abstract class OpenLayerMap {
|
|||
animations.setDuration(ZOOM_ANIMATED_DURATION);
|
||||
animations.setZoom(zoom);
|
||||
view.animate(animations);
|
||||
//view.setZoom(zoom);
|
||||
// view.setZoom(zoom);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -453,6 +455,12 @@ public abstract class OpenLayerMap {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the CQL filter to WMS layer.
|
||||
*
|
||||
* @param key the key
|
||||
* @param cqlFilterExpression the cql filter expression
|
||||
*/
|
||||
public void setCQLFilterToWMSLayer(String key, String cqlFilterExpression) {
|
||||
|
||||
GWT.log("Getting key: " + key);
|
||||
|
@ -467,7 +475,7 @@ public abstract class OpenLayerMap {
|
|||
ImageWms imageWMSSource = wmsLayer.getSource();
|
||||
ImageWmsParams imageWMSParams = imageWMSSource.getParams();
|
||||
|
||||
if (cqlFilterExpression == null || cqlFilterExpression.length()>MAX_LENGHT_CQL_FOR_GET_REQUEST) {
|
||||
if (cqlFilterExpression == null || cqlFilterExpression.length() > MAX_LENGHT_CQL_FOR_GET_REQUEST) {
|
||||
imageWMSParams.delete("CQL_FILTER");
|
||||
} else {
|
||||
imageWMSParams.set("CQL_FILTER", cqlFilterExpression);
|
||||
|
@ -530,41 +538,12 @@ public abstract class OpenLayerMap {
|
|||
GWT.log("The WMS detail layer with key: " + key + " already exists, skipping");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void locateLayer(LayerItem layerItem) {
|
||||
|
||||
String key = layerItem.getName();
|
||||
Image layer = wmsDetailsLayerMap.get(key);
|
||||
|
||||
Source source = layer.getSource();
|
||||
// GeoportalDataViewerConstants.printJsObj(source);
|
||||
String sorceRootObj = GeoportalDataViewerConstants.toJsonObj(source);
|
||||
JSONValue jsonObj = JSONParser.parseStrict(sorceRootObj);
|
||||
// GWT.log("jsonObj: " + jsonObj.toString());
|
||||
JSONObject jsonSourceObj = (JSONObject) jsonObj;
|
||||
GeoportalDataViewerConstants.printJsObj(jsonSourceObj);
|
||||
|
||||
// layer.get("geometry");
|
||||
// GWT.log("The geometry is: "+layer.getSource().get("geometry"));
|
||||
|
||||
// Point thePoint = new Point(coordinate);
|
||||
// Feature vf = new Feature(layer.getExtent());
|
||||
// vf.setStyle(style);
|
||||
// ol.source.Vector vector = new ol.source.Vector();
|
||||
// vector.addFeature(vf);
|
||||
// VectorLayerOptions vectorLayerOptions = new VectorLayerOptions();
|
||||
// vectorLayerOptions.setSource(vector);
|
||||
// ol.layer.Vector geometryLayer = new ol.layer.Vector(vectorLayerOptions);
|
||||
// int zIndex = layerOrder.getOffset(LayerOrder.LAYER_TYPE.VECTOR)+1;
|
||||
// geometryLayer.setZIndex(zIndex);
|
||||
// map.addLayer(geometryLayer);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the all detail layers.
|
||||
*
|
||||
* @param layerName the layer name
|
||||
*/
|
||||
public void removeWMSLayer(String layerName) {
|
||||
GWT.log("Removing layerName: " + layerName + " from map: " + wmsLayerMap);
|
||||
|
@ -589,8 +568,6 @@ public abstract class OpenLayerMap {
|
|||
*/
|
||||
public void removeAllDetailLayers() {
|
||||
|
||||
// NOT NEEDED ANYMORE.. I'M USING MIN/MAX LAYER RESOLUTION
|
||||
|
||||
if (wmsDetailsLayerMap == null)
|
||||
return;
|
||||
|
||||
|
@ -605,6 +582,24 @@ public abstract class OpenLayerMap {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the all layer features as highlight.
|
||||
*/
|
||||
public void removeAllLayerFeaturesAsHighlight() {
|
||||
|
||||
if (vectorLayersHighlighted == null)
|
||||
return;
|
||||
|
||||
GWT.log("Removing vectorLayersHighlighted: " + vectorLayersHighlighted.keySet() + " from map");
|
||||
|
||||
for (String layerName : vectorLayersHighlighted.keySet()) {
|
||||
removeLayerFeaturesAsHighlight(layerName);
|
||||
}
|
||||
|
||||
vectorLayersHighlighted.clear();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the vector.
|
||||
*
|
||||
|
@ -641,49 +636,78 @@ public abstract class OpenLayerMap {
|
|||
/**
|
||||
* Adds the vector.
|
||||
*
|
||||
* @param geometry the geometry
|
||||
* @param layerItem the layer item
|
||||
* @param features the features
|
||||
*/
|
||||
public void addFeaturesAsHighlight(Feature[] features) {
|
||||
public void addLayerFeaturesAsHighlight(LayerItem layerItem, Feature[] features) {
|
||||
|
||||
removeLayerFeaturesAsHighlight(layerItem.getName());
|
||||
|
||||
Style style = new Style();
|
||||
|
||||
|
||||
StrokeOptions strokeOptions = new StrokeOptions();
|
||||
strokeOptions.setColor(new Color(255, 255, 255, 1.0));
|
||||
strokeOptions.setColor(new Color(255, 255, 255, 0.8));
|
||||
strokeOptions.setWidth(5);
|
||||
Stroke stroke = new Stroke(strokeOptions);
|
||||
stroke.setWidth(5);
|
||||
FillOptions fillOptions = new FillOptions();
|
||||
fillOptions.setColor(new Color(0, 0, 255, 1.0));
|
||||
stroke.setWidth(3);
|
||||
style.setStroke(stroke);
|
||||
|
||||
|
||||
// FillOptions fillOptions = new FillOptions();
|
||||
// fillOptions.setColor(color);
|
||||
// Fill fill = new Fill(fillOptions);
|
||||
|
||||
// style.setFill(fill);
|
||||
Vector vectorSource = OLFactory.createVectorSource();
|
||||
vectorSource.addFeatures(features);
|
||||
|
||||
GWT.log("features: "+features);
|
||||
GWT.log("features: " + features);
|
||||
|
||||
VectorLayerOptions vectorLayerOptions = new VectorLayerOptions();
|
||||
vectorLayerOptions.setSource(vectorSource);
|
||||
vectorLayerOptions.setStyle(style);
|
||||
|
||||
//vectorLayerOptions.setMap(map);
|
||||
// vectorLayerOptions.setMap(map);
|
||||
|
||||
GWT.log("vectorLayerOptions: "+vectorLayerOptions);
|
||||
GWT.log("vectorLayerOptions: " + vectorLayerOptions);
|
||||
|
||||
ol.layer.Vector vector = OLFactory.createVector(vectorLayerOptions);
|
||||
vector.setStyle(style);
|
||||
// vector.setStyle(style);
|
||||
vector.setVisible(true);
|
||||
vector.setZIndex(11000);
|
||||
vector.setZIndex(5000);
|
||||
|
||||
vectorLayersHighlighted.put(layerItem.getName(), vector);
|
||||
|
||||
map.addLayer(vector);
|
||||
}
|
||||
|
||||
/**
|
||||
* Are layer features A as highlight.
|
||||
*
|
||||
* @param layerItem the layer item
|
||||
* @return true, if successful
|
||||
*/
|
||||
public boolean areLayerFeaturesAsHighlight(LayerItem layerItem) {
|
||||
return vectorLayersHighlighted.get(layerItem.getName()) != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the layer features A as highlight.
|
||||
*
|
||||
* @param layerName the layer name
|
||||
* @return true, if successful
|
||||
*/
|
||||
public boolean removeLayerFeaturesAsHighlight(String layerName) {
|
||||
|
||||
try {
|
||||
|
||||
ol.layer.Vector vl = vectorLayersHighlighted.get(layerName);
|
||||
|
||||
if (vl != null) {
|
||||
map.removeLayer(vl);
|
||||
vectorLayersHighlighted.remove(layerName);
|
||||
return true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the point vector source.
|
||||
*
|
||||
|
@ -955,7 +979,6 @@ public abstract class OpenLayerMap {
|
|||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the wms details layer map.
|
||||
*
|
||||
|
@ -1018,8 +1041,6 @@ public abstract class OpenLayerMap {
|
|||
layer.setOpacity(opacity);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Swap details layers.
|
||||
*
|
||||
|
@ -1057,7 +1078,4 @@ public abstract class OpenLayerMap {
|
|||
return map.get((map.keySet().toArray())[index]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -47,6 +47,12 @@ public interface GNAImages extends ClientBundle {
|
|||
@Source("layer_invisible.png")
|
||||
ImageResource layerInvisible();
|
||||
|
||||
@Source("locate.png")
|
||||
ImageResource locate();
|
||||
|
||||
@Source("locate_none.png")
|
||||
ImageResource locateNone();
|
||||
|
||||
@Source("spinner_earth.gif")
|
||||
ImageResource spinnerEarth();
|
||||
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
Binary file not shown.
After Width: | Height: | Size: 1.6 KiB |
|
@ -2,6 +2,7 @@ package org.gcube.portlets.user.geoportaldataviewer.client.ui.dandd;
|
|||
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.geojson.GeoJSON;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.project.TemporalReferenceDV;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerServiceAsync;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.client.events.DoActionOnDetailLayersEvent;
|
||||
|
@ -32,21 +33,29 @@ import com.google.gwt.event.dom.client.DropEvent;
|
|||
import com.google.gwt.event.dom.client.DropHandler;
|
||||
import com.google.gwt.event.shared.HandlerManager;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
import com.google.gwt.user.client.ui.FlexTable;
|
||||
import com.google.gwt.user.client.ui.FlowPanel;
|
||||
import com.google.gwt.user.client.ui.HTML;
|
||||
import com.google.gwt.user.client.ui.HorizontalPanel;
|
||||
import com.google.gwt.user.client.ui.Image;
|
||||
import com.google.gwt.user.client.ui.SimplePanel;
|
||||
import com.google.gwt.user.client.ui.VerticalPanel;
|
||||
import com.google.gwt.user.client.ui.Widget;
|
||||
|
||||
public class DragDropLayer extends FlowPanel {
|
||||
|
||||
private static final String _22PX = "22px";
|
||||
private static DragDropLayer dragging = null;
|
||||
private static DragDropLayer draggingTarget = null;
|
||||
final boolean droppable;
|
||||
private Label labelLayerName;
|
||||
private Image imgLayerVisible = new Image(GNAImages.ICONS.layerVisible());
|
||||
private Image imgLayerInvisible = new Image(GNAImages.ICONS.layerInvisible());
|
||||
|
||||
private Image imgLocate = new Image(GNAImages.ICONS.locate());
|
||||
private Image imgLocateNone = new Image(GNAImages.ICONS.locateNone());
|
||||
private boolean locateEnabled = false;
|
||||
private HTML buttonLocate = new HTML();
|
||||
|
||||
private Button draggableButton = new Button();
|
||||
private HandlerManager applicationBus;
|
||||
private LayerObject layerObject;
|
||||
|
@ -54,7 +63,6 @@ public class DragDropLayer extends FlowPanel {
|
|||
private com.google.gwt.user.client.ui.Label labelProject;
|
||||
private boolean layerVisibility = true;
|
||||
private HTML buttonLayerVisibility = new HTML();
|
||||
private Button buttonLocate = new Button();
|
||||
|
||||
public DragDropLayer(HandlerManager applicationBus, LayerObject layerObject, boolean draggable, boolean droppable) {
|
||||
this.applicationBus = applicationBus;
|
||||
|
@ -62,6 +70,26 @@ public class DragDropLayer extends FlowPanel {
|
|||
this.layerItem = layerObject.getLayerItem();
|
||||
GWT.log("DragDropLayer for projectDV: " + layerObject.getProjectDV());
|
||||
|
||||
// Checking the spatial reference
|
||||
if (layerObject.getProjectDV() != null && layerObject.getProjectDV().getSpatialReference() == null) {
|
||||
GeoportalDataViewerServiceAsync.Util.getInstance().getSpatialReference(layerObject.getProfileID(),
|
||||
layerObject.getProjectID(), new AsyncCallback<GeoJSON>() {
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(GeoJSON result) {
|
||||
if (result != null)
|
||||
layerObject.getProjectDV().setSpatialReference(result);
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
String referProjectID = "Project ID: " + layerObject.getProjectDV().getId();
|
||||
labelProject = new com.google.gwt.user.client.ui.Label("");
|
||||
labelProject.setTitle(referProjectID);
|
||||
|
@ -75,8 +103,8 @@ public class DragDropLayer extends FlowPanel {
|
|||
if (result != null) {
|
||||
for (String key : result.keySet()) {
|
||||
result.get(key);
|
||||
//referProject = key + ": " + result.get(key);
|
||||
realProjectName = result.get(key)+"";
|
||||
// referProject = key + ": " + result.get(key);
|
||||
realProjectName = result.get(key) + "";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -120,42 +148,47 @@ public class DragDropLayer extends FlowPanel {
|
|||
|
||||
RangeSlider rs = new RangeSlider(applicationBus, layerItem);
|
||||
rs.getElement().addClassName("range-slider");
|
||||
FlexTable ft = new FlexTable();
|
||||
ft.setWidget(0, 0, draggableButton);
|
||||
|
||||
// FlexTable ft = new FlexTable();
|
||||
// ft.setWidget(0, 0, draggableButton);
|
||||
draggableButton.setTitle("Drag and Drop me up or down to change my position on the Map");
|
||||
|
||||
imgLayerVisible.getElement().addClassName("layer-visibility-st");
|
||||
imgLayerInvisible.getElement().addClassName("layer-visibility-st");
|
||||
|
||||
imgLocate.setWidth(_22PX);
|
||||
imgLocate.setHeight(_22PX);
|
||||
imgLocateNone.setWidth(_22PX);
|
||||
imgLocateNone.setHeight(_22PX);
|
||||
imgLocate.getElement().addClassName("layer-visibility-st");
|
||||
imgLocateNone.getElement().addClassName("layer-visibility-st");
|
||||
setLocateEnabledButtonImage();
|
||||
|
||||
setLayerVisibilityButtonImage();
|
||||
|
||||
buttonLocate.setIcon(IconType.MAP_MARKER);
|
||||
buttonLocate.addClickHandler(new ClickHandler() {
|
||||
VerticalPanel vp = new VerticalPanel();
|
||||
VerticalPanel vpInner = new VerticalPanel();
|
||||
HorizontalPanel hp1 = new HorizontalPanel();
|
||||
vpInner.getElement().getStyle().setMarginLeft(47, Unit.PX);
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
hp1.add(draggableButton);
|
||||
hp1.add(buttonLayerVisibility);
|
||||
hp1.add(buttonLocate);
|
||||
vpInner.add(labelProject);
|
||||
|
||||
setLayerVisibilityButtonImage();
|
||||
DoActionOnDetailLayersEvent dae = new DoActionOnDetailLayersEvent(DO_LAYER_ACTION.LOCATE_LAYER,
|
||||
layerItem);
|
||||
applicationBus.fireEvent(dae);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// labelLayerName.getElement().getStyle().setMarginLeft(10, Unit.PX);
|
||||
ft.setWidget(0, 1, buttonLayerVisibility);
|
||||
ft.setWidget(0, 2, buttonLocate);
|
||||
ft.setWidget(0, 3, labelProject);
|
||||
|
||||
if(layerObject.getProjectDV().getTemporalReference()!=null) {
|
||||
if (layerObject.getProjectDV().getTemporalReference() != null) {
|
||||
TemporalReferenceDV tempRef = layerObject.getProjectDV().getTemporalReference();
|
||||
ft.setWidget(ft.getRowCount()+1, 2, new HTML(ProjectUtil.toHTMLCode(tempRef)));
|
||||
// ft.setWidget(ft.getRowCount() + 1, 2, new HTML(ProjectUtil.toHTMLCode(tempRef)));
|
||||
vpInner.add(new HTML(ProjectUtil.toHTMLCode(tempRef)));
|
||||
}
|
||||
|
||||
ft.setWidget(ft.getRowCount()+1, 2, labelLayerName);
|
||||
ft.setWidget(ft.getRowCount()+1, 2, new SimplePanel(rs));
|
||||
add(ft);
|
||||
vpInner.add(labelLayerName);
|
||||
vpInner.add(new SimplePanel(rs));
|
||||
vp.add(hp1);
|
||||
vp.add(vpInner);
|
||||
add(vp);
|
||||
|
||||
// add(ft);
|
||||
draggableButton.setIcon(IconType.MOVE);
|
||||
|
||||
buttonLayerVisibility.addClickHandler(new ClickHandler() {
|
||||
|
@ -164,20 +197,46 @@ public class DragDropLayer extends FlowPanel {
|
|||
public void onClick(ClickEvent event) {
|
||||
layerVisibility = !layerVisibility;
|
||||
setLayerVisibilityButtonImage();
|
||||
DoActionOnDetailLayersEvent dae = new DoActionOnDetailLayersEvent(DO_LAYER_ACTION.VISIBILITY,
|
||||
layerItem);
|
||||
DoActionOnDetailLayersEvent dae = new DoActionOnDetailLayersEvent(DO_LAYER_ACTION.VISIBILITY, layerItem,
|
||||
layerObject);
|
||||
dae.setVisibility(layerVisibility);
|
||||
applicationBus.fireEvent(dae);
|
||||
}
|
||||
});
|
||||
|
||||
buttonLocate.addClickHandler(new ClickHandler() {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
locateEnabled = !locateEnabled;
|
||||
setLocateEnabledButtonImage();
|
||||
DoActionOnDetailLayersEvent dae = new DoActionOnDetailLayersEvent(DO_LAYER_ACTION.LOCATE_LAYER,
|
||||
layerItem, layerObject);
|
||||
applicationBus.fireEvent(dae);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void setLayerVisibilityButtonImage() {
|
||||
buttonLayerVisibility.getElement().removeAllChildren();
|
||||
if (layerVisibility) {
|
||||
buttonLayerVisibility.getElement().appendChild(imgLayerVisible.getElement());
|
||||
buttonLayerVisibility.setTitle("Hide the layer");
|
||||
} else {
|
||||
buttonLayerVisibility.getElement().appendChild(imgLayerInvisible.getElement());
|
||||
buttonLayerVisibility.setTitle("Show the layer");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void setLocateEnabledButtonImage() {
|
||||
buttonLocate.getElement().removeAllChildren();
|
||||
if (locateEnabled) {
|
||||
buttonLocate.getElement().appendChild(imgLocate.getElement());
|
||||
buttonLocate.setTitle("Unselect the layer");
|
||||
} else {
|
||||
buttonLocate.getElement().appendChild(imgLocateNone.getElement());
|
||||
buttonLocate.setTitle("Highlight the layer");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -243,7 +302,7 @@ public class DragDropLayer extends FlowPanel {
|
|||
tree.insert(source, targetIndex);
|
||||
// target.setState(true);
|
||||
DoActionOnDetailLayersEvent actionSwapLayers = new DoActionOnDetailLayersEvent(
|
||||
DO_LAYER_ACTION.SWAP, layerItem);
|
||||
DO_LAYER_ACTION.SWAP, layerItem, layerObject);
|
||||
SwapLayer swapLS = new DoActionOnDetailLayersEvent.SwapLayer(dragging.getLayerItem(),
|
||||
sourceIndex);
|
||||
SwapLayer swapLT = new DoActionOnDetailLayersEvent.SwapLayer(draggingTarget.getLayerItem(),
|
||||
|
|
|
@ -54,7 +54,7 @@ public class RangeSlider extends Composite {
|
|||
if (Event.ONMOUSEUP == event.getTypeInt()) {
|
||||
GWT.log("Event.ONMOUSEUP");
|
||||
DoActionOnDetailLayersEvent actionChangeOpacity = new DoActionOnDetailLayersEvent(
|
||||
DO_LAYER_ACTION.OPACITY, layer);
|
||||
DO_LAYER_ACTION.OPACITY, layer, null);
|
||||
int value = Integer.parseInt((String) theSlider.getPropertyObject("value"));
|
||||
//GWT.log("opacity int value: "+value);
|
||||
double opacity = (double) ((double) value/100);
|
||||
|
|
|
@ -577,6 +577,7 @@ public class Geoportal_JSON_Mapper {
|
|||
projectView.addSectionView(sectionView);
|
||||
}
|
||||
|
||||
LOG.debug("returning the projectView: " + projectView);
|
||||
return projectView;
|
||||
}
|
||||
|
||||
|
|
|
@ -363,6 +363,8 @@ body {
|
|||
|
||||
.dand-layer {
|
||||
width: 400px;
|
||||
border: 1px solid #ccc !important;
|
||||
padding: 5px 0px;
|
||||
}
|
||||
|
||||
.range-slider {
|
||||
|
|
Loading…
Reference in New Issue