From bba75e70b8eba9e10e58d8a98e1042647376665a Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Tue, 16 Nov 2021 17:05:58 +0100 Subject: [PATCH] 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; }