From 4eeb6d257935a4a3b43e72297783bdbcbae7aa25 Mon Sep 17 00:00:00 2001 From: Hilbrand Bouwkamp Date: Thu, 8 Feb 2024 19:24:30 +0100 Subject: [PATCH] AER-2688 Enable to set attribution on map/layer (#50) --- .../java/nl/aerius/geo/wui/util/OL3MapLayerFactory.java | 5 ++++- .../src/main/java/nl/aerius/geo/wui/util/OL3MapUtil.java | 6 ++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/gwt-client-geo-ol3/src/main/java/nl/aerius/geo/wui/util/OL3MapLayerFactory.java b/gwt-client-geo-ol3/src/main/java/nl/aerius/geo/wui/util/OL3MapLayerFactory.java index 7c36e82..a3f7e7d 100644 --- a/gwt-client-geo-ol3/src/main/java/nl/aerius/geo/wui/util/OL3MapLayerFactory.java +++ b/gwt-client-geo-ol3/src/main/java/nl/aerius/geo/wui/util/OL3MapLayerFactory.java @@ -82,7 +82,10 @@ public IsLayer prepareLayer(final LayerProps c) { layer.getInfo().setTitle(c.getTitle()); layer.getInfo().setName(c.getName()); layer.getInfo().setBundle(c.getBundleName()); - + final String attribution = c.getAttribution(); + if (attribution != null) { + layer.asLayer().getSource().setAttributions(attribution); + } final Projection projection = layer.asLayer().getSource().getProjection(); if (c.getMinScale() != null && projection != null) { layer.asLayer().setMinResolution(OL3GeometryUtil.scaleToResolution(c.getMinScale(), projection)); diff --git a/gwt-client-geo-ol3/src/main/java/nl/aerius/geo/wui/util/OL3MapUtil.java b/gwt-client-geo-ol3/src/main/java/nl/aerius/geo/wui/util/OL3MapUtil.java index 3c770ef..43b446e 100644 --- a/gwt-client-geo-ol3/src/main/java/nl/aerius/geo/wui/util/OL3MapUtil.java +++ b/gwt-client-geo-ol3/src/main/java/nl/aerius/geo/wui/util/OL3MapUtil.java @@ -30,6 +30,8 @@ import ol.OLFactory; import ol.View; import ol.ViewOptions; +import ol.control.Attribution; +import ol.control.AttributionOptions; import ol.control.Control; import ol.control.MousePosition; import ol.control.ScaleLine; @@ -82,6 +84,10 @@ private static void prepareControls(final Map map, final MapProperties mapProps) map.addControl(new Zoom()); map.addControl(new ZoomSlider()); map.addControl(new ScaleLine()); + final AttributionOptions attributionOptions = new AttributionOptions(); + attributionOptions.setCollapsible(false); + attributionOptions.setCollapsed(false); + map.addControl(new Attribution(attributionOptions)); final MousePosition mousePosition = new MousePosition();