improved css

This commit is contained in:
Francesco Mangiacrapa 2021-11-16 17:05:58 +01:00
parent bec8e3afc6
commit bba75e70b8
3 changed files with 54 additions and 17 deletions

View File

@ -24,6 +24,7 @@ import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField; import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.Random; import com.google.gwt.user.client.Random;
import com.google.gwt.user.client.ui.Composite; 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.HTMLPanel;
import com.google.gwt.user.client.ui.HorizontalPanel; import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.RadioButton; import com.google.gwt.user.client.ui.RadioButton;
@ -58,7 +59,7 @@ public class MapView extends Composite {
HTMLPanel panelBaseLayers; HTMLPanel panelBaseLayers;
@UiField @UiField
HTMLPanel theMap; HTMLPanel theMapPanel;
@UiField @UiField
DropdownButton linkMap; DropdownButton linkMap;
@ -68,6 +69,8 @@ public class MapView extends Composite {
private LightOpenLayerMap lightOLSM; private LightOpenLayerMap lightOLSM;
private HTML attributionDiv = null;
private String theMapId = null; private String theMapId = null;
/** /**
@ -79,9 +82,9 @@ public class MapView extends Composite {
public MapView(Coordinate centerTo, int zoom, String internalMapWidth, String internalMapHeight) { public MapView(Coordinate centerTo, int zoom, String internalMapWidth, String internalMapHeight) {
initWidget(uiBinder.createAndBindUi(this)); initWidget(uiBinder.createAndBindUi(this));
theMapId = "map" + Random.nextInt(); theMapId = "map" + Random.nextInt();
theMap.getElement().setId(theMapId); theMapPanel.getElement().setId(theMapId);
theMap.setWidth(internalMapWidth); theMapPanel.setWidth(internalMapWidth);
theMap.setHeight(internalMapHeight); theMapPanel.setHeight(internalMapHeight);
linkMap.setCustomIconStyle(GNAIcons.CustomIconType.MAP.get()); linkMap.setCustomIconStyle(GNAIcons.CustomIconType.MAP.get());
@ -101,7 +104,7 @@ public class MapView extends Composite {
}); });
} }
public void setBaseLayers() { protected void setBaseLayers() {
List<BaseMapLayer> listBaseLayers = GeoportalDataViewer.getListBaseMapLayers(); List<BaseMapLayer> listBaseLayers = GeoportalDataViewer.getListBaseMapLayers();
if(listBaseLayers==null) if(listBaseLayers==null)
@ -117,15 +120,15 @@ public class MapView extends Composite {
radio.setText(baseMapLayer.getName()); radio.setText(baseMapLayer.getName());
if(i==0) { if(i==0) {
radio.setValue(true, false); radio.setValue(true, false);
setMapAttribution(baseMapLayer);
} }
radio.addValueChangeHandler(new ValueChangeHandler<Boolean>() { radio.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
@Override @Override
public void onValueChange(ValueChangeEvent<Boolean> event) { public void onValueChange(ValueChangeEvent<Boolean> event) {
//applicationBus.fireEvent(new ChangeMapLayerEvent(baseMapLayer));
lightOLSM.changeBaseMap(baseMapLayer); lightOLSM.changeBaseMap(baseMapLayer);
setMapAttribution(baseMapLayer);
} }
}); });
@ -138,14 +141,30 @@ public class MapView extends Composite {
} }
private void setMapAttribution(BaseMapLayer baseMapLayer) {
if(attributionDiv!=null)
theMapPanel.remove(attributionDiv);
String attributionHTML = "<div class='map-internal-credits'><div class='map-internal-credits-container'>"
+ baseMapLayer.getAttribution() + "</div></div>";
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() { private void setMapSize() {
Scheduler.get().scheduleDeferred(new ScheduledCommand() { Scheduler.get().scheduleDeferred(new ScheduledCommand() {
@Override @Override
public void execute() { public void execute() {
int width = theMap.getParent().getOffsetWidth(); int width = theMapPanel.getParent().getOffsetWidth();
int height = theMap.getParent().getOffsetHeight(); int height = theMapPanel.getParent().getOffsetHeight();
if (width == 0) if (width == 0)
width = 300; width = 300;
@ -153,7 +172,7 @@ public class MapView extends Composite {
height = 300; height = 300;
GWT.log("Internal Map w: " + width + ", h: " + height); GWT.log("Internal Map w: " + width + ", h: " + height);
theMap.setSize(width + "px", height + "px"); theMapPanel.setSize(width + "px", height + "px");
} }
}); });
} }

View File

@ -6,9 +6,9 @@
</ui:style> </ui:style>
<g:HTMLPanel addStyleNames="map-style"> <g:HTMLPanel addStyleNames="map-style">
<g:HTMLPanel ui:field="theMap" addStyleNames="internalMap"> <g:HTMLPanel ui:field="theMapPanel" addStyleNames="internal-map">
<b:DropdownButton type="LINK" title="Select the Map" <b:DropdownButton type="LINK" title="Select the Map"
addStyleNames="baseLayersMapLink" ui:field="linkMap"> addStyleNames="base-internal-layers-maplink" ui:field="linkMap">
<g:HTMLPanel ui:field="panelBaseLayers"> <g:HTMLPanel ui:field="panelBaseLayers">
</g:HTMLPanel> </g:HTMLPanel>
</b:DropdownButton> </b:DropdownButton>

View File

@ -372,8 +372,26 @@ body {
margin: 0px 0px; margin: 0px 0px;
padding: 2px 4px; padding: 2px 4px;
background: white; 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 { .map-layers-radio {
margin-left: 5px; margin-left: 5px;
} }
@ -391,7 +409,7 @@ body {
/************ INTERNAL MAP***************/ /************ INTERNAL MAP***************/
.internalMap { .internal-map {
height: 280px; height: 280px;
display: inline-block; display: inline-block;
margin: 0 auto; margin: 0 auto;
@ -406,22 +424,22 @@ body {
text-align: center; text-align: center;
} }
.baseLayersMapLink { .base-internal-layers-maplink {
width: 100%; width: 100%;
text-align: left; text-align: left;
left: 40px; left: 45px;
top: 40px; top: 40px;
z-index: 10; z-index: 10;
} }
.baseLayersMapLink .btn-link { .base-internal-layers-maplink .btn-link {
/*border: 1px solid #eee;*/ /*border: 1px solid #eee;*/
border: 1px solid #005580; border: 1px solid #005580;
/*background-color: #fcfcfc;*/ /*background-color: #fcfcfc;*/
margin: 1px; 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; background-color: #f3f3f3 !important;
text-decoration: none; text-decoration: none;
} }