From c36754a7b3f6869cc87516848630690fa49eb259 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Wed, 10 Nov 2021 15:01:11 +0100 Subject: [PATCH 01/14] replaced * with - --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 841bfca..e3c32bf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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). + +## [v2.1.0-SNAPSHOT] - 2021-11-10 + +#### Enhancements + +- [#22370] Use a max-height for preview image shown in the pop-up + ## [v2.0.1] - 2021-11-10 #### Fixes -- 2.17.1 From 143fed7c79fe2cb503f549f53619de830238d2a0 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Thu, 11 Nov 2021 16:32:49 +0100 Subject: [PATCH 02/14] moved to gwt-ol3 v8.1.0-gwt2_9. Implementing Map credits (it is buggy in the gwt-ol3) --- .classpath | 6 +- .../com.gwtplugins.gdt.eclipse.core.prefs | 2 +- .settings/org.eclipse.wst.common.component | 44 ++++--- CHANGELOG.md | 1 + pom.xml | 4 +- .../client/GeoportalDataViewer.java | 11 ++ .../client/OLMapManager.java | 1 - .../client/gis/MapUtils.java | 5 + .../client/gis/OpenLayerOSM.java | 93 +++++++++++---- .../client/ui/GeonaDataViewMainPanel.java | 84 ++++++++------ .../client/ui/GeonaDataViewMainPanel.ui.xml | 5 +- .../shared/gis/BaseMapLayer.java | 109 ++++++++++++++++++ src/main/webapp/GeoportalDataViewer.css | 15 +++ 13 files changed, 297 insertions(+), 83 deletions(-) create mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/gis/BaseMapLayer.java diff --git a/.classpath b/.classpath index 1b3eb3f..3f84059 100644 --- a/.classpath +++ b/.classpath @@ -1,12 +1,12 @@ - + - + @@ -35,5 +35,5 @@ - + diff --git a/.settings/com.gwtplugins.gdt.eclipse.core.prefs b/.settings/com.gwtplugins.gdt.eclipse.core.prefs index aaa6c87..4c65c64 100644 --- a/.settings/com.gwtplugins.gdt.eclipse.core.prefs +++ b/.settings/com.gwtplugins.gdt.eclipse.core.prefs @@ -1,4 +1,4 @@ eclipse.preferences.version=1 -lastWarOutDir=/home/francescomangiacrapa/git/geoportal-data-viewer-app/target/geoportal-data-viewer-app-2.0.0 +lastWarOutDir=/home/francescomangiacrapa/git/geoportal-data-viewer-app/target/geoportal-data-viewer-app-2.1.0-SNAPSHOT warSrcDir=src/main/webapp warSrcDirIsOutput=false diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component index 66ff2c7..72174ae 100644 --- a/.settings/org.eclipse.wst.common.component +++ b/.settings/org.eclipse.wst.common.component @@ -1,21 +1,31 @@ - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/CHANGELOG.md b/CHANGELOG.md index e3c32bf..58dcb6d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm #### Enhancements - [#22370] Use a max-height for preview image shown in the pop-up +- Moved to gwt-ol3 v8.1.0-gwt2_9 ## [v2.0.1] - 2021-11-10 diff --git a/pom.xml b/pom.xml index 4b017dc..eccb30a 100644 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,7 @@ org.gcube.portlets.user geoportal-data-viewer-app war - 2.0.1 + 2.1.0-SNAPSHOT GeoPortal Data Viewer App The GeoPortal Data Viewer App is an application to access, discovery and navigate the GeoNa products by a Web-Map Interface @@ -122,7 +122,7 @@ com.github.tdesjardins gwt-ol3 - 8.0.0-gwt2_9 + 8.1.0-gwt2_9 com.github.gwtbootstrap diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewer.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewer.java index d0ddc0b..301bb46 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewer.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewer.java @@ -43,6 +43,7 @@ import com.google.gwt.event.shared.HandlerManager; import com.google.gwt.user.client.Timer; import com.google.gwt.user.client.Window; import com.google.gwt.user.client.rpc.AsyncCallback; +import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.RootPanel; import ol.Coordinate; @@ -105,6 +106,16 @@ public class GeoportalDataViewer implements EntryPoint { layerManager.getLayerManagerBus()); layerManager.setOlMap(olMapMng.getOLOSMMap()); mainPanel.setMap(olMapMng.getOLOSMMap()); + + + String attributionHTML = "
" + +olMapMng.getOLOSMMap().getMapAttribution()+ + "
"; + + + RootPanel.get(APP_DIV).add(new HTML(attributionHTML)); + + //mainPanel.setMapAttribution(olMapMng.getOLOSMMap().getMapAttribution()); updateSize(); ScriptInjector.fromUrl("//cdnjs.cloudflare.com/ajax/libs/nanogallery2/3.0.5/jquery.nanogallery2.min.js") .setWindow(ScriptInjector.TOP_WINDOW).inject(); diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/OLMapManager.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/OLMapManager.java index ed15837..a379883 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/OLMapManager.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/OLMapManager.java @@ -39,7 +39,6 @@ public class OLMapManager { public static final int QUERY_MIN_ZOOM_LEVEL = 13; public static final Double LAYER_DETAIL_MIN_RESOLUTION = 0.01; public static final Double LAYER_DETAIL_MAX_RESOLUTION = 18.5; - /** * Instantiates a new OL map manager. diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/MapUtils.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/MapUtils.java index 15ccd71..08406ff 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/MapUtils.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/MapUtils.java @@ -2,6 +2,7 @@ package org.gcube.portlets.user.geoportaldataviewer.client.gis; import ol.Collection; import ol.Coordinate; +import ol.control.Attribution; import ol.control.Control; import ol.control.FullScreen; import ol.control.MousePosition; @@ -32,6 +33,10 @@ public final class MapUtils { MousePosition mousePosition = new MousePosition(); mousePosition.setCoordinateFormat(Coordinate.createStringXY(5)); controls.push(mousePosition); + + Attribution attribution = new Attribution(); + attribution.setCollapsed(true); + controls.push(attribution); //controls.push(new ZoomToExtent()); } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/OpenLayerOSM.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/OpenLayerOSM.java index 4971b9d..7b5c71a 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/OpenLayerOSM.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/OpenLayerOSM.java @@ -8,6 +8,7 @@ import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerCon import org.gcube.portlets.user.geoportaldataviewer.client.events.AddedLayerToMapEvent; import org.gcube.portlets.user.geoportaldataviewer.client.events.AddedLayerToMapEvent.LAYER_TYPE; import org.gcube.portlets.user.geoportaldataviewer.client.events.DoActionOnDetailLayersEvent.SwapLayer; +import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BaseMapLayer; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerItem; import com.google.gwt.core.client.GWT; @@ -35,7 +36,6 @@ import ol.OverlayOptions; import ol.Size; import ol.View; import ol.ViewOptions; -import ol.control.Attribution; import ol.event.EventListener; import ol.geom.Geometry; import ol.interaction.Draw; @@ -47,6 +47,7 @@ import ol.interaction.KeyboardPan; import ol.interaction.KeyboardZoom; import ol.layer.Base; import ol.layer.Image; +import ol.layer.Layer; import ol.layer.LayerOptions; import ol.layer.Tile; import ol.layer.VectorLayerOptions; @@ -58,6 +59,7 @@ import ol.source.ImageWmsParams; import ol.source.Osm; import ol.source.Source; import ol.source.Vector; +import ol.source.Xyz; import ol.source.XyzOptions; /** @@ -138,6 +140,10 @@ public abstract class OpenLayerOSM { private LinkedHashMap wmsLayerMap; + private Layer baseLayerTile; + + private String mapAttribution; + /** * Instantiates a new open layer OSM. * @@ -156,16 +162,6 @@ public abstract class OpenLayerOSM { wmsDetailsLayerZIndex[i] = 1000 + i; } - // create a OSM-layer - XyzOptions xyzOptions = OLFactory.createOptions(); -// osmSourceOptions.setCrossOrigin("Anonymous"); -// osmSourceOptions.setTileLoadFunction(null); - - Osm osmSource = new Osm(xyzOptions); - LayerOptions osmLayerOptions = OLFactory.createOptions(); - osmLayerOptions.setSource(osmSource); - - Tile osmLayer = new Tile(osmLayerOptions); // create a projection projectionOptions.setCode(MAP_PROJECTION.EPSG_3857.getName()); projectionOptions.setUnits("m"); @@ -184,25 +180,72 @@ public abstract class OpenLayerOSM { map = new Map(mapOptions); - map.addLayer(osmLayer); + //map.addLayer(baseLayerTile); // map.addLayer(tileDebugLayer); // add some controls map.addControl(OLFactory.createScaleLine()); MapUtils.addDefaultControls(map.getControls()); - Attribution attribution = new Attribution(); - attribution.setCollapsed(true); - map.addControl(attribution); - // add some interactions map.addInteraction(new KeyboardPan()); map.addInteraction(new KeyboardZoom()); + + + String attribution = "© Mapbox © OpenStreetMap Improve this map"; + BaseMapLayer baseLayer = new BaseMapLayer( + "https://{a-d}.tiles.mapbox.com/v4/mapbox.satellite/{z}/{x}/{y}.png?access_token=pk.eyJ1IjoiZDRzY2llbmNlIiwiYSI6ImNpcW1nZjE4MDAwMXNod25rdHJsemRoNTQifQ.YPNkNLb8EzjThpvJl1tg4w", + attribution, BaseMapLayer.OL_BASE_MAP.MAPBOX); + + //applying base map + changeBaseMap(baseLayer); bindEvents(); } + public void changeBaseMap(BaseMapLayer baseLayer) { + + BaseMapLayer.OL_BASE_MAP baseMap = baseLayer.getType() == null ? BaseMapLayer.OL_BASE_MAP.OSM + : baseLayer.getType(); + this.mapAttribution = baseLayer.getAttribution(); + + try { + if (baseLayerTile != null) + map.removeLayer(baseLayerTile); + } catch (Exception e) { + // TODO: handle exception + } + + switch (baseMap) { + case OSM: + XyzOptions xyzOptions = OLFactory.createOptions(); + Osm osmSource = new Osm(xyzOptions); + LayerOptions layerOptions = OLFactory.createOptions(); + layerOptions.setSource(osmSource); + baseLayerTile = new Tile(layerOptions); + + break; + case MAPBOX: + case OTHER: + + XyzOptions xyzOptions2 = OLFactory.createOptions(); + Xyz xyz = new Xyz(xyzOptions2); + xyz.setAttributions(mapAttribution); + xyz.setUrl(baseLayer.getUrl()); + LayerOptions layerOptions2 = OLFactory.createOptions(); + layerOptions2.setSource(xyz); + baseLayerTile = new Tile(layerOptions2); + + break; + } + + // map == null at init time + if (map != null) + map.addLayer(baseLayerTile); + + } + /** * Bind events. */ @@ -830,15 +873,15 @@ public abstract class OpenLayerOSM { Image layer1 = wmsDetailsLayerMap.get(layerSource); Image layer2 = wmsDetailsLayerMap.get(layerTarget); - int zIndexS = swapLSource.getPosition()+1; - int zIndexT = swapLTarget.getPosition()+1; - GWT.log("new zindex source: "+zIndexS+", new zTarget: "+zIndexT); + int zIndexS = swapLSource.getPosition() + 1; + int zIndexT = swapLTarget.getPosition() + 1; + GWT.log("new zindex source: " + zIndexS + ", new zTarget: " + zIndexT); layer1.setZIndex(zIndexT); layer2.setZIndex(zIndexS); - - GWT.log("layer1 source: "+layerSource+", new zIndex: "+layer1.getZIndex()); - GWT.log("layer1 target: "+layerTarget+", new zIndex: "+layer2.getZIndex()); - + + GWT.log("layer1 source: " + layerSource + ", new zIndex: " + layer1.getZIndex()); + GWT.log("layer1 target: " + layerTarget + ", new zIndex: " + layer2.getZIndex()); + } /** @@ -852,4 +895,8 @@ public abstract class OpenLayerOSM { return map.get((map.keySet().toArray())[index]); } + public String getMapAttribution() { + return mapAttribution; + } + } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/GeonaDataViewMainPanel.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/GeonaDataViewMainPanel.java index df0ddfa..c8cd6f5 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/GeonaDataViewMainPanel.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/GeonaDataViewMainPanel.java @@ -12,6 +12,7 @@ import org.gcube.portlets.user.geoportaldataviewer.client.ui.map.ExtentMapUtil.L import com.github.gwtbootstrap.client.ui.Button; import com.github.gwtbootstrap.client.ui.NavLink; +import com.github.gwtbootstrap.client.ui.Paragraph; import com.github.gwtbootstrap.client.ui.constants.IconType; import com.google.gwt.core.client.GWT; import com.google.gwt.dom.client.Style.Unit; @@ -25,6 +26,7 @@ import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.FlowPanel; import com.google.gwt.user.client.ui.HTMLPanel; import com.google.gwt.user.client.ui.Image; +import com.google.gwt.user.client.ui.Label; import com.google.gwt.user.client.ui.ScrollPanel; import com.google.gwt.user.client.ui.Widget; @@ -69,7 +71,7 @@ public class GeonaDataViewMainPanel extends Composite { @UiField Button extentToItaly; - + @UiField Button extentToEarth; @@ -79,6 +81,9 @@ public class GeonaDataViewMainPanel extends Composite { @UiField ScrollPanel overlayLayersPanel; + @UiField + HTMLPanel panelAttribution; + private MapPanel mapPanel; private OpenLayerOSM map; @@ -102,39 +107,39 @@ public class GeonaDataViewMainPanel extends Composite { dataPointSelection.setIcon(IconType.SCREENSHOT); dataBoxSelection.setIcon(IconType.BOOKMARK); removeQuery.setIcon(IconType.REMOVE); - + Image italyImg = new Image(Images.ICONS.italyIcon()); italyImg.getElement().getStyle().setPaddingLeft(20, Unit.PX); extentToItaly.getElement().appendChild(italyImg.getElement()); extentToItaly.setWidth("140px"); - + Image worldImg = new Image(Images.ICONS.worldIcon()); worldImg.getElement().getStyle().setPaddingLeft(20, Unit.PX); extentToEarth.getElement().appendChild(worldImg.getElement()); extentToEarth.setWidth("140px"); - - //layersDDB.setToggle(true); + + // layersDDB.setToggle(true); bindEvents(); } private void bindEvents() { - + layersDDB.addClickHandler(new ClickHandler() { - + @Override public void onClick(ClickEvent event) { - + GWT.log("layersDDB clicked"); - - if(overlayLayersPanel.isVisible()) { + + if (overlayLayersPanel.isVisible()) { overlayLayersPanel.setVisible(false); - }else { + } else { overlayLayersPanel.setVisible(true); } } }); - + } /** @@ -146,15 +151,15 @@ public class GeonaDataViewMainPanel extends Composite { String toH = height + "px"; mapPanel.setMapHeight(height); detailsPanel.setHeight(toH); - + setOverlayPanelMaxHeight(); } - + private void setOverlayPanelMaxHeight() { - - String overlMH = mapPanel.getOffsetHeight()-130+"px"; - GWT.log("overlayLayersPanel maxHeight: "+overlMH); + + String overlMH = mapPanel.getOffsetHeight() - 130 + "px"; + GWT.log("overlayLayersPanel maxHeight: " + overlMH); overlayLayersPanel.getElement().getStyle().setProperty("maxHeight", overlMH); } @@ -227,7 +232,7 @@ public class GeonaDataViewMainPanel extends Composite { } }); - + extentToEarth.addClickHandler(new ClickHandler() { @Override @@ -286,37 +291,46 @@ public class GeonaDataViewMainPanel extends Composite { */ public void showOverlayLayers(FlowPanel panel) { GWT.log("showOverlayLayers"); - //layersDDB.setVisible(true); + // layersDDB.setVisible(true); overlayLayersPanel.setVisible(true); overlayLayersPanel.clear(); - + setOverlayPanelMaxHeight(); overlayLayersPanel.add(panel); - //layersDDBClickEvent(); + // layersDDBClickEvent(); } - + private void layersDDBClickEvent() { - layersDDB.fireEvent( new GwtEvent() { - @Override - public com.google.gwt.event.shared.GwtEvent.Type getAssociatedType() { - return ClickEvent.getType(); - } - @Override - protected void dispatch(ClickHandler handler) { - handler.onClick(null); - } - }); + layersDDB.fireEvent(new GwtEvent() { + @Override + public com.google.gwt.event.shared.GwtEvent.Type getAssociatedType() { + return ClickEvent.getType(); + } + + @Override + protected void dispatch(ClickHandler handler) { + handler.onClick(null); + } + }); } - + /** * Hide overlay layers. */ public void hideOverlayLayers() { GWT.log("hideOverlayLayers"); overlayLayersPanel.clear(); - //layersDDB.setVisible(false); + // layersDDB.setVisible(false); overlayLayersPanel.setVisible(false); - //layersDDBClickEvent(); + // layersDDBClickEvent(); + } + + public void setMapAttribution(String attribution) { + panelAttribution.clear(); + Label label = new Label("Base Map Credits"); + Paragraph p = new Paragraph(attribution); + panelAttribution.add(label); + panelAttribution.add(p); } } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/GeonaDataViewMainPanel.ui.xml b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/GeonaDataViewMainPanel.ui.xml index 3052b86..5701faf 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/GeonaDataViewMainPanel.ui.xml +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/GeonaDataViewMainPanel.ui.xml @@ -17,7 +17,7 @@ - Map Interactions @@ -30,6 +30,9 @@ Click on the Points shown on the Map to view their features + + Date: Fri, 12 Nov 2021 12:37:15 +0100 Subject: [PATCH 03/14] implemented Base Map layers switching --- .../client/GeoportalDataViewer.java | 126 ++++++++++++------ .../client/GeoportalDataViewerService.java | 3 + .../GeoportalDataViewerServiceAsync.java | 3 + .../client/OLMapManager.java | 11 +- .../client/events/ChangeMapLayerEvent.java | 57 ++++++++ .../events/ChangeMapLayerEventHandler.java | 20 +++ .../client/gis/OpenLayerOSM.java | 44 +++--- .../client/ui/GeonaDataViewMainPanel.java | 49 ++++++- .../client/ui/GeonaDataViewMainPanel.ui.xml | 6 +- .../GeoportalDataViewerServiceImpl.java | 27 ++++ .../shared/gis/BaseMapLayer.java | 68 ++++------ src/main/webapp/GeoportalDataViewer.css | 18 ++- 12 files changed, 323 insertions(+), 109 deletions(-) create mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/events/ChangeMapLayerEvent.java create mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/events/ChangeMapLayerEventHandler.java diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewer.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewer.java index 301bb46..01d5a34 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewer.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewer.java @@ -1,6 +1,7 @@ package org.gcube.portlets.user.geoportaldataviewer.client; import java.util.Iterator; +import java.util.List; import org.gcube.application.geoportalcommon.shared.GeoNaDataViewerProfile; import org.gcube.application.geoportalcommon.shared.GeoNaItemRef; @@ -12,6 +13,8 @@ import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerCon import org.gcube.portlets.user.geoportaldataviewer.client.events.AddedLayerToMapEvent; import org.gcube.portlets.user.geoportaldataviewer.client.events.AddedLayerToMapEvent.LAYER_TYPE; import org.gcube.portlets.user.geoportaldataviewer.client.events.AddedLayerToMapEventHandler; +import org.gcube.portlets.user.geoportaldataviewer.client.events.ChangeMapLayerEvent; +import org.gcube.portlets.user.geoportaldataviewer.client.events.ChangeMapLayerEventHandler; import org.gcube.portlets.user.geoportaldataviewer.client.events.ClosedViewDetailsEvent; import org.gcube.portlets.user.geoportaldataviewer.client.events.ClosedViewDetailsEventHandler; import org.gcube.portlets.user.geoportaldataviewer.client.events.DoActionOnDetailLayersEvent; @@ -29,7 +32,9 @@ import org.gcube.portlets.user.geoportaldataviewer.client.gis.ExtentWrapped; import org.gcube.portlets.user.geoportaldataviewer.client.gis.MapUtils; import org.gcube.portlets.user.geoportaldataviewer.client.gis.OpenLayerOSM; import org.gcube.portlets.user.geoportaldataviewer.client.ui.GeonaDataViewMainPanel; +import org.gcube.portlets.user.geoportaldataviewer.client.util.LoaderIcon; import org.gcube.portlets.user.geoportaldataviewer.client.util.URLUtil; +import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BaseMapLayer; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.GeoQuery; import com.google.gwt.core.client.EntryPoint; @@ -89,11 +94,31 @@ public class GeoportalDataViewer implements EntryPoint { private OLMapManager olMapMng = null; int attempt = 0; + + + private LoaderIcon loaderApp = new LoaderIcon("Loading application...."); + + + private HTML attributionDiv = new HTML(); /** * This is the entry point method. */ public void onModuleLoad() { + + loaderApp.getElement().getStyle().setZIndex(100); + + paramWmsRequest = Window.Location.getParameter(GeoportalDataViewerConstants.GET_WMS_PARAMETER); + paramGeonaItemType = Window.Location.getParameter(GeoportalDataViewerConstants.GET_GEONA_ITEM_TYPE); + paramGeonaItemID = Window.Location.getParameter(GeoportalDataViewerConstants.GET_GEONA_ITEM_ID); + paramLayerTitle = Window.Location.getParameter(GeoportalDataViewerConstants.GET_LAYER_TITLE); + GWT.log(GeoportalDataViewerConstants.GET_WMS_PARAMETER + " = " + paramWmsRequest); + GWT.log(GeoportalDataViewerConstants.GET_GEONA_ITEM_TYPE + " = " + paramGeonaItemType); + GWT.log(GeoportalDataViewerConstants.GET_GEONA_ITEM_ID + " = " + paramGeonaItemID); + GWT.log(GeoportalDataViewerConstants.GET_LAYER_TITLE + " = " + paramLayerTitle); + + RootPanel.get(APP_DIV).add(loaderApp); + mainPanel = new GeonaDataViewMainPanel(applicationBus, getClientHeight()); RootPanel.get(APP_DIV).add(mainPanel); @@ -102,23 +127,38 @@ public class GeoportalDataViewer implements EntryPoint { @Override public void execute() { - olMapMng = new OLMapManager(mainPanel.getMapPanel().getElement().getId(), - layerManager.getLayerManagerBus()); - layerManager.setOlMap(olMapMng.getOLOSMMap()); - mainPanel.setMap(olMapMng.getOLOSMMap()); - - - String attributionHTML = "
" - +olMapMng.getOLOSMMap().getMapAttribution()+ - "
"; - + //LOADING THE BASE MAP LAYERS + GeoportalDataViewerServiceAsync.Util.getInstance().getListBaseLayers(new AsyncCallback>() { - RootPanel.get(APP_DIV).add(new HTML(attributionHTML)); + @Override + public void onFailure(Throwable caught) { + RootPanel.get(APP_DIV).remove(loaderApp); + Window.alert("Error occurred on instancing the GeoPortale Viewer. Please, contact the support"); + } + + @Override + public void onSuccess(List listBaseMapLayers) { + RootPanel.get(APP_DIV).remove(loaderApp); + loadGeonaDataViewerProfile(); + mainPanel.setBaseLayers(listBaseMapLayers); + + BaseMapLayer firstBaseLayer = listBaseMapLayers.get(0); + //Passing the first base map layer that will be applied as first base layer + olMapMng = new OLMapManager(mainPanel.getMapPanel().getElement().getId(), + layerManager.getLayerManagerBus(), firstBaseLayer); + layerManager.setOlMap(olMapMng.getOLOSMMap()); + mainPanel.setMap(olMapMng.getOLOSMMap()); + + //mainPanel.setMapAttribution(olMapMng.getOLOSMMap().getMapAttribution()); + updateSize(); + ScriptInjector.fromUrl("//cdnjs.cloudflare.com/ajax/libs/nanogallery2/3.0.5/jquery.nanogallery2.min.js") + .setWindow(ScriptInjector.TOP_WINDOW).inject(); + + } + + + }); - //mainPanel.setMapAttribution(olMapMng.getOLOSMMap().getMapAttribution()); - updateSize(); - ScriptInjector.fromUrl("//cdnjs.cloudflare.com/ajax/libs/nanogallery2/3.0.5/jquery.nanogallery2.min.js") - .setWindow(ScriptInjector.TOP_WINDOW).inject(); } }); @@ -129,28 +169,15 @@ public class GeoportalDataViewer implements EntryPoint { } }); - paramWmsRequest = Window.Location.getParameter(GeoportalDataViewerConstants.GET_WMS_PARAMETER); - paramGeonaItemType = Window.Location.getParameter(GeoportalDataViewerConstants.GET_GEONA_ITEM_TYPE); - // paramUUID = - // Window.Location.getParameter(GeoportalDataViewerConstants.GET_UUID_PARAMETER); - paramGeonaItemID = Window.Location.getParameter(GeoportalDataViewerConstants.GET_GEONA_ITEM_ID); - paramLayerTitle = Window.Location.getParameter(GeoportalDataViewerConstants.GET_LAYER_TITLE); - GWT.log(GeoportalDataViewerConstants.GET_WMS_PARAMETER + " = " + paramWmsRequest); - GWT.log(GeoportalDataViewerConstants.GET_GEONA_ITEM_TYPE + " = " + paramGeonaItemType); - GWT.log(GeoportalDataViewerConstants.GET_GEONA_ITEM_ID + " = " + paramGeonaItemID); - // GWT.log(GeoportalDataViewerConstants.GET_UUID_PARAMETER + " = " + paramUUID); - GWT.log(GeoportalDataViewerConstants.GET_LAYER_TITLE + " = " + paramLayerTitle); - - // VALIDATING THE LONG FORMAT FOR GID -// try { -// if (paramGeonaItemID != null) -// Long.parseLong(paramGeonaItemID); -// } catch (Exception e) { -// Window.alert("Bad format for parameter " + GeoportalDataViewerConstants.GET_GEONA_ITEM_ID -// + ". It must be a Long"); -// paramGeonaItemID = null; -// } + + bindEvents(); + + RootPanel.get(APP_DIV).add(attributionDiv); + } + + private void loadGeonaDataViewerProfile() { + Scheduler.get().scheduleDeferred(new ScheduledCommand() { @Override @@ -206,8 +233,7 @@ public class GeoportalDataViewer implements EntryPoint { }); } }); - - bindEvents(); + } /** @@ -410,6 +436,30 @@ public class GeoportalDataViewer implements EntryPoint { } }); + + + applicationBus.addHandler(ChangeMapLayerEvent.TYPE, new ChangeMapLayerEventHandler() { + + @Override + public void onChangeBaseMapLayer(ChangeMapLayerEvent changeMapLayerEvent) { + + BaseMapLayer baseLayer = changeMapLayerEvent.getBaseMapLayer(); + + if (baseLayer == null) + return; + + String attributionHTML = "
" + + baseLayer.getAttribution() + "
"; + olMapMng.getOLOSMMap().changeBaseMap(baseLayer); + + //THE OSM Contributors are automatically added by gwt-ol, other ones not. + if(!baseLayer.getType().equals(BaseMapLayer.OL_BASE_MAP.OSM)) { + attributionDiv.setHTML(attributionHTML); + }else + attributionDiv.setHTML(""); + + } + }); } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerService.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerService.java index b4f9611..b48828a 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerService.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerService.java @@ -9,6 +9,7 @@ import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; import org.gcube.application.geoportalcommon.shared.products.model.LayerConcessioneDV; import org.gcube.application.geoportalcommon.shared.products.model.UploadedImageDV; import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaSpatialQueryResult; +import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BaseMapLayer; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerObject; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wms.GeoInformationForWMSRequest; @@ -124,5 +125,7 @@ public interface GeoportalDataViewerService extends RemoteService { List getWFSFeatures(List layerObjects, String mapSrsName, BoundsMap selectBBOX, int maxWFSFeature, double zoomLevel); + List getListBaseLayers(); + } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerServiceAsync.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerServiceAsync.java index fd50869..462a52e 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerServiceAsync.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerServiceAsync.java @@ -9,6 +9,7 @@ import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; import org.gcube.application.geoportalcommon.shared.products.model.LayerConcessioneDV; import org.gcube.application.geoportalcommon.shared.products.model.UploadedImageDV; import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaSpatialQueryResult; +import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BaseMapLayer; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerObject; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wms.GeoInformationForWMSRequest; @@ -58,4 +59,6 @@ public interface GeoportalDataViewerServiceAsync { void getWFSFeatures(List layerObjects, String mapSrsName, BoundsMap selectBBOX, int maxWFSFeature, double zoomLevel, AsyncCallback> callback); + void getListBaseLayers(AsyncCallback> callback); + } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/OLMapManager.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/OLMapManager.java index a379883..2fc6d15 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/OLMapManager.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/OLMapManager.java @@ -10,6 +10,7 @@ import org.gcube.portlets.user.geoportaldataviewer.client.gis.OpenLayerOSM; import org.gcube.portlets.user.geoportaldataviewer.client.ui.map.ExtentMapUtil; import org.gcube.portlets.user.geoportaldataviewer.client.ui.map.ExtentMapUtil.Location; import org.gcube.portlets.user.geoportaldataviewer.client.ui.map.ExtentMapUtil.PLACE; +import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BaseMapLayer; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.GeoQuery; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.GeoQuery.TYPE; @@ -45,19 +46,21 @@ public class OLMapManager { * * @param targetId the target id * @param layerManagerBus the layer manager bus + * @param baseMapLayer the base map layer */ - public OLMapManager(String targetId, HandlerManager layerManagerBus) { + public OLMapManager(String targetId, HandlerManager layerManagerBus, BaseMapLayer baseMapLayer) { this.targetId = targetId; this.layerManagerBus = layerManagerBus; - instanceOLMap(); + instanceOLMap(baseMapLayer); } /** * Instance OL map. + * @param baseMapLayer */ - public void instanceOLMap() { + public void instanceOLMap(BaseMapLayer baseMapLayer) { - olMap = new OpenLayerOSM(targetId, layerManagerBus) { + olMap = new OpenLayerOSM(targetId, layerManagerBus, baseMapLayer) { @Override public void clickListener(MapBrowserEvent event) { diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/events/ChangeMapLayerEvent.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/events/ChangeMapLayerEvent.java new file mode 100644 index 0000000..2ace889 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/events/ChangeMapLayerEvent.java @@ -0,0 +1,57 @@ +package org.gcube.portlets.user.geoportaldataviewer.client.events; + +import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BaseMapLayer; + +import com.google.gwt.event.shared.GwtEvent; + +/** + * The Class ChangeMapLayerEvent. + * + * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it + * + * Nov 12, 2021 + */ +public class ChangeMapLayerEvent extends GwtEvent { + public static Type TYPE = new Type(); + private BaseMapLayer baseMapLayer; + + /** + * Instantiates a new change map layer event. + * + * @param baseMapLayer the base map layer + */ + public ChangeMapLayerEvent(BaseMapLayer baseMapLayer) { + this.baseMapLayer = baseMapLayer; + + } + + /** + * Gets the associated type. + * + * @return the associated type + */ + @Override + public Type getAssociatedType() { + return TYPE; + } + + /** + * Dispatch. + * + * @param handler the handler + */ + @Override + protected void dispatch(ChangeMapLayerEventHandler handler) { + handler.onChangeBaseMapLayer(this); + + } + + /** + * Gets the base map layer. + * + * @return the base map layer + */ + public BaseMapLayer getBaseMapLayer() { + return baseMapLayer; + } +} \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/events/ChangeMapLayerEventHandler.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/events/ChangeMapLayerEventHandler.java new file mode 100644 index 0000000..143eac0 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/events/ChangeMapLayerEventHandler.java @@ -0,0 +1,20 @@ +package org.gcube.portlets.user.geoportaldataviewer.client.events; + +import com.google.gwt.event.shared.EventHandler; + +/** + * The Interface ChangeMapLayerEventHandler. + * + * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it + * + * Nov 12, 2021 + */ +public interface ChangeMapLayerEventHandler extends EventHandler { + + /** + * On change base map layer. + * + * @param changeMapLayerEvent the change map layer event + */ + void onChangeBaseMapLayer(ChangeMapLayerEvent changeMapLayerEvent); +} diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/OpenLayerOSM.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/OpenLayerOSM.java index 7b5c71a..cbe9b44 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/OpenLayerOSM.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/OpenLayerOSM.java @@ -142,20 +142,15 @@ public abstract class OpenLayerOSM { private Layer baseLayerTile; - private String mapAttribution; /** * Instantiates a new open layer OSM. * * @param divTargetId the div target id - * @param eventBus the event bus + * @param eventBus the event bus + * @param baseLayer the base layer */ - /* - * (non-Javadoc) - * - * @see de.desjardins.ol3.demo.client.example.Example#show() - */ - public OpenLayerOSM(String divTargetId, HandlerManager eventBus) { + public OpenLayerOSM(String divTargetId, HandlerManager eventBus, BaseMapLayer baseLayer) { this.eventBus = eventBus; for (int i = 0; i < 100; i++) { @@ -191,12 +186,6 @@ public abstract class OpenLayerOSM { map.addInteraction(new KeyboardPan()); map.addInteraction(new KeyboardZoom()); - - String attribution = "© Mapbox © OpenStreetMap Improve this map"; - BaseMapLayer baseLayer = new BaseMapLayer( - "https://{a-d}.tiles.mapbox.com/v4/mapbox.satellite/{z}/{x}/{y}.png?access_token=pk.eyJ1IjoiZDRzY2llbmNlIiwiYSI6ImNpcW1nZjE4MDAwMXNod25rdHJsemRoNTQifQ.YPNkNLb8EzjThpvJl1tg4w", - attribution, BaseMapLayer.OL_BASE_MAP.MAPBOX); - //applying base map changeBaseMap(baseLayer); @@ -204,11 +193,15 @@ public abstract class OpenLayerOSM { } + /** + * Change base map. + * + * @param baseLayer the base layer + */ public void changeBaseMap(BaseMapLayer baseLayer) { BaseMapLayer.OL_BASE_MAP baseMap = baseLayer.getType() == null ? BaseMapLayer.OL_BASE_MAP.OSM : baseLayer.getType(); - this.mapAttribution = baseLayer.getAttribution(); try { if (baseLayerTile != null) @@ -221,8 +214,12 @@ public abstract class OpenLayerOSM { case OSM: XyzOptions xyzOptions = OLFactory.createOptions(); Osm osmSource = new Osm(xyzOptions); + osmSource.setUrl(baseLayer.getUrl()); + //setAttributions is buggy + //osmSource.setAttributions(baseLayer.getAttribution()); LayerOptions layerOptions = OLFactory.createOptions(); layerOptions.setSource(osmSource); + layerOptions.setZIndex(0); baseLayerTile = new Tile(layerOptions); break; @@ -231,18 +228,23 @@ public abstract class OpenLayerOSM { XyzOptions xyzOptions2 = OLFactory.createOptions(); Xyz xyz = new Xyz(xyzOptions2); - xyz.setAttributions(mapAttribution); + //setAttributions is buggy + //xyz.setAttributions(baseLayer.getAttribution()); xyz.setUrl(baseLayer.getUrl()); + LayerOptions layerOptions2 = OLFactory.createOptions(); layerOptions2.setSource(xyz); + layerOptions2.setZIndex(0); baseLayerTile = new Tile(layerOptions2); + break; } // map == null at init time - if (map != null) + if (map != null) { map.addLayer(baseLayerTile); + } } @@ -863,8 +865,8 @@ public abstract class OpenLayerOSM { /** * Swap details layers. * - * @param layerSource the source index - * @param layerTarget the target index + * @param swapLSource the swap L source + * @param swapLTarget the swap L target */ public void swapDetailsLayers(SwapLayer swapLSource, SwapLayer swapLTarget) { @@ -895,8 +897,4 @@ public abstract class OpenLayerOSM { return map.get((map.keySet().toArray())[index]); } - public String getMapAttribution() { - return mapAttribution; - } - } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/GeonaDataViewMainPanel.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/GeonaDataViewMainPanel.java index c8cd6f5..0c74a2c 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/GeonaDataViewMainPanel.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/GeonaDataViewMainPanel.java @@ -1,14 +1,18 @@ package org.gcube.portlets.user.geoportaldataviewer.client.ui; +import java.util.List; + import org.gcube.application.geoportalcommon.shared.GeoNaItemRef; import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; import org.gcube.application.geoportalcommon.shared.products.model.RecordDV; import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants.MAP_PROJECTION; +import org.gcube.portlets.user.geoportaldataviewer.client.events.ChangeMapLayerEvent; import org.gcube.portlets.user.geoportaldataviewer.client.events.MapExtentToEvent; import org.gcube.portlets.user.geoportaldataviewer.client.gis.OpenLayerOSM; import org.gcube.portlets.user.geoportaldataviewer.client.resources.Images; import org.gcube.portlets.user.geoportaldataviewer.client.ui.map.ExtentMapUtil; import org.gcube.portlets.user.geoportaldataviewer.client.ui.map.ExtentMapUtil.Location; +import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BaseMapLayer; import com.github.gwtbootstrap.client.ui.Button; import com.github.gwtbootstrap.client.ui.NavLink; @@ -18,6 +22,8 @@ import com.google.gwt.core.client.GWT; import com.google.gwt.dom.client.Style.Unit; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; +import com.google.gwt.event.logical.shared.ValueChangeEvent; +import com.google.gwt.event.logical.shared.ValueChangeHandler; import com.google.gwt.event.shared.GwtEvent; import com.google.gwt.event.shared.HandlerManager; import com.google.gwt.uibinder.client.UiBinder; @@ -27,7 +33,9 @@ import com.google.gwt.user.client.ui.FlowPanel; import com.google.gwt.user.client.ui.HTMLPanel; import com.google.gwt.user.client.ui.Image; import com.google.gwt.user.client.ui.Label; +import com.google.gwt.user.client.ui.RadioButton; import com.google.gwt.user.client.ui.ScrollPanel; +import com.google.gwt.user.client.ui.SimplePanel; import com.google.gwt.user.client.ui.Widget; /** @@ -83,12 +91,17 @@ public class GeonaDataViewMainPanel extends Composite { @UiField HTMLPanel panelAttribution; + + @UiField + HTMLPanel panelBaseLayers; private MapPanel mapPanel; private OpenLayerOSM map; private HandlerManager applicationBus; + + /** * Instantiates a new geona data view main panel. @@ -122,7 +135,7 @@ public class GeonaDataViewMainPanel extends Composite { bindEvents(); } - + private void bindEvents() { layersDDB.addClickHandler(new ClickHandler() { @@ -332,5 +345,39 @@ public class GeonaDataViewMainPanel extends Composite { panelAttribution.add(label); panelAttribution.add(p); } + + public void setBaseLayers(List listBaseLayers) { + + if(listBaseLayers==null) + return; + + int i = 0; + + for (BaseMapLayer baseMapLayer : listBaseLayers) { + + RadioButton radio = new RadioButton("base-layer"); + radio.setText(baseMapLayer.getName()); + if(i==0) { + radio.setValue(true, true); + } + + radio.addValueChangeHandler(new ValueChangeHandler() { + + @Override + public void onValueChange(ValueChangeEvent event) { + applicationBus.fireEvent(new ChangeMapLayerEvent(baseMapLayer)); + + } + }); + + SimplePanel sp = new SimplePanel(radio); + sp.getElement().addClassName("form-inline"); + sp.getElement().addClassName("map-layers-radio"); + panelBaseLayers.add(sp); + i++; + } + + } + } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/GeonaDataViewMainPanel.ui.xml b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/GeonaDataViewMainPanel.ui.xml index 5701faf..8f70659 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/GeonaDataViewMainPanel.ui.xml +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/GeonaDataViewMainPanel.ui.xml @@ -16,6 +16,10 @@ + + + + @@ -31,7 +35,7 @@ Click on the Points shown on the Map to view their features + addStyleNames="info-interaction" visible="false"> diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/GeoportalDataViewerServiceImpl.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/GeoportalDataViewerServiceImpl.java index 708d003..de501bf 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/GeoportalDataViewerServiceImpl.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/GeoportalDataViewerServiceImpl.java @@ -34,6 +34,7 @@ import org.gcube.portlets.user.geoportaldataviewer.server.mongoservice.Concessio import org.gcube.portlets.user.geoportaldataviewer.server.mongoservice.accesspolicy.GeoNACheckAccessPolicy; import org.gcube.portlets.user.geoportaldataviewer.server.util.SessionUtil; import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaSpatialQueryResult; +import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BaseMapLayer; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerObject; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wfs.FeatureRow; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wms.GeoInformationForWMSRequest; @@ -660,5 +661,31 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme } } + + @Override + public List getListBaseLayers() { + + List listBL = new ArrayList(); + + // OSM + String attribution = "© OpenStreetMap"; + BaseMapLayer baseLayer = new BaseMapLayer("Open Street Map", "https://tile.openstreetmap.org/{z}/{x}/{y}.png", attribution, + BaseMapLayer.OL_BASE_MAP.OSM); + + listBL.add(baseLayer); + + + // MAPBOX + attribution = "© Mapbox © OpenStreetMap Improve this map"; + baseLayer = new BaseMapLayer("MapBox Satellite", + "https://{a-d}.tiles.mapbox.com/v4/mapbox.satellite/{z}/{x}/{y}.png?access_token=pk.eyJ1IjoiZDRzY2llbmNlIiwiYSI6ImNpcW1nZjE4MDAwMXNod25rdHJsemRoNTQifQ.YPNkNLb8EzjThpvJl1tg4w", + attribution, BaseMapLayer.OL_BASE_MAP.MAPBOX); + + listBL.add(baseLayer); + + + return listBL; + + } } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/gis/BaseMapLayer.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/gis/BaseMapLayer.java index 834fb5e..de0b773 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/gis/BaseMapLayer.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/gis/BaseMapLayer.java @@ -7,7 +7,7 @@ import java.io.Serializable; * * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it * - * Nov 11, 2021 + * Nov 11, 2021 */ public class BaseMapLayer implements Serializable { @@ -21,12 +21,13 @@ public class BaseMapLayer implements Serializable { * * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it * - * Nov 11, 2021 + * Nov 11, 2021 */ public static enum OL_BASE_MAP { OSM, MAPBOX, OTHER }; + private String name; private String url; private String attribution; private OL_BASE_MAP type; @@ -38,72 +39,59 @@ public class BaseMapLayer implements Serializable { } - /** - * Instantiates a new base map layer. - * - * @param url the url - * @param attribution the attribution - * @param type the type - */ - public BaseMapLayer(String url, String attribution, OL_BASE_MAP type) { + public BaseMapLayer(String name, String url, String attribution, OL_BASE_MAP type) { super(); + this.name = name; this.url = url; this.attribution = attribution; this.type = type; } - /** - * Gets the url. - * - * @return the url - */ + public String getName() { + return name; + } + public String getUrl() { return url; } - /** - * Gets the attribution. - * - * @return the attribution - */ public String getAttribution() { return attribution; } - /** - * Gets the type. - * - * @return the type - */ public OL_BASE_MAP getType() { return type; } - /** - * Sets the url. - * - * @param url the new url - */ + public void setName(String name) { + this.name = name; + } + public void setUrl(String url) { this.url = url; } - /** - * Sets the attribution. - * - * @param attribution the new attribution - */ public void setAttribution(String attribution) { this.attribution = attribution; } - /** - * Sets the type. - * - * @param type the new type - */ public void setType(OL_BASE_MAP type) { this.type = type; } + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("BaseMapLayer [name="); + builder.append(name); + builder.append(", url="); + builder.append(url); + builder.append(", attribution="); + builder.append(attribution); + builder.append(", type="); + builder.append(type); + builder.append("]"); + return builder.toString(); + } + } diff --git a/src/main/webapp/GeoportalDataViewer.css b/src/main/webapp/GeoportalDataViewer.css index 93cf4a8..59620a7 100644 --- a/src/main/webapp/GeoportalDataViewer.css +++ b/src/main/webapp/GeoportalDataViewer.css @@ -364,12 +364,26 @@ body { max-height: 25px; } -.map-attribution-container { +.map-credits-container { bottom: 0; right: 0; position: absolute; display: block; - margin: 10px 5px; + margin: 0px 0px; padding: 2px 4px; background: white; +} + +.map-layers-radio { + margin-left: 5px; +} + +.map-layers-radio input { + margin-top: 0 !important; + margin-left: 5px; +} + +.map-layers-radio label { + margin-left: 5px; + padding-top: 5px; } \ No newline at end of file -- 2.17.1 From db9ff853bca35e1242c7ed4b10ad31c1c34f89be Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Fri, 12 Nov 2021 14:48:12 +0100 Subject: [PATCH 04/14] Added Layer offset manager --- .../client/gis/LayerOrder.java | 51 +++++++++++++++++++ .../client/gis/OpenLayerOSM.java | 35 +++++++++---- 2 files changed, 77 insertions(+), 9 deletions(-) create mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/LayerOrder.java diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/LayerOrder.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/LayerOrder.java new file mode 100644 index 0000000..940f016 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/LayerOrder.java @@ -0,0 +1,51 @@ +package org.gcube.portlets.user.geoportaldataviewer.client.gis; + +import java.util.HashMap; + +/** + * The Class LayerOrder. + * + * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it + * + * Nov 12, 2021 + */ +public class LayerOrder { + + /** + * The Enum LAYER_TYPE. + * + * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it + * + * Nov 12, 2021 + */ + public static enum LAYER_TYPE { + BASE_MAP, BASE_WMS, WMS_DETAIL, VECTOR + } + + public static final HashMap LAYER_OFFSET = new HashMap(5); + + static { + + LAYER_OFFSET.put(LAYER_TYPE.BASE_MAP, 0); + LAYER_OFFSET.put(LAYER_TYPE.BASE_WMS, 70); + LAYER_OFFSET.put(LAYER_TYPE.WMS_DETAIL, 140); + LAYER_OFFSET.put(LAYER_TYPE.VECTOR, 210); + } + + /** + * Instantiates a new layer order. + */ + public LayerOrder() { + } + + /** + * Gets the offset. + * + * @param layerType the layer type + * @return the offset + */ + public Integer getOffset(LAYER_TYPE layerType) { + return LAYER_OFFSET.get(layerType); + } + +} diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/OpenLayerOSM.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/OpenLayerOSM.java index cbe9b44..fdc6711 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/OpenLayerOSM.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/OpenLayerOSM.java @@ -141,7 +141,9 @@ public abstract class OpenLayerOSM { private LinkedHashMap wmsLayerMap; private Layer baseLayerTile; - + + private LayerOrder layerOrder = new LayerOrder(); + /** * Instantiates a new open layer OSM. @@ -219,7 +221,8 @@ public abstract class OpenLayerOSM { //osmSource.setAttributions(baseLayer.getAttribution()); LayerOptions layerOptions = OLFactory.createOptions(); layerOptions.setSource(osmSource); - layerOptions.setZIndex(0); + int zIndex = layerOrder.getOffset(LayerOrder.LAYER_TYPE.BASE_MAP)+1; + layerOptions.setZIndex(zIndex); baseLayerTile = new Tile(layerOptions); break; @@ -234,11 +237,13 @@ public abstract class OpenLayerOSM { LayerOptions layerOptions2 = OLFactory.createOptions(); layerOptions2.setSource(xyz); - layerOptions2.setZIndex(0); + zIndex = layerOrder.getOffset(LayerOrder.LAYER_TYPE.BASE_MAP)+1; + layerOptions2.setZIndex(zIndex); baseLayerTile = new Tile(layerOptions2); break; + } // map == null at init time @@ -405,6 +410,8 @@ public abstract class OpenLayerOSM { LayerOptions layerOptions = OLFactory.createOptions(); layerOptions.setSource(imageWMSSource); + + // Settings MIN and MAX Resolution if (layerItem.getMinResolution() != null) { @@ -415,7 +422,8 @@ public abstract class OpenLayerOSM { } Image wmsLayer = new Image(layerOptions); - + int zIndex = layerOrder.getOffset(LayerOrder.LAYER_TYPE.BASE_WMS)+wmsLayerMap.size()+1; + wmsLayer.setZIndex(zIndex); // visibleLayerItems map.addLayer(wmsLayer); @@ -457,6 +465,9 @@ public abstract class OpenLayerOSM { LayerOptions layerOptions = OLFactory.createOptions(); layerOptions.setSource(imageWMSSource); + + + // Settings MIN and MAX Resolution if (layerItem.getMinResolution() != null) { layerOptions.setMinResolution(layerItem.getMinResolution()); @@ -466,7 +477,8 @@ public abstract class OpenLayerOSM { } Image wmsLayer = new Image(layerOptions); - wmsLayer.setZIndex(wmsDetailsLayerMap.size() + 1); + int zIndex = layerOrder.getOffset(LayerOrder.LAYER_TYPE.WMS_DETAIL)+wmsDetailsLayerMap.size() + 1; + wmsLayer.setZIndex(zIndex); map.addLayer(wmsLayer); wmsDetailsLayerMap.put(key, wmsLayer); @@ -523,9 +535,12 @@ public abstract class OpenLayerOSM { Vector vectorSource = OLFactory.createVectorSource(); vectorSource.addFeature(feature); vectorLayerOptions.setSource(vectorSource); - + ol.layer.Vector vector = OLFactory.createVector(vectorLayerOptions); - + + int zIndex = layerOrder.getOffset(LayerOrder.LAYER_TYPE.VECTOR)+1; + vector.setZIndex(zIndex); + map.addLayer(vector); } @@ -875,9 +890,11 @@ public abstract class OpenLayerOSM { Image layer1 = wmsDetailsLayerMap.get(layerSource); Image layer2 = wmsDetailsLayerMap.get(layerTarget); - int zIndexS = swapLSource.getPosition() + 1; - int zIndexT = swapLTarget.getPosition() + 1; + int zIndexOffset = layerOrder.getOffset(LayerOrder.LAYER_TYPE.WMS_DETAIL); + int zIndexS = swapLSource.getPosition() + zIndexOffset + 1; + int zIndexT = swapLTarget.getPosition() + zIndexOffset + 1; GWT.log("new zindex source: " + zIndexS + ", new zTarget: " + zIndexT); + layer1.setZIndex(zIndexT); layer2.setZIndex(zIndexS); -- 2.17.1 From 2846ba6e2fd4ab4caad617c680ca6da09f0ae88e Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Fri, 12 Nov 2021 14:54:54 +0100 Subject: [PATCH 05/14] refactored --- .../client/GeoportalDataViewer.java | 14 ++++++++------ .../client/LayerManager.java | 6 +++--- .../client/OLMapManager.java | 18 +++++++++++------- ...penLayerOSM.java => LightOpenLayerMap.java} | 15 ++++++++++----- .../{OpenLayerOSM.java => OpenLayerMap.java} | 12 +++--------- .../client/ui/GeonaDataViewMainPanel.java | 6 +++--- .../client/ui/map/MapView.java | 8 ++++---- 7 files changed, 42 insertions(+), 37 deletions(-) rename src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/{LightOpenLayerOSM.java => LightOpenLayerMap.java} (97%) rename src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/{OpenLayerOSM.java => OpenLayerMap.java} (99%) diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewer.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewer.java index 01d5a34..44ff96f 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewer.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewer.java @@ -30,7 +30,7 @@ import org.gcube.portlets.user.geoportaldataviewer.client.events.ZoomOutOverMini import org.gcube.portlets.user.geoportaldataviewer.client.events.ZoomOutOverMinimumEventHandler; import org.gcube.portlets.user.geoportaldataviewer.client.gis.ExtentWrapped; import org.gcube.portlets.user.geoportaldataviewer.client.gis.MapUtils; -import org.gcube.portlets.user.geoportaldataviewer.client.gis.OpenLayerOSM; +import org.gcube.portlets.user.geoportaldataviewer.client.gis.OpenLayerMap; import org.gcube.portlets.user.geoportaldataviewer.client.ui.GeonaDataViewMainPanel; import org.gcube.portlets.user.geoportaldataviewer.client.util.LoaderIcon; import org.gcube.portlets.user.geoportaldataviewer.client.util.URLUtil; @@ -66,7 +66,7 @@ public class GeoportalDataViewer implements EntryPoint { public final static String APP_DIV = "geoportal-data-viewer"; /** The ol map. */ - // private OpenLayerOSM olMap = null; + // private OpenLayerMap olMap = null; /** The main panel. */ private GeonaDataViewMainPanel mainPanel; @@ -139,6 +139,7 @@ public class GeoportalDataViewer implements EntryPoint { @Override public void onSuccess(List listBaseMapLayers) { RootPanel.get(APP_DIV).remove(loaderApp); + //now the map is loaded and I'm sure that I can load the GeonaDataViewer Profile loadGeonaDataViewerProfile(); mainPanel.setBaseLayers(listBaseMapLayers); @@ -146,8 +147,9 @@ public class GeoportalDataViewer implements EntryPoint { //Passing the first base map layer that will be applied as first base layer olMapMng = new OLMapManager(mainPanel.getMapPanel().getElement().getId(), layerManager.getLayerManagerBus(), firstBaseLayer); - layerManager.setOlMap(olMapMng.getOLOSMMap()); - mainPanel.setMap(olMapMng.getOLOSMMap()); + OpenLayerMap olMap = olMapMng.getOLMap(); + layerManager.setOlMap(olMap); + mainPanel.setMap(olMap); //mainPanel.setMapAttribution(olMapMng.getOLOSMMap().getMapAttribution()); updateSize(); @@ -407,7 +409,7 @@ public class GeoportalDataViewer implements EntryPoint { DO_LAYER_ACTION doAction = doLayerActionEvent.getDoAction(); GWT.log("event: "+doAction); GWT.log("layer source: "+doLayerActionEvent.getLayerItem().getName()); - OpenLayerOSM olMap = olMapMng.getOLOSMMap(); + OpenLayerMap olMap = olMapMng.getOLMap(); switch (doAction) { case OPACITY: @@ -450,7 +452,7 @@ public class GeoportalDataViewer implements EntryPoint { String attributionHTML = "
" + baseLayer.getAttribution() + "
"; - olMapMng.getOLOSMMap().changeBaseMap(baseLayer); + olMapMng.getOLMap().changeBaseMap(baseLayer); //THE OSM Contributors are automatically added by gwt-ol, other ones not. if(!baseLayer.getType().equals(BaseMapLayer.OL_BASE_MAP.OSM)) { diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/LayerManager.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/LayerManager.java index 7998f93..bcd7fbe 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/LayerManager.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/LayerManager.java @@ -26,7 +26,7 @@ import org.gcube.portlets.user.geoportaldataviewer.client.events.ZoomOutOverMini import org.gcube.portlets.user.geoportaldataviewer.client.events.ZoomOutOverMinimumEventHandler; import org.gcube.portlets.user.geoportaldataviewer.client.gis.ExtentWrapped; import org.gcube.portlets.user.geoportaldataviewer.client.gis.MapUtils; -import org.gcube.portlets.user.geoportaldataviewer.client.gis.OpenLayerOSM; +import org.gcube.portlets.user.geoportaldataviewer.client.gis.OpenLayerMap; import org.gcube.portlets.user.geoportaldataviewer.client.ui.ModalWindow; import org.gcube.portlets.user.geoportaldataviewer.client.util.StringUtil; import org.gcube.portlets.user.geoportaldataviewer.client.util.URLUtil; @@ -81,7 +81,7 @@ import ol.geom.Geometry; public class LayerManager { /** The ol map. */ - private OpenLayerOSM olMap; + private OpenLayerMap olMap; private Map mapDetailLayerObjects = new HashMap(); private Map mapBaseLayerObjects = new HashMap(); @@ -869,7 +869,7 @@ public class LayerManager { * * @param olMap the new ol map */ - public void setOlMap(OpenLayerOSM olMap) { + public void setOlMap(OpenLayerMap olMap) { this.olMap = olMap; } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/OLMapManager.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/OLMapManager.java index 2fc6d15..294aab6 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/OLMapManager.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/OLMapManager.java @@ -6,7 +6,7 @@ import org.gcube.portlets.user.geoportaldataviewer.client.events.QueryDataEvent; import org.gcube.portlets.user.geoportaldataviewer.client.events.ZoomOutOverMinimumEvent; import org.gcube.portlets.user.geoportaldataviewer.client.gis.ExtentWrapped; import org.gcube.portlets.user.geoportaldataviewer.client.gis.MapUtils; -import org.gcube.portlets.user.geoportaldataviewer.client.gis.OpenLayerOSM; +import org.gcube.portlets.user.geoportaldataviewer.client.gis.OpenLayerMap; import org.gcube.portlets.user.geoportaldataviewer.client.ui.map.ExtentMapUtil; import org.gcube.portlets.user.geoportaldataviewer.client.ui.map.ExtentMapUtil.Location; import org.gcube.portlets.user.geoportaldataviewer.client.ui.map.ExtentMapUtil.PLACE; @@ -32,7 +32,7 @@ public class OLMapManager { private String targetId; private HandlerManager layerManagerBus; - private OpenLayerOSM olMap; + private OpenLayerMap olMap; private ol.Extent dragStartExtent = null; private Double zoomStart = null; private Double zoomEnd = null; @@ -56,11 +56,12 @@ public class OLMapManager { /** * Instance OL map. - * @param baseMapLayer + * + * @param baseMapLayer the base map layer */ public void instanceOLMap(BaseMapLayer baseMapLayer) { - olMap = new OpenLayerOSM(targetId, layerManagerBus, baseMapLayer) { + olMap = new OpenLayerMap(targetId, layerManagerBus, baseMapLayer) { @Override public void clickListener(MapBrowserEvent event) { @@ -140,6 +141,7 @@ public class OLMapManager { * To data point query. * * @param coordinate the coordinate + * @param manualClick the manual click * @return the geo query */ public GeoQuery toDataPointQuery(Coordinate coordinate, boolean manualClick) { @@ -178,16 +180,18 @@ public class OLMapManager { } /** - * Gets the OLOSM map. + * Gets the OL map. * - * @return the OLOSM map + * @return the OL map */ - public OpenLayerOSM getOLOSMMap() { + public OpenLayerMap getOLMap() { return olMap; } /** * Check select query. + * + * @param mapEventType the map event type */ private void checkSelectQuery(MapEventType mapEventType) { diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/LightOpenLayerOSM.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/LightOpenLayerMap.java similarity index 97% rename from src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/LightOpenLayerOSM.java rename to src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/LightOpenLayerMap.java index 73615d7..2e9818d 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/LightOpenLayerOSM.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/LightOpenLayerMap.java @@ -52,13 +52,13 @@ import ol.style.Text; import ol.style.TextOptions; /** - * The Class LightOpenLayerOSM. + * The Class LightOpenLayerMap. * - * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) + * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it * - * Nov 11, 2020 + * Nov 12, 2021 */ -public class LightOpenLayerOSM { +public class LightOpenLayerMap { public static final int MAX_ZOOM = 20; @@ -85,7 +85,7 @@ public class LightOpenLayerOSM { * * @param divTargetId the div target id */ - public LightOpenLayerOSM(String divTargetId) { + public LightOpenLayerMap(String divTargetId) { // create a OSM-layer XyzOptions osmSourceOptions = OLFactory.createOptions(); @@ -265,6 +265,11 @@ public class LightOpenLayerOSM { return layerNames; } + /** + * Gets the layer UR ls property. + * + * @return the layer UR ls property + */ public java.util.Map getLayerURLsProperty() { Collection layers = map.getLayerGroup().getLayers(); diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/OpenLayerOSM.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/OpenLayerMap.java similarity index 99% rename from src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/OpenLayerOSM.java rename to src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/OpenLayerMap.java index fdc6711..c762965 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/OpenLayerOSM.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/OpenLayerMap.java @@ -63,13 +63,13 @@ import ol.source.Xyz; import ol.source.XyzOptions; /** - * The Class OpenLayerOSM. + * The Class OpenLayerMap. * * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) * * Oct 27, 2020 */ -public abstract class OpenLayerOSM { +public abstract class OpenLayerMap { public static final int MAX_ZOOM = 21; @@ -152,7 +152,7 @@ public abstract class OpenLayerOSM { * @param eventBus the event bus * @param baseLayer the base layer */ - public OpenLayerOSM(String divTargetId, HandlerManager eventBus, BaseMapLayer baseLayer) { + public OpenLayerMap(String divTargetId, HandlerManager eventBus, BaseMapLayer baseLayer) { this.eventBus = eventBus; for (int i = 0; i < 100; i++) { @@ -407,12 +407,9 @@ public abstract class OpenLayerOSM { // imageWMSOptions.setRatio(1.5f); ImageWms imageWMSSource = new ImageWms(imageWMSOptions); - LayerOptions layerOptions = OLFactory.createOptions(); layerOptions.setSource(imageWMSSource); - - // Settings MIN and MAX Resolution if (layerItem.getMinResolution() != null) { layerOptions.setMinResolution(layerItem.getMinResolution()); @@ -462,12 +459,9 @@ public abstract class OpenLayerOSM { // imageWMSOptions.setRatio(1.5f); ImageWms imageWMSSource = new ImageWms(imageWMSOptions); - LayerOptions layerOptions = OLFactory.createOptions(); layerOptions.setSource(imageWMSSource); - - // Settings MIN and MAX Resolution if (layerItem.getMinResolution() != null) { layerOptions.setMinResolution(layerItem.getMinResolution()); diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/GeonaDataViewMainPanel.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/GeonaDataViewMainPanel.java index 0c74a2c..894b783 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/GeonaDataViewMainPanel.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/GeonaDataViewMainPanel.java @@ -8,7 +8,7 @@ import org.gcube.application.geoportalcommon.shared.products.model.RecordDV; import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants.MAP_PROJECTION; import org.gcube.portlets.user.geoportaldataviewer.client.events.ChangeMapLayerEvent; import org.gcube.portlets.user.geoportaldataviewer.client.events.MapExtentToEvent; -import org.gcube.portlets.user.geoportaldataviewer.client.gis.OpenLayerOSM; +import org.gcube.portlets.user.geoportaldataviewer.client.gis.OpenLayerMap; import org.gcube.portlets.user.geoportaldataviewer.client.resources.Images; import org.gcube.portlets.user.geoportaldataviewer.client.ui.map.ExtentMapUtil; import org.gcube.portlets.user.geoportaldataviewer.client.ui.map.ExtentMapUtil.Location; @@ -97,7 +97,7 @@ public class GeonaDataViewMainPanel extends Composite { private MapPanel mapPanel; - private OpenLayerOSM map; + private OpenLayerMap map; private HandlerManager applicationBus; @@ -190,7 +190,7 @@ public class GeonaDataViewMainPanel extends Composite { * * @param map the new map */ - public void setMap(OpenLayerOSM map) { + public void setMap(OpenLayerMap map) { this.map = map; } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/map/MapView.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/map/MapView.java index e28412b..61c5958 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/map/MapView.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/map/MapView.java @@ -4,7 +4,7 @@ import org.gcube.application.geoportalcommon.shared.gis.BoundsMap; import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants; import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants.MAP_PROJECTION; import org.gcube.portlets.user.geoportaldataviewer.client.gis.ExtentWrapped; -import org.gcube.portlets.user.geoportaldataviewer.client.gis.LightOpenLayerOSM; +import org.gcube.portlets.user.geoportaldataviewer.client.gis.LightOpenLayerMap; import org.gcube.portlets.user.geoportaldataviewer.client.gis.MapUtils; import org.gcube.portlets.user.geoportaldataviewer.client.ui.map.ExtentMapUtil.Location; import org.gcube.portlets.user.geoportaldataviewer.client.ui.map.ExtentMapUtil.PLACE; @@ -50,7 +50,7 @@ public class MapView extends Composite { @UiField HorizontalPanel coordinatePanel; - private LightOpenLayerOSM lightOLSM; + private LightOpenLayerMap lightOLSM; private String theMapId = null; @@ -71,7 +71,7 @@ public class MapView extends Composite { @Override public void execute() { - lightOLSM = new LightOpenLayerOSM(theMapId); + lightOLSM = new LightOpenLayerMap(theMapId); // EPSG_3857 LOCATION TO ITALY Location italyLocation = ExtentMapUtil.getLocation(PLACE.ITALY); @@ -169,7 +169,7 @@ public class MapView extends Composite { } - public LightOpenLayerOSM getLightOLSM() { + public LightOpenLayerMap getLightOLSM() { return lightOLSM; } -- 2.17.1 From 002d6d230179bdbe113fdc53439f438a50f7d348 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Fri, 12 Nov 2021 16:57:57 +0100 Subject: [PATCH 06/14] MapBox Satellite integrated in the principal Map --- .../client/GeoportalDataViewer.java | 16 ++++++---------- .../geoportaldataviewer/client/LayerManager.java | 2 +- .../client/gis/LightOpenLayerMap.java | 10 +++++----- .../client/gis/OpenLayerMap.java | 5 ----- .../client/ui/GeonaDataViewMainPanel.ui.xml | 8 ++++---- src/main/webapp/GeoportalDataViewer.css | 2 +- 6 files changed, 17 insertions(+), 26 deletions(-) diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewer.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewer.java index 44ff96f..5281264 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewer.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewer.java @@ -95,10 +95,8 @@ public class GeoportalDataViewer implements EntryPoint { int attempt = 0; - private LoaderIcon loaderApp = new LoaderIcon("Loading application...."); - private HTML attributionDiv = new HTML(); /** @@ -148,7 +146,7 @@ public class GeoportalDataViewer implements EntryPoint { olMapMng = new OLMapManager(mainPanel.getMapPanel().getElement().getId(), layerManager.getLayerManagerBus(), firstBaseLayer); OpenLayerMap olMap = olMapMng.getOLMap(); - layerManager.setOlMap(olMap); + layerManager.setOLMap(olMap); mainPanel.setMap(olMap); //mainPanel.setMapAttribution(olMapMng.getOLOSMMap().getMapAttribution()); @@ -310,9 +308,7 @@ public class GeoportalDataViewer implements EntryPoint { @Override public void onLayerRendered(AddedLayerToMapEvent addedLayerToMapEvent) { GWT.log("Fired AddedLayerToMapEvent " + addedLayerToMapEvent.getLayerItem() + "layer type: "+addedLayerToMapEvent.getLayerType()); - // GeoportalDataViewerConstants.print("Fired AddedLayerToMapEvent - // "+addedLayerToMapEvent.getLayerItem()); - + try { attempt = 0; @@ -453,11 +449,11 @@ public class GeoportalDataViewer implements EntryPoint { String attributionHTML = "
" + baseLayer.getAttribution() + "
"; olMapMng.getOLMap().changeBaseMap(baseLayer); - - //THE OSM Contributors are automatically added by gwt-ol, other ones not. - if(!baseLayer.getType().equals(BaseMapLayer.OL_BASE_MAP.OSM)) { + + // THE OSM Contributors are automatically added by gwt-ol, others ones not. + if (!baseLayer.getType().equals(BaseMapLayer.OL_BASE_MAP.OSM)) { attributionDiv.setHTML(attributionHTML); - }else + } else attributionDiv.setHTML(""); } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/LayerManager.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/LayerManager.java index bcd7fbe..e26aab3 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/LayerManager.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/LayerManager.java @@ -869,7 +869,7 @@ public class LayerManager { * * @param olMap the new ol map */ - public void setOlMap(OpenLayerMap olMap) { + public void setOLMap(OpenLayerMap olMap) { this.olMap = olMap; } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/LightOpenLayerMap.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/LightOpenLayerMap.java index 2e9818d..bb61559 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/LightOpenLayerMap.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/LightOpenLayerMap.java @@ -56,10 +56,10 @@ import ol.style.TextOptions; * * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it * - * Nov 12, 2021 + * Nov 12, 2021 */ public class LightOpenLayerMap { - + public static final int MAX_ZOOM = 20; /** The map. */ @@ -81,7 +81,7 @@ public class LightOpenLayerMap { private String markerURL = Images.ICONS.mapMarkerIcon().getURL(); /** - * Instantiates a new light open layer OSM. + * Instantiates a new light open layer map. * * @param divTargetId the div target id */ @@ -278,7 +278,7 @@ public class LightOpenLayerMap { Base[] layersArr = layers.getArray(); for (int i = 0; i < layersArr.length; i++) { Base layer = layersArr[i]; - //GeoportalDataViewerConstants.printJs(layer.toString()); + // GeoportalDataViewerConstants.printJs(layer.toString()); if (layer instanceof Image) { Image layerImage = (Image) layer; @@ -308,7 +308,7 @@ public class LightOpenLayerMap { } } - GWT.log("returning mapLayerNameURL: "+mapLayerNameURL); + GWT.log("returning mapLayerNameURL: " + mapLayerNameURL); return mapLayerNameURL; } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/OpenLayerMap.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/OpenLayerMap.java index c762965..e487256 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/OpenLayerMap.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/OpenLayerMap.java @@ -136,8 +136,6 @@ public abstract class OpenLayerMap { private LinkedHashMap wmsDetailsLayerMap; - private Integer[] wmsDetailsLayerZIndex = new Integer[100]; - private LinkedHashMap wmsLayerMap; private Layer baseLayerTile; @@ -155,9 +153,6 @@ public abstract class OpenLayerMap { public OpenLayerMap(String divTargetId, HandlerManager eventBus, BaseMapLayer baseLayer) { this.eventBus = eventBus; - for (int i = 0; i < 100; i++) { - wmsDetailsLayerZIndex[i] = 1000 + i; - } // create a projection projectionOptions.setCode(MAP_PROJECTION.EPSG_3857.getName()); diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/GeonaDataViewMainPanel.ui.xml b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/GeonaDataViewMainPanel.ui.xml index 8f70659..38a57f5 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/GeonaDataViewMainPanel.ui.xml +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/GeonaDataViewMainPanel.ui.xml @@ -16,10 +16,6 @@ - - - - @@ -39,6 +35,10 @@
+ + + + diff --git a/src/main/webapp/GeoportalDataViewer.css b/src/main/webapp/GeoportalDataViewer.css index 59620a7..2ca51d9 100644 --- a/src/main/webapp/GeoportalDataViewer.css +++ b/src/main/webapp/GeoportalDataViewer.css @@ -342,7 +342,7 @@ body { .layers-panel { margin-top: 10px; background-color: white; - opacity: 80%; + opacity: 90%; padding: 10px; width: 410px; } -- 2.17.1 From 4ae0c399830775fe0065a27902d14a84e2bad13e Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Tue, 16 Nov 2021 14:07:59 +0100 Subject: [PATCH 07/14] Added new set of icons --- .../client/GeoportalDataViewer.java | 8 +- .../client/gis/LightOpenLayerMap.java | 93 +++++++++++++++--- .../client/resources/GNAIcons.java | 37 +++++++ .../client/resources/GNAImages.java | 41 ++++++++ .../client/resources/Images.java | 25 ----- .../client/resources/baseIcons.css | 25 +++++ .../client/resources/home.png | Bin 0 -> 403 bytes .../client/resources/layers.png | Bin 0 -> 465 bytes .../client/resources/map.png | Bin 0 -> 318 bytes .../client/resources/new_folder.png | Bin 0 -> 581 bytes .../client/resources/preset_location.png | Bin 0 -> 683 bytes .../client/resources/vre_folder.png | Bin 0 -> 1396 bytes .../client/ui/GeonaDataViewMainPanel.java | 31 ++++-- .../client/ui/GeonaDataViewMainPanel.ui.xml | 6 +- .../client/ui/map/MapView.java | 57 +++++++++++ .../client/ui/map/MapView.ui.xml | 26 ++--- .../client/util/LoaderIcon.java | 4 +- .../shared/GeoNaSpatialQueryResult.java | 2 +- src/main/webapp/GeoportalDataViewer.css | 40 +++++++- 19 files changed, 324 insertions(+), 71 deletions(-) create mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/resources/GNAIcons.java create mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/resources/GNAImages.java delete mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/resources/Images.java create mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/resources/baseIcons.css create mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/resources/home.png create mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/resources/layers.png create mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/resources/map.png create mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/resources/new_folder.png create mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/resources/preset_location.png create mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/resources/vre_folder.png diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewer.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewer.java index 5281264..bf75a85 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewer.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewer.java @@ -98,6 +98,8 @@ public class GeoportalDataViewer implements EntryPoint { private LoaderIcon loaderApp = new LoaderIcon("Loading application...."); private HTML attributionDiv = new HTML(); + + private static List listBaseMapLayers = null; /** * This is the entry point method. @@ -137,6 +139,7 @@ public class GeoportalDataViewer implements EntryPoint { @Override public void onSuccess(List listBaseMapLayers) { RootPanel.get(APP_DIV).remove(loaderApp); + GeoportalDataViewer.listBaseMapLayers = listBaseMapLayers; //now the map is loaded and I'm sure that I can load the GeonaDataViewer Profile loadGeonaDataViewerProfile(); mainPanel.setBaseLayers(listBaseMapLayers); @@ -149,7 +152,6 @@ public class GeoportalDataViewer implements EntryPoint { layerManager.setOLMap(olMap); mainPanel.setMap(olMap); - //mainPanel.setMapAttribution(olMapMng.getOLOSMMap().getMapAttribution()); updateSize(); ScriptInjector.fromUrl("//cdnjs.cloudflare.com/ajax/libs/nanogallery2/3.0.5/jquery.nanogallery2.min.js") .setWindow(ScriptInjector.TOP_WINDOW).inject(); @@ -176,6 +178,10 @@ public class GeoportalDataViewer implements EntryPoint { RootPanel.get(APP_DIV).add(attributionDiv); } + public static List getListBaseMapLayers() { + return listBaseMapLayers; + } + private void loadGeonaDataViewerProfile() { Scheduler.get().scheduleDeferred(new ScheduledCommand() { diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/LightOpenLayerMap.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/LightOpenLayerMap.java index bb61559..5a54555 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/LightOpenLayerMap.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/LightOpenLayerMap.java @@ -5,9 +5,11 @@ import java.util.HashMap; import java.util.List; import org.gcube.application.geoportalcommon.shared.gis.BoundsMap; +import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewer; import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants; import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants.MAP_PROJECTION; -import org.gcube.portlets.user.geoportaldataviewer.client.resources.Images; +import org.gcube.portlets.user.geoportaldataviewer.client.resources.GNAImages; +import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BaseMapLayer; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.GeoQuery; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.GeoQuery.TYPE; @@ -34,6 +36,7 @@ import ol.interaction.KeyboardPan; import ol.interaction.KeyboardZoom; import ol.layer.Base; import ol.layer.Image; +import ol.layer.Layer; import ol.layer.LayerOptions; import ol.layer.Tile; import ol.layer.VectorLayerOptions; @@ -44,6 +47,7 @@ import ol.source.ImageWmsOptions; import ol.source.ImageWmsParams; import ol.source.Osm; import ol.source.Source; +import ol.source.Xyz; import ol.source.XyzOptions; import ol.style.Icon; import ol.style.IconOptions; @@ -78,8 +82,12 @@ public class LightOpenLayerMap { private ol.layer.Vector geometryLayer; - private String markerURL = Images.ICONS.mapMarkerIcon().getURL(); + private String markerURL = GNAImages.ICONS.mapMarkerIcon().getURL(); + private LayerOrder layerOrder = new LayerOrder(); + + private Layer baseLayerTile; + /** * Instantiates a new light open layer map. * @@ -87,15 +95,6 @@ public class LightOpenLayerMap { */ public LightOpenLayerMap(String divTargetId) { - // create a OSM-layer - XyzOptions osmSourceOptions = OLFactory.createOptions(); - osmSourceOptions.setCrossOrigin("Anonymous"); -// osmSourceOptions.setTileLoadFunction(null); - - Osm osmSource = new Osm(osmSourceOptions); - LayerOptions osmLayerOptions = OLFactory.createOptions(); - osmLayerOptions.setSource(osmSource); - Tile osmLayer = new Tile(osmLayerOptions); // create a projection projectionOptions.setCode(MAP_PROJECTION.EPSG_3857.getName()); projectionOptions.setUnits("m"); @@ -114,7 +113,7 @@ public class LightOpenLayerMap { map = new Map(mapOptions); - map.addLayer(osmLayer); + //map.addLayer(osmLayer); // map.addLayer(tileDebugLayer); Attribution attribution = new Attribution(); @@ -161,6 +160,72 @@ public class LightOpenLayerMap { // add some interactions map.addInteraction(new KeyboardPan()); map.addInteraction(new KeyboardZoom()); + + List listBaseMapLayers = GeoportalDataViewer.getListBaseMapLayers(); + BaseMapLayer bml = null; + if(listBaseMapLayers!=null) + bml = listBaseMapLayers.get(0); + + changeBaseMap(bml); + + } + + /** + * Change base map. + * + * @param baseLayer the base layer + */ + public void changeBaseMap(BaseMapLayer baseLayer) { + + BaseMapLayer.OL_BASE_MAP baseMap = baseLayer.getType() == null ? BaseMapLayer.OL_BASE_MAP.OSM + : baseLayer.getType(); + + try { + if (baseLayerTile != null) + map.removeLayer(baseLayerTile); + } catch (Exception e) { + } + + switch (baseMap) { + case MAPBOX: + case OTHER: + + XyzOptions xyzOptions2 = OLFactory.createOptions(); + xyzOptions2.setCrossOrigin("Anonymous"); + Xyz xyz = new Xyz(xyzOptions2); + //setAttributions is buggy + //xyz.setAttributions(baseLayer.getAttribution()); + xyz.setUrl(baseLayer.getUrl()); + + LayerOptions layerOptions2 = OLFactory.createOptions(); + layerOptions2.setSource(xyz); + int zIndex = layerOrder.getOffset(LayerOrder.LAYER_TYPE.BASE_MAP)+1; + layerOptions2.setZIndex(zIndex); + baseLayerTile = new Tile(layerOptions2); + + break; + case OSM: + default: + XyzOptions osmSourceOptions = OLFactory.createOptions(); + osmSourceOptions.setCrossOrigin("Anonymous"); + Osm osmSource = new Osm(osmSourceOptions); + //osmSource.setUrl(baseLayer.getUrl()); + //setAttributions is buggy + //osmSource.setAttributions(baseLayer.getAttribution()); + LayerOptions layerOptions = OLFactory.createOptions(); + layerOptions.setSource(osmSource); + zIndex = layerOrder.getOffset(LayerOrder.LAYER_TYPE.BASE_MAP)+1; + layerOptions.setZIndex(zIndex); + baseLayerTile = new Tile(layerOptions); + + break; + + } + + // map == null at init time + if (map != null) { + map.addLayer(baseLayerTile); + } } @@ -212,6 +277,8 @@ public class LightOpenLayerMap { layerOptions.setSource(imageWMSSource); ol.layer.Image wmsLayer = new ol.layer.Image(layerOptions); + int zIndex = layerOrder.getOffset(LayerOrder.LAYER_TYPE.WMS_DETAIL)+1; + wmsLayer.setZIndex(zIndex); // visibleLayerItems map.addLayer(wmsLayer); @@ -370,6 +437,8 @@ public class LightOpenLayerMap { VectorLayerOptions vectorLayerOptions = new VectorLayerOptions(); vectorLayerOptions.setSource(vector); geometryLayer = new ol.layer.Vector(vectorLayerOptions); + int zIndex = layerOrder.getOffset(LayerOrder.LAYER_TYPE.VECTOR)+1; + geometryLayer.setZIndex(zIndex); map.addLayer(geometryLayer); } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/resources/GNAIcons.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/resources/GNAIcons.java new file mode 100644 index 0000000..32e4c76 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/resources/GNAIcons.java @@ -0,0 +1,37 @@ +package org.gcube.portlets.user.geoportaldataviewer.client.resources; + +import com.github.gwtbootstrap.client.ui.constants.BaseIconType; +import com.google.gwt.core.client.GWT; +import com.google.gwt.resources.client.ClientBundle; + +public interface GNAIcons extends ClientBundle { + + /** My custom base icon collection */ + public enum CustomIconType implements BaseIconType { + + MAP("map"), + PRESET_LOCATION("preset_location"), + LAYERS("layers"); + + /** Inject the icon's css once at first usage */ + static { + GNAImages icons = GWT.create(GNAImages.class); + icons.css().ensureInjected(); + } + + private static final String PREFIX = "myBaseIcon_"; + private String className; + + private CustomIconType(String className) { + this.className = className; + } + + /** + * {@inheritDoc} + */ + @Override + public String get() { + return PREFIX + className; + } + } +} diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/resources/GNAImages.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/resources/GNAImages.java new file mode 100644 index 0000000..e327a65 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/resources/GNAImages.java @@ -0,0 +1,41 @@ +package org.gcube.portlets.user.geoportaldataviewer.client.resources; + +import com.google.gwt.core.client.GWT; +import com.google.gwt.resources.client.ClientBundle; +import com.google.gwt.resources.client.CssResource; +import com.google.gwt.resources.client.ImageResource; + +public interface GNAImages extends ClientBundle { + + /** Get access to the css resource during gwt compilation */ + @Source("baseIcons.css") + CssResource css(); + + public static final GNAImages ICONS = GWT.create(GNAImages.class); + + /** Our sample image icon. Makes the image resource for the gwt-compiler's css composer accessible */ + @Source("map.png") + ImageResource map(); + + @Source("preset_location.png") + ImageResource preset_location(); + + @Source("layers.png") + ImageResource layers(); + + @Source("loading.gif") + ImageResource loading(); + + @Source("map-marker-icon.png") + ImageResource mapMarkerIcon(); + + @Source("icon_share.png") + ImageResource shareIcon(); + + @Source("italy.png") + ImageResource italyIcon(); + + @Source("world.png") + ImageResource worldIcon(); + +} diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/resources/Images.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/resources/Images.java deleted file mode 100644 index c097d2a..0000000 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/resources/Images.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.gcube.portlets.user.geoportaldataviewer.client.resources; - -import com.google.gwt.core.client.GWT; -import com.google.gwt.resources.client.ClientBundle; -import com.google.gwt.resources.client.ImageResource; - -public interface Images extends ClientBundle { - - public static final Images ICONS = GWT.create(Images.class); - - @Source("loading.gif") - ImageResource loading(); - - @Source("map-marker-icon.png") - ImageResource mapMarkerIcon(); - - @Source("icon_share.png") - ImageResource shareIcon(); - - @Source("italy.png") - ImageResource italyIcon(); - - @Source("world.png") - ImageResource worldIcon(); -} diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/resources/baseIcons.css b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/resources/baseIcons.css new file mode 100644 index 0000000..8630120 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/resources/baseIcons.css @@ -0,0 +1,25 @@ +/* Prevent our icons from css obfuscation */ +@external .myBaseIcon_*; /* Do some css stuff */ +@sprite .myBaseIcon_map { + gwt-image: "map"; + display: inline-block; + vertical-align: middle; + margin-bottom: 3px; + margin-right: 2px; +} + +@sprite .myBaseIcon_preset_location { + gwt-image: "preset_location"; + display: inline-block; + vertical-align: middle; + margin-bottom: 3px; + margin-right: 2px; +} + +@sprite .myBaseIcon_layers { + gwt-image: "layers"; + display: inline-block; + vertical-align: middle; + margin-bottom: 3px; + margin-right: 2px; +} \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/resources/home.png b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/resources/home.png new file mode 100644 index 0000000000000000000000000000000000000000..d19e34de44fda4eabdcb6e85fd060e5d39100df4 GIT binary patch literal 403 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbL!WQl7;NpOBzNqJ&XDuZK6ep0G} zXKrG8YEWuoN@d~6R2!h8@Bp6>S6^RWKR>^?xVWgOsOaeEl$4a@p;*x1;> zz(5}#pYZVTkdTnX#KfSWps=v8fPjFAh=|b8(4?fK`1p8#fB(qH$l&1MgoK2cn3(_n z{{zhqo-{`kNXeE2`2_<-Z~}(Nw&z(ug)2Q>978H@+4M#79Z}$Mj$QDYA+_D%ef>F4 z_shSOz2@m0-;ot=%bk6B)0x-X9IvmsqNiaTIn&{FK()A%@KTfW(sM35YMHw2vpwDQ zB8H=MgHhzS14mwbk00^R8{ivXh_l-Yq!A;^SrcV|r(!wRg<{!#TxLdJ?OSu$tX{@_gm>@CHVP4SqtC U*M`r#0dzEjr>mdKI;Vst08CJ>g#Z8m literal 0 HcmV?d00001 diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/resources/layers.png b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/resources/layers.png new file mode 100644 index 0000000000000000000000000000000000000000..41fc600fc69f83969e0755321c9fc3d4d15c2486 GIT binary patch literal 465 zcmV;?0WSWDP)Ez6#xJL8FWQhbW?9;ba!ELWdL_~cP?peYja~^ zaAhuUa%Y?FJQ@H10ZvIoK~yM_ozpRER8bJc@!vcpO=6*78iimZ7Ft-C!cMU81K4S0 zlS(kF8wCZQ5{TigyEb-KVwcv!La?#b51042!8vhoA#*o`K$f_{6urHn2t+u00000NkvXX Hu0mjfZC%U! literal 0 HcmV?d00001 diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/resources/map.png b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/resources/map.png new file mode 100644 index 0000000000000000000000000000000000000000..fc9aef5bb0708e23b4d0b4f696c074a094e544d4 GIT binary patch literal 318 zcmeAS@N?(olHy`uVBq!ia0vp^0zk~q!3HGX7W?Z1DVAa<&kznEsNqQI0P;BtJR*x3 z7`TptFyj`j1OuR;WQl7;NpOBzNqJ&XDnogBxn5>oc5!lIL8@MUQTpt6Hc~)EyFFbT zLo_D7J+siOxlp9-Y6MA?keteIypRV z)MjQ{i~W^x{&8s5k0r$w_rG)QmGKl#Ot?JPZ_n>%TC>IamQ4Gg;ajjs;>9uUmbf%i z4&&nEW^cS|P5u-p_O|?9U$1dT?DP`dME6_qlK+o2mc(Xxl};&T{l{AGwjmCb+PfvS$dvS4bYHo5~US67- znrv)rpP!$bo10!gxah{C<9ZU0q#mZEbsdd+6ok>*(e_K0fK^<>=(%Wo2b>aBzKnef0G7{P_0p z>E-tG@pW}|baZrUYis}a@^W%=^6%~P^78fZ@8jd+goK28dV1{U;_K_{fPjGZ?&uzptX=!P1Z*N;$Tl?|rhK7cNgM;<(?e_Nee0+TO@azBj^lWTwczAfXx3^SORB>@} zd3kwbV`G7VfoN!GZpyBA0000WbW%=J08Rl9@bF6~@cLx@@DTikc=Ygy@bGE)_3-ud z`TX_t#57ug0002MNklAs^&Thh+nTn!x33UwjvwaFzu^-7t^TI#Qpy~{@a}$Ew!M=3 z+G-gW2!--UZ+^N4L-814{m1sc8l7vlEWX-8ID5i*X%x9yRY+@ZY)b%!ou2Iv`2(W*}J@?jn!^cQ%e; zi+F=J4&+$02+L_maTf{UJ4p-)E(|0|7~I$@XbQBCRf~cI^CQg26xujSW5fLar^UQY z^Um1D1DAWxea`c6&&Lf*?O+b*^NO@hv0HJ=oL8|0r&K=iPTX8fDP02NIjqkmyf0i- z8&H|T5n+=sp~uhK`Ql<)ES%c8AMbU%)UaOVIGz!9;&Ex;0v>kR8z28CGM*2cbz85O zupLF%Bb`S`XN1@Ag>Y8wl-iVDO>f1y@IkIryNqd^kiOLKdvjL!%Q|6&+O)B_C^L+E z4ug0ZmCE{}GJ>_(fOm!O+_u$>gTgVitnRrf*%f3NQH0 z9kuO>DdBXFS;zF*hda`z_)6^?GtPLxgKGC{xTzJDcHSq}K%8aS(XUF{^kR!j;%ddMxUsQ&-&6pyKVC~U(pHsb9?DZgPfCg!`-UGZHQ zN56Db!-U!iwL!%>tj4sk-`@D>Us|^a9LhC{5ot&G;wC{0I9bxu)mV R-9!KY002ovPDHLkV1i3eKiU8Q literal 0 HcmV?d00001 diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/resources/vre_folder.png b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/resources/vre_folder.png new file mode 100644 index 0000000000000000000000000000000000000000..68ae4d3fb1c5942ce67f355c0e0be06dc16072e3 GIT binary patch literal 1396 zcmV-)1&jKLP)dQ@0+Qek%> zaB^>EX>4U6ba`-PAZ2)IW&i+q+NG6klH?`~hW~Sl907eHaU9G?Rc?^u=LLIudv>Na zyA`N5v@C?sBjhyy`Fo|m&?rkzY96JQlF_tk<%UV*yI~~Glq=@+$exkfXL-_R5nT{j z{?a(|-tdPZz6T*l_Iy5u$}wjQkP2Tc18*yHI|<9(1y@ABjSS=5exdRwsfI#K-Y zD0x$O3+{&)?j3ph^5UbFWBqfW%lE`Ku=FDK(~B3e`jyx@)?1*tXG)L4rx!zBOHNyB z#9H$xXw!mxE9Vcr4s#oV;srnCq+mgJ{0wtHy`l$V+L0O~_k5vu#GVnd4s+muEnl~Z%jl-M z^GOa{fu3Q!6PbM6>$f4r-UerIr<8IbF)FwY%ua+r1^_k6!J>SD0GaWCldK{IY=ZaJ z32U5=E*sx+)FhBFDdJ#Lr2&?zA%9#0In+!{&8(PPShZH9Xew4p@v@6sb8&TZ6aWve z-avOAYP8B#Q2VTw>NRSutzpjw%dMma{RYX!mt1<;RW85cs#ohspRV0{>E5H) z-UbgDI&75TBSsx<(nKmvot9>qK4aF|7IJOL(q*eGU$N?HFKYB$;h*~-P@{($A5vS- zU(_IVzsGd)1x7YA5Mw0}_e}r^&6`;cQsqrZ2DEwK=HBYiZYbp z7QQ?^P-FYzJY5D#{wUIM8Kl`*qtCizdji*e;RJeO+avXr9oHzt8qGWwkcH2V@_>&h zO5R0d8ZMb#J;LEqIQAqsVKh-iZhaKCjHFnXmdXl@xew_vN95TNrmPEg0w-Bxe{%i> zPN~@_|DpNP00004b3#c}2nYxWd(+1kQx-X&RHDn%%rdn zEgV)xdeYA9dow#Ts{r8T{{D+6TU+k{C;%|Vd~dZ{hX4c*n;;SFHX84ZQXilc0KoTs z3d8V+0+7TOfqp6CX@LbPp9Qn4M)6cLE!(6XYT zo5pdTiQani+5C~&@KOZN^H3}n0RY3{5Z2lh$CBOfL`1Kv&}=r5&*uREqtOWMc00up z5v|uHFvcL4%PoBOyplj^7D-Kth%lK<7XElVekg&~5YZxnRdhO?goJLlo4UV;(#))w z87>}gZlY8wLFDcq6$%A}VF)H#2D9>*Ns}|-=X-moR;y6XAE?*ssMTud^?K-@oGju@ zq%{#MYb~s`AZt-BmzTuuU@Mgh60WrtOr&)3f&}MhXSj``RKK@Tg!9u=xLjgZo-ix7 zg|A0P_<3=G%FYh5*(?Cy@68SR{XTwOT`g~cS$Weqo*Ql4-QaRCz~x}Dc6F|P8pl=z zLC|=*z5T`*<7=&() { + linkLayers.fireEvent(new GwtEvent() { @Override public com.google.gwt.event.shared.GwtEvent.Type getAssociatedType() { return ClickEvent.getType(); @@ -358,7 +369,7 @@ public class GeonaDataViewMainPanel extends Composite { RadioButton radio = new RadioButton("base-layer"); radio.setText(baseMapLayer.getName()); if(i==0) { - radio.setValue(true, true); + radio.setValue(true, false); } radio.addValueChangeHandler(new ValueChangeHandler() { diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/GeonaDataViewMainPanel.ui.xml b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/GeonaDataViewMainPanel.ui.xml index 38a57f5..c996e06 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/GeonaDataViewMainPanel.ui.xml +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/GeonaDataViewMainPanel.ui.xml @@ -35,12 +35,12 @@
- + + title="Center Map to Location" text="Preset Location" ui:field="linkPresetLocation"> @@ -62,7 +62,7 @@ - + diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/map/MapView.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/map/MapView.java index 61c5958..ced856c 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/map/MapView.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/map/MapView.java @@ -1,23 +1,33 @@ package org.gcube.portlets.user.geoportaldataviewer.client.ui.map; +import java.util.List; + import org.gcube.application.geoportalcommon.shared.gis.BoundsMap; +import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewer; import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants; import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants.MAP_PROJECTION; import org.gcube.portlets.user.geoportaldataviewer.client.gis.ExtentWrapped; import org.gcube.portlets.user.geoportaldataviewer.client.gis.LightOpenLayerMap; import org.gcube.portlets.user.geoportaldataviewer.client.gis.MapUtils; +import org.gcube.portlets.user.geoportaldataviewer.client.resources.GNAIcons; import org.gcube.portlets.user.geoportaldataviewer.client.ui.map.ExtentMapUtil.Location; import org.gcube.portlets.user.geoportaldataviewer.client.ui.map.ExtentMapUtil.PLACE; +import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BaseMapLayer; +import com.github.gwtbootstrap.client.ui.DropdownButton; 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.event.logical.shared.ValueChangeEvent; +import com.google.gwt.event.logical.shared.ValueChangeHandler; import com.google.gwt.uibinder.client.UiBinder; import com.google.gwt.uibinder.client.UiField; import com.google.gwt.user.client.Random; import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.HTMLPanel; import com.google.gwt.user.client.ui.HorizontalPanel; +import com.google.gwt.user.client.ui.RadioButton; +import com.google.gwt.user.client.ui.SimplePanel; import com.google.gwt.user.client.ui.Widget; import ol.Coordinate; @@ -44,8 +54,14 @@ public class MapView extends Composite { interface MapViewUiBinder extends UiBinder { } + @UiField + HTMLPanel panelBaseLayers; + @UiField HTMLPanel theMap; + + @UiField + DropdownButton linkMap; @UiField HorizontalPanel coordinatePanel; @@ -66,12 +82,15 @@ public class MapView extends Composite { theMap.getElement().setId(theMapId); theMap.setWidth(internalMapWidth); theMap.setHeight(internalMapHeight); + + linkMap.setCustomIconStyle(GNAIcons.CustomIconType.MAP.get()); Scheduler.get().scheduleDeferred(new ScheduledCommand() { @Override public void execute() { lightOLSM = new LightOpenLayerMap(theMapId); + setBaseLayers(); // EPSG_3857 LOCATION TO ITALY Location italyLocation = ExtentMapUtil.getLocation(PLACE.ITALY); @@ -81,6 +100,44 @@ public class MapView extends Composite { } }); } + + public void setBaseLayers() { + List listBaseLayers = GeoportalDataViewer.getListBaseMapLayers(); + + if(listBaseLayers==null) + return; + + int i = 0; + + String radioId = "base_layer_" + Random.nextInt()+Random.nextInt(); + + for (BaseMapLayer baseMapLayer : listBaseLayers) { + + RadioButton radio = new RadioButton(radioId); + radio.setText(baseMapLayer.getName()); + if(i==0) { + radio.setValue(true, false); + } + + radio.addValueChangeHandler(new ValueChangeHandler() { + + @Override + public void onValueChange(ValueChangeEvent event) { + //applicationBus.fireEvent(new ChangeMapLayerEvent(baseMapLayer)); + lightOLSM.changeBaseMap(baseMapLayer); + + } + }); + + SimplePanel sp = new SimplePanel(radio); + sp.getElement().addClassName("form-inline"); + sp.getElement().addClassName("map-layers-radio"); + panelBaseLayers.add(sp); + i++; + } + + } + private void setMapSize() { Scheduler.get().scheduleDeferred(new ScheduledCommand() { diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/map/MapView.ui.xml b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/map/MapView.ui.xml index 27b1dbe..bec7a40 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/map/MapView.ui.xml +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/map/MapView.ui.xml @@ -1,23 +1,17 @@ + xmlns:g="urn:import:com.google.gwt.user.client.ui" + xmlns:b="urn:import:com.github.gwtbootstrap.client.ui"> - .internalMap { - height: 280px; - display: inline-block; - margin: 0 auto; - /*float: right;*/ - } - .map-style { - width: 100%; - text-align:center; - margin-top: 10px; - margin-bottom: 20px; - } + - - + + + + + + diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/util/LoaderIcon.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/util/LoaderIcon.java index 4ba03f1..39359b9 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/util/LoaderIcon.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/util/LoaderIcon.java @@ -3,7 +3,7 @@ */ package org.gcube.portlets.user.geoportaldataviewer.client.util; -import org.gcube.portlets.user.geoportaldataviewer.client.resources.Images; +import org.gcube.portlets.user.geoportaldataviewer.client.resources.GNAImages; import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.HorizontalPanel; @@ -18,7 +18,7 @@ import com.google.gwt.user.client.ui.Image; public class LoaderIcon extends HorizontalPanel{ - private Image imgLoading = new Image(Images.ICONS.loading()); + private Image imgLoading = new Image(GNAImages.ICONS.loading()); private HTML txtLoading = new HTML(""); /** diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/GeoNaSpatialQueryResult.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/GeoNaSpatialQueryResult.java index 6c80e33..d6a315b 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/GeoNaSpatialQueryResult.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/GeoNaSpatialQueryResult.java @@ -24,7 +24,7 @@ public class GeoNaSpatialQueryResult implements Serializable { private static final long serialVersionUID = 3513120677727206958L; private List features; private LayerObject sourceLayerObject; - // Map with couple (mongoId concessione, list of uploaded Images for the concessione) + // Map with couple (mongoId concessione, list of uploaded GNAImages for the concessione) private Map> mapImages = null; /** diff --git a/src/main/webapp/GeoportalDataViewer.css b/src/main/webapp/GeoportalDataViewer.css index 2ca51d9..eadce10 100644 --- a/src/main/webapp/GeoportalDataViewer.css +++ b/src/main/webapp/GeoportalDataViewer.css @@ -386,4 +386,42 @@ body { .map-layers-radio label { margin-left: 5px; padding-top: 5px; -} \ No newline at end of file +} + + +/************ INTERNAL MAP***************/ + +.internalMap { + height: 280px; + display: inline-block; + margin: 0 auto; + + /*float: right;*/ +} + +.map-style { + width: 100%; + margin-top: 10px; + margin-bottom: 20px; + text-align: center; +} + +.baseLayersMapLink { + width: 100%; + text-align: left; + left: 40px; + top: 40px; + z-index: 10; +} + +.baseLayersMapLink .btn-link { + border: 1px solid #eee; + background-color: #fcfcfc; + margin: 1px; +} + +.baseLayersMapLink .btn-link:hover, .inner-toolbar .btn-link:focus { + background-color: #f3f3f3 !important; + text-decoration: none; +} + \ No newline at end of file -- 2.17.1 From bec8e3afc68ad0d5f2e773dd862a94bf439e4be3 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Tue, 16 Nov 2021 14:49:59 +0100 Subject: [PATCH 08/14] updated map icon and css --- .../client/gis/LightOpenLayerMap.java | 22 +++++++++++------- .../client/resources/map.png | Bin 318 -> 500 bytes src/main/webapp/GeoportalDataViewer.css | 5 ++-- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/LightOpenLayerMap.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/LightOpenLayerMap.java index 5a54555..9d8be3b 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/LightOpenLayerMap.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/LightOpenLayerMap.java @@ -29,6 +29,7 @@ import ol.MapOptions; import ol.OLFactory; import ol.View; import ol.ViewOptions; +import ol.color.Color; import ol.control.Attribution; import ol.event.EventListener; import ol.geom.Point; @@ -49,8 +50,12 @@ import ol.source.Osm; import ol.source.Source; import ol.source.Xyz; import ol.source.XyzOptions; +import ol.style.Fill; +import ol.style.FillOptions; import ol.style.Icon; import ol.style.IconOptions; +import ol.style.Stroke; +import ol.style.StrokeOptions; import ol.style.Style; import ol.style.Text; import ol.style.TextOptions; @@ -405,14 +410,15 @@ public class LightOpenLayerMap { if (showCoordinateText) { TextOptions textOptions = new TextOptions(); textOptions.setOffsetY(-25); -// StrokeOptions strokeOptions = new StrokeOptions(); -// strokeOptions.setColor(new Color(0, 0, 255, 0.0)); -// strokeOptions.setWidth(4); -// Stroke stroke = new Stroke(strokeOptions); -// textOptions.setStroke(stroke); -// FillOptions fillOptions = new FillOptions(); -// fillOptions.setColor(new Color(0, 0, 0, 0.0)); -// textOptions.setFill(new Fill(fillOptions)); + StrokeOptions strokeOptions = new StrokeOptions(); + strokeOptions.setColor(new Color(255, 255, 255, 1.0)); + strokeOptions.setWidth(4); + Stroke stroke = new Stroke(strokeOptions); + stroke.setWidth(5); + textOptions.setStroke(stroke); + FillOptions fillOptions = new FillOptions(); + fillOptions.setColor(new Color(0, 0, 255, 1.0)); + textOptions.setFill(new Fill(fillOptions)); Coordinate transfCoord = MapUtils.transformCoordiante(coordinate, MAP_PROJECTION.EPSG_3857.getName(), MAP_PROJECTION.EPSG_4326.getName()); diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/resources/map.png b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/resources/map.png index fc9aef5bb0708e23b4d0b4f696c074a094e544d4..da4854a01dbab38de8bfcc75803ecc7c778a2e60 100644 GIT binary patch delta 451 zcmV;!0X+V`0`vnRiBL{Q4GJ0x0000DNk~Le0000H0000F2nGNE00OZj5s@Jp3jlur z004ghxVFrRkwzzf0dYx0K~y-6ozgvPR8bJd@!#CU7!w03ifAVoQ}_X_gj7~`7QxEW zLR*lIj~{_Yy)YtJcsLkPFrj>mr> z;gvLkW4NjG#Dpu-f<*X?3up_UR5lgPOK+ssFi4X)ju+CJailNU5H4b}S6vzwE~$JK zMit%{byI-?(+X{qi3sPA{8K7^x~lE#XfUi4)eLZ^lfDjV_8Ge%AS8#U1}82Wep zCnV+mkZ72H_ETqfNLA+>RHZwqokm?Kgdfsd-A&w0DZR$JG$x(Jvl?1;Av>n9fi2;s zsB58;p5udX0xLG1R+y1a;vLq}H`?XAEUng=j|d-e7z-w>xgI}z-urpbwprZ4cym8i t@{o=>VFt@e58aLJJ=$b3&j_o(0D8}LtO+;OCIA2m002ovPDHLkV1h;0#LoZ# delta 267 zcmV+m0rdX#1HJ+wiBL{Q4GJ0x0000DNk~Le0000G0000F2nGNE0PS;6FOeY{3kt;m z01Cwcv?^dQkwzzf0J}*m+Z=*A0#US>52Gjqo_>`Hw!{BR+Sg!`|5DBKpyq%C1mN7`Q*|HgrIU1~~olywFE z1%F1cSXXd{VNLH<7)x)$Y&nSPy39jGTYA7ATEdg!*?CN>-c4@%a4NNh<|i+E$ RJ*WTx002ovPDHLkV1j3SZ!-V@ diff --git a/src/main/webapp/GeoportalDataViewer.css b/src/main/webapp/GeoportalDataViewer.css index eadce10..e1e40e2 100644 --- a/src/main/webapp/GeoportalDataViewer.css +++ b/src/main/webapp/GeoportalDataViewer.css @@ -415,8 +415,9 @@ body { } .baseLayersMapLink .btn-link { - border: 1px solid #eee; - background-color: #fcfcfc; + /*border: 1px solid #eee;*/ + border: 1px solid #005580; + /*background-color: #fcfcfc;*/ margin: 1px; } -- 2.17.1 From bba75e70b8eba9e10e58d8a98e1042647376665a Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Tue, 16 Nov 2021 17:05:58 +0100 Subject: [PATCH 09/14] improved css --- .../client/ui/map/MapView.java | 39 ++++++++++++++----- .../client/ui/map/MapView.ui.xml | 4 +- src/main/webapp/GeoportalDataViewer.css | 28 ++++++++++--- 3 files changed, 54 insertions(+), 17 deletions(-) diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/map/MapView.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/map/MapView.java index ced856c..5fde1df 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/map/MapView.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/map/MapView.java @@ -24,6 +24,7 @@ import com.google.gwt.uibinder.client.UiBinder; import com.google.gwt.uibinder.client.UiField; import com.google.gwt.user.client.Random; import com.google.gwt.user.client.ui.Composite; +import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.HTMLPanel; import com.google.gwt.user.client.ui.HorizontalPanel; import com.google.gwt.user.client.ui.RadioButton; @@ -58,7 +59,7 @@ public class MapView extends Composite { HTMLPanel panelBaseLayers; @UiField - HTMLPanel theMap; + HTMLPanel theMapPanel; @UiField DropdownButton linkMap; @@ -67,6 +68,8 @@ public class MapView extends Composite { HorizontalPanel coordinatePanel; private LightOpenLayerMap lightOLSM; + + private HTML attributionDiv = null; private String theMapId = null; @@ -79,9 +82,9 @@ public class MapView extends Composite { public MapView(Coordinate centerTo, int zoom, String internalMapWidth, String internalMapHeight) { initWidget(uiBinder.createAndBindUi(this)); theMapId = "map" + Random.nextInt(); - theMap.getElement().setId(theMapId); - theMap.setWidth(internalMapWidth); - theMap.setHeight(internalMapHeight); + theMapPanel.getElement().setId(theMapId); + theMapPanel.setWidth(internalMapWidth); + theMapPanel.setHeight(internalMapHeight); linkMap.setCustomIconStyle(GNAIcons.CustomIconType.MAP.get()); @@ -101,7 +104,7 @@ public class MapView extends Composite { }); } - public void setBaseLayers() { + protected void setBaseLayers() { List listBaseLayers = GeoportalDataViewer.getListBaseMapLayers(); if(listBaseLayers==null) @@ -117,15 +120,15 @@ public class MapView extends Composite { radio.setText(baseMapLayer.getName()); if(i==0) { radio.setValue(true, false); + setMapAttribution(baseMapLayer); } radio.addValueChangeHandler(new ValueChangeHandler() { @Override public void onValueChange(ValueChangeEvent event) { - //applicationBus.fireEvent(new ChangeMapLayerEvent(baseMapLayer)); lightOLSM.changeBaseMap(baseMapLayer); - + setMapAttribution(baseMapLayer); } }); @@ -137,6 +140,22 @@ public class MapView extends Composite { } } + + private void setMapAttribution(BaseMapLayer baseMapLayer) { + + if(attributionDiv!=null) + theMapPanel.remove(attributionDiv); + + String attributionHTML = "
" + + baseMapLayer.getAttribution() + "
"; + attributionDiv = new HTML(); + + // THE OSM Contributors are automatically added by gwt-ol, others ones not. + if (!baseMapLayer.getType().equals(BaseMapLayer.OL_BASE_MAP.OSM)) { + attributionDiv.setHTML(attributionHTML); + theMapPanel.add(attributionDiv); + } + } private void setMapSize() { @@ -144,8 +163,8 @@ public class MapView extends Composite { @Override public void execute() { - int width = theMap.getParent().getOffsetWidth(); - int height = theMap.getParent().getOffsetHeight(); + int width = theMapPanel.getParent().getOffsetWidth(); + int height = theMapPanel.getParent().getOffsetHeight(); if (width == 0) width = 300; @@ -153,7 +172,7 @@ public class MapView extends Composite { height = 300; GWT.log("Internal Map w: " + width + ", h: " + height); - theMap.setSize(width + "px", height + "px"); + theMapPanel.setSize(width + "px", height + "px"); } }); } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/map/MapView.ui.xml b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/map/MapView.ui.xml index bec7a40..b24e854 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/map/MapView.ui.xml +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/map/MapView.ui.xml @@ -6,9 +6,9 @@ - + + addStyleNames="base-internal-layers-maplink" ui:field="linkMap"> diff --git a/src/main/webapp/GeoportalDataViewer.css b/src/main/webapp/GeoportalDataViewer.css index e1e40e2..09f8556 100644 --- a/src/main/webapp/GeoportalDataViewer.css +++ b/src/main/webapp/GeoportalDataViewer.css @@ -372,8 +372,26 @@ body { margin: 0px 0px; padding: 2px 4px; background: white; + border-radius: 4px 0 0; } +.map-internal-credits { + width: 100%; + max-height: 25px; + position: relative; +} + +.map-internal-credits-container { + bottom: 0; + right: 0; + position: absolute; + display: block; + padding: 2px 4px; + background: white; + border-radius: 4px 0 0; +} + + .map-layers-radio { margin-left: 5px; } @@ -391,7 +409,7 @@ body { /************ INTERNAL MAP***************/ -.internalMap { +.internal-map { height: 280px; display: inline-block; margin: 0 auto; @@ -406,22 +424,22 @@ body { text-align: center; } -.baseLayersMapLink { +.base-internal-layers-maplink { width: 100%; text-align: left; - left: 40px; + left: 45px; top: 40px; z-index: 10; } -.baseLayersMapLink .btn-link { +.base-internal-layers-maplink .btn-link { /*border: 1px solid #eee;*/ border: 1px solid #005580; /*background-color: #fcfcfc;*/ margin: 1px; } -.baseLayersMapLink .btn-link:hover, .inner-toolbar .btn-link:focus { +.base-internal-layers-maplink .btn-link:hover, .inner-toolbar .btn-link:focus { background-color: #f3f3f3 !important; text-decoration: none; } -- 2.17.1 From bb64769b51c46a7f5d427f593d79730a5908574a Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Thu, 18 Nov 2021 15:55:05 +0100 Subject: [PATCH 10/14] integrated Base Maps into GNABaseMaps Runtime Resource --- .settings/org.eclipse.wst.common.component | 30 +++-- .../client/GeoportalDataViewer.java | 15 ++- .../server/GNABaseMapsResourceReader.java | 111 ++++++++++++++++++ .../GeoportalDataViewerServiceImpl.java | 45 ++++--- .../IAMClientCredentialsReader.java | 2 +- .../server/util/SessionUtil.java | 29 +++++ src/main/webapp/GeoportalDataViewer.css | 2 +- src/main/webapp/GeoportalDataViewer.html | 2 +- .../user/geoportaldataviewer/GNABaseMaps.java | 29 +++++ 9 files changed, 229 insertions(+), 36 deletions(-) create mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/GNABaseMapsResourceReader.java create mode 100644 src/test/java/org/gcube/portlets/user/geoportaldataviewer/GNABaseMaps.java diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component index 72174ae..af45588 100644 --- a/.settings/org.eclipse.wst.common.component +++ b/.settings/org.eclipse.wst.common.component @@ -1,31 +1,41 @@ - + + - + + - + + - + + - + + - + + - + + - + + - + + - + + diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewer.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewer.java index bf75a85..b749d7e 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewer.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewer.java @@ -42,6 +42,8 @@ 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.core.client.ScriptInjector; +import com.google.gwt.dom.client.Style; +import com.google.gwt.dom.client.Style.Unit; import com.google.gwt.event.logical.shared.ResizeEvent; import com.google.gwt.event.logical.shared.ResizeHandler; import com.google.gwt.event.shared.HandlerManager; @@ -95,7 +97,7 @@ public class GeoportalDataViewer implements EntryPoint { int attempt = 0; - private LoaderIcon loaderApp = new LoaderIcon("Loading application...."); + //private LoaderIcon loaderApp = new LoaderIcon("Loading application...."); private HTML attributionDiv = new HTML(); @@ -106,7 +108,10 @@ public class GeoportalDataViewer implements EntryPoint { */ public void onModuleLoad() { - loaderApp.getElement().getStyle().setZIndex(100); +// Style style = loaderApp.getElement().getStyle(); +// style.setZIndex(300); +// style.setMarginTop(50,Unit.PX); +// style.setMarginLeft(50, Unit.PX); paramWmsRequest = Window.Location.getParameter(GeoportalDataViewerConstants.GET_WMS_PARAMETER); paramGeonaItemType = Window.Location.getParameter(GeoportalDataViewerConstants.GET_GEONA_ITEM_TYPE); @@ -117,7 +122,7 @@ public class GeoportalDataViewer implements EntryPoint { GWT.log(GeoportalDataViewerConstants.GET_GEONA_ITEM_ID + " = " + paramGeonaItemID); GWT.log(GeoportalDataViewerConstants.GET_LAYER_TITLE + " = " + paramLayerTitle); - RootPanel.get(APP_DIV).add(loaderApp); + //RootPanel.get(APP_DIV).add(loaderApp); mainPanel = new GeonaDataViewMainPanel(applicationBus, getClientHeight()); RootPanel.get(APP_DIV).add(mainPanel); @@ -132,13 +137,13 @@ public class GeoportalDataViewer implements EntryPoint { @Override public void onFailure(Throwable caught) { - RootPanel.get(APP_DIV).remove(loaderApp); + //RootPanel.get(APP_DIV).remove(loaderApp); Window.alert("Error occurred on instancing the GeoPortale Viewer. Please, contact the support"); } @Override public void onSuccess(List listBaseMapLayers) { - RootPanel.get(APP_DIV).remove(loaderApp); + //RootPanel.get(APP_DIV).remove(loaderApp); GeoportalDataViewer.listBaseMapLayers = listBaseMapLayers; //now the map is loaded and I'm sure that I can load the GeonaDataViewer Profile loadGeonaDataViewerProfile(); diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/GNABaseMapsResourceReader.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/GNABaseMapsResourceReader.java new file mode 100644 index 0000000..20a6291 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/GNABaseMapsResourceReader.java @@ -0,0 +1,111 @@ +package org.gcube.portlets.user.geoportaldataviewer.server; + +import static org.gcube.resources.discovery.icclient.ICFactory.clientFor; +import static org.gcube.resources.discovery.icclient.ICFactory.queryFor; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import org.gcube.common.encryption.StringEncrypter; +import org.gcube.common.resources.gcore.ServiceEndpoint; +import org.gcube.common.resources.gcore.ServiceEndpoint.AccessPoint; +import org.gcube.common.scope.api.ScopeProvider; +import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BaseMapLayer; +import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BaseMapLayer.OL_BASE_MAP; +import org.gcube.resources.discovery.client.api.DiscoveryClient; +import org.gcube.resources.discovery.client.queries.api.SimpleQuery; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * The Class GNABaseMapsResourceReader. + * + * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it + * + * Nov 18, 2021 + */ +public class GNABaseMapsResourceReader { + + private static Logger LOG = LoggerFactory.getLogger(GNABaseMapsResourceReader.class); + + private static final String SE_PROFILE_NAME = "GNABaseMaps"; + private static final String SE_CATEGORY_NAME = "Application"; + + /** + * Gets the list base maps. + * + * @return the list base maps + * @throws Exception the exception + */ + public static List getListBaseMaps() throws Exception { + + List lstBaseMaps = new ArrayList(); + + LOG.info("Searching SE in the scope: " + ScopeProvider.instance.get() + " with profile name: " + SE_PROFILE_NAME + + " and category name: " + SE_CATEGORY_NAME); + + SimpleQuery query = queryFor(ServiceEndpoint.class); + query.addCondition("$resource/Profile/Name/text() eq '" + SE_PROFILE_NAME + "'"); + query.addCondition("$resource/Profile/Category/text() eq '" + SE_CATEGORY_NAME + "'"); + + DiscoveryClient client = clientFor(ServiceEndpoint.class); + List resources = client.submit(query); + + if (resources.size() > 0) + LOG.info("The query returned " + resources.size() + " ServiceEndpoint/s"); + else + throw new RuntimeException("ServiceEndpoint not found. Searching for profile name: " + SE_PROFILE_NAME + + " and category name: " + SE_CATEGORY_NAME + "in the scope: " + ScopeProvider.instance.get()); + + ServiceEndpoint se = resources.get(0); + Collection theAccessPoints = se.profile().accessPoints().asCollection(); + for (AccessPoint accessPoint : theAccessPoints) { + BaseMapLayer bml = new BaseMapLayer(); + bml.setName(accessPoint.name()); + bml.setAttribution(accessPoint.description()); + String url = accessPoint.address(); + String apiTokenName = accessPoint.username(); + String apiTokenPwd = accessPoint.password(); + LOG.debug("Found API_TOKEN name: " + apiTokenName + ", encrypted token: " + apiTokenPwd); + // decrypting the pwd + try { + if (isValorized(apiTokenPwd)) { + apiTokenPwd = StringEncrypter.getEncrypter().decrypt(apiTokenPwd); + LOG.debug("Token decrypted is: " + apiTokenPwd.substring(0, apiTokenPwd.length() / 2) + + "_MASKED_TOKEN_"); + } + } catch (Exception e) { + throw new RuntimeException("Error on decrypting the pwd: ", e); + } + if (isValorized(apiTokenName) && isValorized(apiTokenPwd)) { + url = String.format("%s?%s=%s", url, apiTokenName, apiTokenPwd); + } + bml.setUrl(url); + + // SETTING MAP TYPE + String urlLower = bml.getUrl().toLowerCase(); + if (urlLower.contains("mapbox")) { + bml.setType(OL_BASE_MAP.MAPBOX); + } else if (urlLower.contains("openstreetmap")) { + bml.setType(OL_BASE_MAP.OSM); + } else + bml.setType(OL_BASE_MAP.OTHER); + + lstBaseMaps.add(bml); + } + + LOG.debug("Read base maps: "+lstBaseMaps); + LOG.info("Returning " + lstBaseMaps.size() + " base maps"); + return lstBaseMaps; + + } + + private static boolean isValorized(String value) { + if (value != null && !value.isEmpty()) { + return true; + } + return false; + } + +} diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/GeoportalDataViewerServiceImpl.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/GeoportalDataViewerServiceImpl.java index de501bf..b633d94 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/GeoportalDataViewerServiceImpl.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/GeoportalDataViewerServiceImpl.java @@ -322,8 +322,7 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme if (layerPosizionamento != null) { if (!GeoNACheckAccessPolicy.isAccessible(layerPosizionamento.getPolicy(), userName)) { concessionDV.setPosizionamentoScavo(null); - } else { - LOG.info("Posizionamento di Scavo is not accessible by current user"); + LOG.info("Posizionamento di Scavo is not accessible by current user: "+userName); } } @@ -333,6 +332,8 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme for (LayerConcessioneDV layerDV : listLayersDV) { if (GeoNACheckAccessPolicy.isAccessible(layerDV.getPolicy(), userName)) { accessibleListLayersDV.add(layerDV); + }else { + LOG.info("(Pianta) Layer "+layerDV.getLayerName()+" is not accessible by current user: "+userName); } } concessionDV.setPianteFineScavo(accessibleListLayersDV); @@ -342,6 +343,7 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme if (abstractRS != null) { if (!GeoNACheckAccessPolicy.isAccessible(abstractRS.getPolicy(), userName)) { concessionDV.setAbstractRelazioneScavo(null); + LOG.info("Abstract relazione is not accessible by current user: "+userName); } } @@ -349,6 +351,7 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme if (relazioneScavo != null) { if (!GeoNACheckAccessPolicy.isAccessible(relazioneScavo.getPolicy(), userName)) { concessionDV.setRelazioneScavo(null); + LOG.info("Relazione scavo is not accessible by current user: "+userName); } } @@ -361,6 +364,8 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme if (GeoNACheckAccessPolicy.isAccessible(uploadedImageDV.getPolicy(), userName)) { accessibleListImages.add(uploadedImageDV); + }else { + LOG.info("Immagine "+uploadedImageDV.getTitolo()+" is not accessible by current user: "+userName); } } @@ -664,24 +669,28 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme @Override public List getListBaseLayers() { - + LOG.info("getListBaseLayers called"); List listBL = new ArrayList(); - - // OSM - String attribution = "© OpenStreetMap"; - BaseMapLayer baseLayer = new BaseMapLayer("Open Street Map", "https://tile.openstreetmap.org/{z}/{x}/{y}.png", attribution, - BaseMapLayer.OL_BASE_MAP.OSM); - - listBL.add(baseLayer); + //Setting scope in the cuurent thread + SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true); + listBL = SessionUtil.getGNABaseMaps(this.getThreadLocalRequest()); - - // MAPBOX - attribution = "© Mapbox © OpenStreetMap Improve this map"; - baseLayer = new BaseMapLayer("MapBox Satellite", - "https://{a-d}.tiles.mapbox.com/v4/mapbox.satellite/{z}/{x}/{y}.png?access_token=pk.eyJ1IjoiZDRzY2llbmNlIiwiYSI6ImNpcW1nZjE4MDAwMXNod25rdHJsemRoNTQifQ.YPNkNLb8EzjThpvJl1tg4w", - attribution, BaseMapLayer.OL_BASE_MAP.MAPBOX); - - listBL.add(baseLayer); + LOG.info("getListBaseLayers returning "+listBL.size() +" base maps"); +// +// String attribution; +// BaseMapLayer baseLayer; +// // OSM +// attribution = "© OpenStreetMap"; +// baseLayer = new BaseMapLayer("Open Street Map", "https://tile.openstreetmap.org/{z}/{x}/{y}.png", attribution, +// BaseMapLayer.OL_BASE_MAP.OSM); +// listBL.add(baseLayer); +// // MAPBOX +// attribution = "© Mapbox © OpenStreetMap Improve this map"; +// baseLayer = new BaseMapLayer("MapBox Satellite", +// "https://{a-d}.tiles.mapbox.com/v4/mapbox.satellite/{z}/{x}/{y}.png?access_token=pk.eyJ1IjoiZDRzY2llbmNlIiwiYSI6ImNpcW1nZjE4MDAwMXNod25rdHJsemRoNTQifQ.YPNkNLb8EzjThpvJl1tg4w", +// attribution, BaseMapLayer.OL_BASE_MAP.MAPBOX); +// +// listBL.add(baseLayer); return listBL; diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/IAMClientCredentialsReader.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/IAMClientCredentialsReader.java index 6df98b6..3b10b94 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/IAMClientCredentialsReader.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/IAMClientCredentialsReader.java @@ -17,7 +17,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * The Class IAMClientCredentialsReader. + * The Class GNABaseMapsResourceReader. * * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it * diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/util/SessionUtil.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/util/SessionUtil.java index b99787c..301178d 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/util/SessionUtil.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/util/SessionUtil.java @@ -3,12 +3,16 @@ */ package org.gcube.portlets.user.geoportaldataviewer.server.util; +import java.util.List; + import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; import org.gcube.common.authorization.library.provider.SecurityTokenProvider; import org.gcube.common.portal.PortalContext; import org.gcube.common.scope.api.ScopeProvider; +import org.gcube.portlets.user.geoportaldataviewer.server.GNABaseMapsResourceReader; +import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BaseMapLayer; import org.gcube.portlets.user.urlshortener.UrlShortener; import org.gcube.vomanagement.usermanagement.GroupManager; import org.gcube.vomanagement.usermanagement.exception.GroupRetrievalFault; @@ -34,6 +38,7 @@ public class SessionUtil { private static Logger LOG = LoggerFactory.getLogger(SessionUtil.class); private static final String URL_SHORTENER_SERVICE = "URL_SHORTENER_SERVICE"; + private static final String LIST_BASE_MAPS_LAYERS = "LIST_BASE_MAPS_LAYERS"; /** * Checks if is into portal. @@ -168,4 +173,28 @@ public class SessionUtil { return shortener; } + + /** + * Gets the GNA base maps. + * + * @param httpServletRequest the http servlet request + * @return the GNA base maps + */ + public static List getGNABaseMaps(HttpServletRequest httpServletRequest) { + HttpSession session = httpServletRequest.getSession(); + List lstBML = null; + try { + lstBML = (List) session.getAttribute(LIST_BASE_MAPS_LAYERS); + + if (lstBML == null) { + GNABaseMapsResourceReader gnaBMRR = new GNABaseMapsResourceReader(); + lstBML = gnaBMRR.getListBaseMaps(); + session.setAttribute(LIST_BASE_MAPS_LAYERS, lstBML); + } + + } catch (Exception e) { + LOG.warn("Error occurred reading the base maps by " + GNABaseMapsResourceReader.class.getSimpleName(), e); + } + return lstBML; + } } diff --git a/src/main/webapp/GeoportalDataViewer.css b/src/main/webapp/GeoportalDataViewer.css index 09f8556..e2ad823 100644 --- a/src/main/webapp/GeoportalDataViewer.css +++ b/src/main/webapp/GeoportalDataViewer.css @@ -434,7 +434,7 @@ body { .base-internal-layers-maplink .btn-link { /*border: 1px solid #eee;*/ - border: 1px solid #005580; + border: 2px solid rgba(255,255,255,.4); /*background-color: #fcfcfc;*/ margin: 1px; } diff --git a/src/main/webapp/GeoportalDataViewer.html b/src/main/webapp/GeoportalDataViewer.html index 6050d5f..72a7ebd 100644 --- a/src/main/webapp/GeoportalDataViewer.html +++ b/src/main/webapp/GeoportalDataViewer.html @@ -31,7 +31,7 @@ -Web Application Starter Project +GNA Data Viewer Application diff --git a/src/test/java/org/gcube/portlets/user/geoportaldataviewer/GNABaseMaps.java b/src/test/java/org/gcube/portlets/user/geoportaldataviewer/GNABaseMaps.java new file mode 100644 index 0000000..b1bd0cf --- /dev/null +++ b/src/test/java/org/gcube/portlets/user/geoportaldataviewer/GNABaseMaps.java @@ -0,0 +1,29 @@ +package org.gcube.portlets.user.geoportaldataviewer; + +import java.util.List; + +import org.gcube.common.scope.api.ScopeProvider; +import org.gcube.portlets.user.geoportaldataviewer.server.GNABaseMapsResourceReader; +import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BaseMapLayer; +import org.junit.Test; + +public class GNABaseMaps { + + private static final String SCOPE = "/gcube/devsec/devVRE"; + + @Test + public void readBaseMaps() { + System.out.println("called readBaseMaps test"); + ScopeProvider.instance.set(SCOPE); + GNABaseMapsResourceReader gnaBaseMapsR = new GNABaseMapsResourceReader(); + List lstBML = null; + try { + lstBML = gnaBaseMapsR.getListBaseMaps(); + } catch (Exception e) { + e.printStackTrace(); + } + + System.out.println("Read base map layers: " + lstBML); + } + +} -- 2.17.1 From 846a303ff2231386405f12d51fd3c6910b5edf54 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Fri, 19 Nov 2021 11:20:42 +0100 Subject: [PATCH 11/14] fixed css rules --- .../client/GeoportalDataViewer.java | 3 --- .../client/resources/baseIcons.css | 12 ++++++------ 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewer.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewer.java index b749d7e..4293700 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewer.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewer.java @@ -32,7 +32,6 @@ import org.gcube.portlets.user.geoportaldataviewer.client.gis.ExtentWrapped; import org.gcube.portlets.user.geoportaldataviewer.client.gis.MapUtils; import org.gcube.portlets.user.geoportaldataviewer.client.gis.OpenLayerMap; import org.gcube.portlets.user.geoportaldataviewer.client.ui.GeonaDataViewMainPanel; -import org.gcube.portlets.user.geoportaldataviewer.client.util.LoaderIcon; import org.gcube.portlets.user.geoportaldataviewer.client.util.URLUtil; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BaseMapLayer; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.GeoQuery; @@ -42,8 +41,6 @@ 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.core.client.ScriptInjector; -import com.google.gwt.dom.client.Style; -import com.google.gwt.dom.client.Style.Unit; import com.google.gwt.event.logical.shared.ResizeEvent; import com.google.gwt.event.logical.shared.ResizeHandler; import com.google.gwt.event.shared.HandlerManager; diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/resources/baseIcons.css b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/resources/baseIcons.css index 8630120..d209eca 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/resources/baseIcons.css +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/resources/baseIcons.css @@ -4,22 +4,22 @@ gwt-image: "map"; display: inline-block; vertical-align: middle; - margin-bottom: 3px; - margin-right: 2px; + width: 17px !important; + height: 17px !important; } @sprite .myBaseIcon_preset_location { gwt-image: "preset_location"; display: inline-block; vertical-align: middle; - margin-bottom: 3px; - margin-right: 2px; + width: 17px !important; + height: 17px !important; } @sprite .myBaseIcon_layers { gwt-image: "layers"; display: inline-block; vertical-align: middle; - margin-bottom: 3px; - margin-right: 2px; + width: 17px !important; + height: 17px !important; } \ No newline at end of file -- 2.17.1 From 74e21e9962460206d24e77eb6ee4bd82a78aab7a Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Fri, 19 Nov 2021 15:02:48 +0100 Subject: [PATCH 12/14] Added Application Loader --- .../client/GeoportalDataViewer.java | 25 ++++++++++++------- src/main/webapp/GeoportalDataViewer.css | 7 ++++++ 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewer.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewer.java index 4293700..0cd2df8 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewer.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewer.java @@ -32,6 +32,7 @@ import org.gcube.portlets.user.geoportaldataviewer.client.gis.ExtentWrapped; import org.gcube.portlets.user.geoportaldataviewer.client.gis.MapUtils; import org.gcube.portlets.user.geoportaldataviewer.client.gis.OpenLayerMap; import org.gcube.portlets.user.geoportaldataviewer.client.ui.GeonaDataViewMainPanel; +import org.gcube.portlets.user.geoportaldataviewer.client.util.LoaderIcon; import org.gcube.portlets.user.geoportaldataviewer.client.util.URLUtil; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BaseMapLayer; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.GeoQuery; @@ -41,6 +42,10 @@ 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.core.client.ScriptInjector; +import com.google.gwt.dom.client.Style; +import com.google.gwt.dom.client.Style.Display; +import com.google.gwt.dom.client.Style.Position; +import com.google.gwt.dom.client.Style.Unit; import com.google.gwt.event.logical.shared.ResizeEvent; import com.google.gwt.event.logical.shared.ResizeHandler; import com.google.gwt.event.shared.HandlerManager; @@ -94,7 +99,7 @@ public class GeoportalDataViewer implements EntryPoint { int attempt = 0; - //private LoaderIcon loaderApp = new LoaderIcon("Loading application...."); + private LoaderIcon loaderApp = new LoaderIcon("Loading application... please wait"); private HTML attributionDiv = new HTML(); @@ -104,11 +109,9 @@ public class GeoportalDataViewer implements EntryPoint { * This is the entry point method. */ public void onModuleLoad() { - -// Style style = loaderApp.getElement().getStyle(); -// style.setZIndex(300); -// style.setMarginTop(50,Unit.PX); -// style.setMarginLeft(50, Unit.PX); + + loaderApp.getElement().addClassName("loader-gna-app"); + RootPanel.get(APP_DIV).add(loaderApp); paramWmsRequest = Window.Location.getParameter(GeoportalDataViewerConstants.GET_WMS_PARAMETER); paramGeonaItemType = Window.Location.getParameter(GeoportalDataViewerConstants.GET_GEONA_ITEM_TYPE); @@ -119,7 +122,7 @@ public class GeoportalDataViewer implements EntryPoint { GWT.log(GeoportalDataViewerConstants.GET_GEONA_ITEM_ID + " = " + paramGeonaItemID); GWT.log(GeoportalDataViewerConstants.GET_LAYER_TITLE + " = " + paramLayerTitle); - //RootPanel.get(APP_DIV).add(loaderApp); + RootPanel.get(APP_DIV).add(loaderApp); mainPanel = new GeonaDataViewMainPanel(applicationBus, getClientHeight()); RootPanel.get(APP_DIV).add(mainPanel); @@ -134,13 +137,17 @@ public class GeoportalDataViewer implements EntryPoint { @Override public void onFailure(Throwable caught) { - //RootPanel.get(APP_DIV).remove(loaderApp); + RootPanel.get(APP_DIV).remove(loaderApp); Window.alert("Error occurred on instancing the GeoPortale Viewer. Please, contact the support"); } @Override public void onSuccess(List listBaseMapLayers) { - //RootPanel.get(APP_DIV).remove(loaderApp); + try { + RootPanel.get(APP_DIV).remove(loaderApp); + }catch (Exception e) { + loaderApp.setVisible(false); + } GeoportalDataViewer.listBaseMapLayers = listBaseMapLayers; //now the map is loaded and I'm sure that I can load the GeonaDataViewer Profile loadGeonaDataViewerProfile(); diff --git a/src/main/webapp/GeoportalDataViewer.css b/src/main/webapp/GeoportalDataViewer.css index e2ad823..ae17cf6 100644 --- a/src/main/webapp/GeoportalDataViewer.css +++ b/src/main/webapp/GeoportalDataViewer.css @@ -443,4 +443,11 @@ body { background-color: #f3f3f3 !important; text-decoration: none; } + +.loader-gna-app { + z-index: 50; + position: absolute; + top: 50%; + left: 50%; +} \ No newline at end of file -- 2.17.1 From 709270015b5409b335c560bd1b43bc915416483e Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Mon, 22 Nov 2021 10:25:09 +0100 Subject: [PATCH 13/14] Added link "Open Project" in the pop-up of WFS feature --- CHANGELOG.md | 3 +- README.md | 2 +- .../client/GeoportalDataViewer.java | 6 +-- .../client/LayerManager.java | 38 +++++++++++++++++++ .../server/GNABaseMapsResourceReader.java | 2 +- .../GeoportalDataViewerServiceImpl.java | 18 --------- 6 files changed, 43 insertions(+), 26 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 58dcb6d..95a8e22 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,8 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm #### Enhancements -- [#22370] Use a max-height for preview image shown in the pop-up +- [#22027] Integrated with MapBox Satellite +- Added link "Open Project" in the pop-up of WFS details - Moved to gwt-ol3 v8.1.0-gwt2_9 ## [v2.0.1] - 2021-11-10 diff --git a/README.md b/README.md index 86ee60d..7ae475e 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ The GeoPortal Data Viewer App is an application to access, discovery and navigat * GWT v.2.9.0. [GWT](http://www.gwtproject.org) is licensed under [Apache License 2.0](http://www.gwtproject.org/terms.html) * GWT-Bootstrap v.2.3.2.0. [GWT-Bootstrap](https://github.com/gwtbootstrap) is licensed under [[Apache License 2.0](http://www.apache.org/licenses/LICENSE-2.0) -* GWT-OpenLayers 3+ v.8.0.0-gwt2_9. [GWT-OL3](https://github.com/TDesjardins/gwt-ol) +* GWT-OpenLayers 3+ v.8.1.0-gwt2_9. [GWT-OL3](https://github.com/TDesjardins/gwt-ol) * OpenLayers v.6.X. [OpenLayers](https://openlayers.org/) is licensed under [BSD 2-Clause "Simplified"](https://github.com/openlayers/openlayers/blob/main/LICENSE.md) ## Documentation diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewer.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewer.java index 0cd2df8..9dd16d9 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewer.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewer.java @@ -42,10 +42,6 @@ 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.core.client.ScriptInjector; -import com.google.gwt.dom.client.Style; -import com.google.gwt.dom.client.Style.Display; -import com.google.gwt.dom.client.Style.Position; -import com.google.gwt.dom.client.Style.Unit; import com.google.gwt.event.logical.shared.ResizeEvent; import com.google.gwt.event.logical.shared.ResizeHandler; import com.google.gwt.event.shared.HandlerManager; @@ -138,7 +134,7 @@ public class GeoportalDataViewer implements EntryPoint { @Override public void onFailure(Throwable caught) { RootPanel.get(APP_DIV).remove(loaderApp); - Window.alert("Error occurred on instancing the GeoPortale Viewer. Please, contact the support"); + Window.alert("Sorry, an error occurred on instancing the GeoPortale Viewer. Please, contact the support"); } @Override diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/LayerManager.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/LayerManager.java index e26aab3..aefc67f 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/LayerManager.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/LayerManager.java @@ -57,6 +57,7 @@ import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.Element; import com.google.gwt.user.client.Event; import com.google.gwt.user.client.EventListener; +import com.google.gwt.user.client.Random; import com.google.gwt.user.client.Window; import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.FlexTable; @@ -558,6 +559,8 @@ public class LayerManager { flowPanel.getElement().getStyle().setProperty("maxHeight", "600px"); scrollPanel.add(flowPanel); + List