Skip to content

Commit 770c6d9

Browse files
authored
Merge pull request #249 from xdev-software/develop
Release 3.0.1
2 parents df03d85 + d35d415 commit 770c6d9

File tree

12 files changed

+76
-101
lines changed

12 files changed

+76
-101
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 3.0.1
2+
* Fixed ``divIcon`` being displayed incorrectly [due to a default ``iconSize`` of ``12px``](https://github.com/Leaflet/Leaflet/issues/4238) #246
3+
* Updated dependencies
4+
* Updated leaflet to [``1.9.4``](https://github.com/Leaflet/Leaflet/blob/b6b56f6e707142c177fad2f67827a5007e56736a/CHANGELOG.md#194-2023-05-18) #247
5+
16
## 3.0.0
27
* Adds support for Vaadin 24+, drops support for Vaadin 23<br/>
38
<i>If you are still using Vaadin 23, use the ``2.x`` versions.</i>

vaadin-maps-leaflet-flow-demo/pom.xml

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,7 @@
1616
<url>https://xdev.software</url>
1717
</organization>
1818

19-
<licenses>
20-
<license>
21-
<name>Apache License, Version 2.0</name>
22-
<url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
23-
</license>
24-
</licenses>
25-
2619
<properties>
27-
<license.licenseName>apache_v2</license.licenseName>
28-
2920
<javaVersion>17</javaVersion>
3021
<maven.compiler.release>${javaVersion}</maven.compiler.release>
3122

@@ -35,9 +26,9 @@
3526
<mainClass>software.xdev.vaadin.Application</mainClass>
3627

3728
<!-- Dependency-Versions -->
38-
<vaadin.version>24.0.5</vaadin.version>
29+
<vaadin.version>24.1.2</vaadin.version>
3930

40-
<org.springframework.boot.version>3.1.0</org.springframework.boot.version>
31+
<org.springframework.boot.version>3.1.1</org.springframework.boot.version>
4132
</properties>
4233

4334
<dependencyManagement>

vaadin-maps-leaflet-flow-demo/src/main/java/software/xdev/vaadin/maps/leaflet/flow/demo/LeafletView.java

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
1414
import com.vaadin.flow.router.Route;
1515

16-
import com.vaadin.flow.router.RouteAlias;
1716
import software.xdev.vaadin.maps.leaflet.flow.LMap;
1817
import software.xdev.vaadin.maps.leaflet.flow.data.LCenter;
1918
import software.xdev.vaadin.maps.leaflet.flow.data.LCircle;
@@ -35,7 +34,6 @@ public class LeafletView extends VerticalLayout
3534
* UI-Components
3635
*/
3736
private final Button btnLunch = new Button("Where do XDEV employees go for lunch?");
38-
private final Button btnCenter = new Button("Center on Caribbean");
3937
private LMap map;
4038

4139
private LMarker markerZob;
@@ -61,7 +59,9 @@ public LeafletView()
6159
hlButtonContainer.setSpacing(false);
6260
hlButtonContainer.add(
6361
this.btnLunch,
64-
this.btnCenter,
62+
new Button("Center on Caribbean", e -> this.map.centerAndZoom(
63+
new LPoint(14.467727, -61.69703),
64+
new LPoint(16.33426, -60.921676))),
6565
new Button("Open dialog over map", ev ->
6666
{
6767
final Icon icoClose = VaadinIcon.CLOSE.create();
@@ -73,7 +73,6 @@ public LeafletView()
7373

7474
icoClose.addClickListener(iev -> dialog.close());
7575
}));
76-
this.btnCenter.addClickListener(e-> map.centerAndZoom(new LPoint(14.467727, -61.69703), new LPoint(16.33426,-60.921676)));
7776
this.add(this.map, hlButtonContainer);
7877
this.setSizeFull();
7978
}
@@ -106,29 +105,33 @@ private void initMapComponents()
106105

107106
final LMarker markerXDev = new LMarker(49.675806677512824, 12.160990185846394);
108107
final LIcon xDevLogo = new LIcon(
109-
// Important replace # with %23!
110-
"data:image/svg+xml;utf8,<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"1000\" height=\"200\" viewBox=\"0 0 18300 4500\" style=\"background-color:rgba(180,180,180,0.7)\">\n"
111-
+ " <defs>\n"
112-
+ " <style>\n"
113-
+ " .fil0{fill:%23d71e23}\n"
114-
+ " </style>\n"
115-
+ " </defs>\n"
116-
+ " <g>\n"
117-
+ " <path class=\"fil0\" d=\"M9763 10965h-920l-17-6-1503-588-1506 588-11 4-13 2-1562 148-1102 105 1064-369 2311-801-1638-633-683-263h1609l16 6 1515 588 1521-588 10-4 9-1 1388-211 1177-178-1131 441-2177 849 1675 647 682 264zM25514 9520l-1909 1442-22 17h-693l-23-19-1765-1440-285-233h907l22 17 1490 1178 1395-1177 23-19h1171zM20426 10961h-4015V9260h4126l-1 127-1 99v126h-112l-3041-3 2 322 3038 3h110l2 124 1 83 2 128h-3146v352l3035-6h112v346z\" transform=\"translate(-5400 -7700)\"/>\n"
118-
+ " <path class=\"fil0\" d=\"M10994 9275h2026a12150 12150 0 0 1 1368 73c292 35 559 83 798 143h1c290 73 510 158 659 254 165 106 248 229 248 368 0 134-85 254-254 359-151 94-375 180-672 256-292 76-618 132-977 170-359 37-751 56-1174 56h-2102V9275h79zm917 1354h1106c300 0 574-14 822-41 247-27 469-67 665-121h1a2470 2470 0 0 0 277-96c176-79 264-164 264-256 0-60-39-118-117-173-92-66-234-125-425-178-197-55-418-96-665-123-248-27-522-41-822-41h-1106v1029z\" transform=\"translate(-5400 -7700)\"/>\n"
119-
+ " </g>\n"
120-
+ "</svg>");
108+
"""
109+
data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="1000" height="200" viewBox="0 0 18300 4500" style="background-color:rgba(180,180,180,0.7)">
110+
<defs>
111+
<style>
112+
.fil0{fill:%23d71e23}
113+
</style>
114+
</defs>
115+
<g>
116+
<path class="fil0" d="M9763 10965h-920l-17-6-1503-588-1506 588-11 4-13 2-1562 148-1102 105 1064-369 2311-801-1638-633-683-263h1609l16 6 1515 588 1521-588 10-4 9-1 1388-211 1177-178-1131 441-2177 849 1675 647 682 264zM25514 9520l-1909 1442-22 17h-693l-23-19-1765-1440-285-233h907l22 17 1490 1178 1395-1177 23-19h1171zM20426 10961h-4015V9260h4126l-1 127-1 99v126h-112l-3041-3 2 322 3038 3h110l2 124 1 83 2 128h-3146v352l3035-6h112v346z" transform="translate(-5400 -7700)"/>
117+
<path class="fil0" d="M10994 9275h2026a12150 12150 0 0 1 1368 73c292 35 559 83 798 143h1c290 73 510 158 659 254 165 106 248 229 248 368 0 134-85 254-254 359-151 94-375 180-672 256-292 76-618 132-977 170-359 37-751 56-1174 56h-2102V9275h79zm917 1354h1106c300 0 574-14 822-41 247-27 469-67 665-121h1a2470 2470 0 0 0 277-96c176-79 264-164 264-256 0-60-39-118-117-173-92-66-234-125-425-178-197-55-418-96-665-123-248-27-522-41-822-41h-1106v1029z" transform="translate(-5400 -7700)"/>
118+
</g>
119+
</svg>
120+
""");
121121

122122
xDevLogo.setIconSize(100, 20);
123123
xDevLogo.setIconAnchor(50, 0);
124-
markerXDev.setPopup("<a href='https://xdev.software/en' target='" + AnchorTarget.BLANK.getValue() + "'>XDEV Software GmbH</a>");
124+
markerXDev.setPopup(
125+
"<a href='https://xdev.software/en' target='" + AnchorTarget.BLANK.getValue() + "'>XDEV Software "
126+
+ "GmbH</a>");
125127
markerXDev.setIcon(xDevLogo);
126128

127129
final LMarker markerInfo = new LMarker(49.674095, 12.162257);
128-
final LDivIcon div = new LDivIcon(
129-
"<p><center><b>Welcome to Weiden in der Oberpfalz!</b></center></p><p>This demo shows you different markers,<br> popups, polygons and other stuff</p>");
130130

131-
markerInfo.setDivIcon(div);
131+
markerInfo.setDivIcon(new LDivIcon("""
132+
<p><center><b>Welcome to Weiden in der Oberpfalz!</b></center></p>
133+
<p>This demo shows you different markers,<br> popups, polygons and other stuff</p>
134+
"""));
132135

133136
final LPolygon polygonNoc = new LPolygon(
134137
Arrays.asList(

vaadin-maps-leaflet-flow/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
5050

5151
<!-- Dependency-Versions -->
52-
<vaadin.version>24.0.5</vaadin.version>
52+
<vaadin.version>24.1.2</vaadin.version>
5353
</properties>
5454

5555
<dependencyManagement>
@@ -108,7 +108,7 @@
108108
<dependency>
109109
<groupId>com.fasterxml.jackson.core</groupId>
110110
<artifactId>jackson-databind</artifactId>
111-
<version>2.15.1</version>
111+
<version>2.15.2</version>
112112
</dependency>
113113

114114
<dependency>

vaadin-maps-leaflet-flow/src/main/java/software/xdev/vaadin/maps/leaflet/flow/LMap.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
import software.xdev.vaadin.maps.leaflet.flow.data.LTileLayer;
4848

4949

50-
@NpmPackage(value = "leaflet", version = "1.8.0")
50+
@NpmPackage(value = "leaflet", version = "1.9.4")
5151
@Tag("leaflet-map")
5252
@JsModule("leaflet/dist/leaflet.js")
5353
@CssImport("leaflet/dist/leaflet.css")
@@ -110,15 +110,16 @@ public void setViewPoint(final LCenter viewpoint)
110110
}
111111

112112
/**
113-
* Uses fitBounds https://leafletjs.com/reference.html#map-fitbounds
114-
* to compute zoom level and center coordinates to zoom the map on the given rectangle
115-
* @param noPoint : Top let point on the map
116-
* @param sePoint : Bottom right point on the map
113+
* Uses <a href="https://leafletjs.com/reference.html#map-fitbounds">fitBounds</a> to compute zoom level and center
114+
* coordinates to zoom the map on the given rectangle
115+
*
116+
* @param nwPoint Top let point on the map
117+
* @param sePoint Bottom right point on the map
117118
*/
118-
public void centerAndZoom(final LPoint noPoint, final LPoint sePoint)
119+
public void centerAndZoom(final LPoint nwPoint, final LPoint sePoint)
119120
{
120121
this.getElement().executeJs(CLIENT_MAP + ".fitBounds(["
121-
+ "[" + noPoint.getLat() + ", " + noPoint.getLon() + "],"
122+
+ "[" + nwPoint.getLat() + ", " + nwPoint.getLon() + "],"
122123
+ "[" + sePoint.getLat() + ", " + sePoint.getLon() + "]"
123124
+ "]);");
124125
}

vaadin-maps-leaflet-flow/src/main/java/software/xdev/vaadin/maps/leaflet/flow/data/LCenter.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@ public int getZoom()
4545

4646
/**
4747
* Sets the zoom level at the start
48-
*
49-
* @param zoom
5048
*/
5149
public void setZoom(final int zoom)
5250
{

vaadin-maps-leaflet-flow/src/main/java/software/xdev/vaadin/maps/leaflet/flow/data/LDivIcon.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ public LDivIcon()
3030

3131
/**
3232
* <b>Ensure that you escape the html properly so that you don't accidentally introduce Serverside XSS</b>
33-
*
34-
* @param html
3533
*/
3634
public LDivIcon(final String html)
3735
{
3836
this.setHtml(html);
3937
this.setIconAnchor(0, 0);
38+
// https://github.com/Leaflet/Leaflet/issues/4238
39+
this.setIconSize(null);
4040
}
4141

4242
public String getClassName()
@@ -46,8 +46,6 @@ public String getClassName()
4646

4747
/**
4848
* Sets a className for CSS formating.
49-
*
50-
* @param className
5149
*/
5250
public void setClassName(final String className)
5351
{
@@ -63,8 +61,6 @@ public String getHtml()
6361
* Custom HTML code to put inside the div element, empty by default. Alternatively, an instance of HTMLElement.
6462
* <br/>
6563
* <b>Ensure that you escape the html properly so that you don't accidentally introduce Serverside XSS</b>
66-
*
67-
* @param html
6864
*/
6965
public void setHtml(final String html)
7066
{

vaadin-maps-leaflet-flow/src/main/java/software/xdev/vaadin/maps/leaflet/flow/data/LIcon.java

Lines changed: 34 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@
1818

1919

2020
import java.util.ArrayList;
21+
import java.util.Collection;
2122
import java.util.List;
23+
import java.util.Optional;
2224

2325
import com.fasterxml.jackson.annotation.JsonInclude;
2426
import com.fasterxml.jackson.annotation.JsonInclude.Include;
@@ -28,8 +30,8 @@ public class LIcon
2830
{
2931
private String iconUrl;
3032

31-
@JsonInclude(Include.NON_EMPTY)
32-
private final List<Integer> iconSize = new ArrayList<>();
33+
@JsonInclude(value = Include.CUSTOM, valueFilter = IconSizeFilter.class)
34+
private List<Integer> iconSize = new ArrayList<>();
3335
private final List<Integer> iconAnchor = new ArrayList<>();
3436
private final List<Integer> popupAnchor = new ArrayList<>();
3537
private String shadowUrl;
@@ -68,8 +70,6 @@ public String getIconUrl()
6870

6971
/**
7072
* Sets a icon url.
71-
*
72-
* @param iconUrl
7373
*/
7474
public void setIconUrl(final String iconUrl)
7575
{
@@ -83,15 +83,15 @@ public List<Integer> getIconSize()
8383

8484
/**
8585
* Icon size with x, y in px
86-
*
87-
* @param x
88-
* @param y
8986
*/
9087
public void setIconSize(final int x, final int y)
9188
{
92-
this.iconSize.clear();
93-
this.iconSize.add(x);
94-
this.iconSize.add(y);
89+
this.setIconSize(new ArrayList<>(List.of(x, y)));
90+
}
91+
92+
public void setIconSize(final List<Integer> iconSize)
93+
{
94+
this.iconSize = iconSize;
9595
}
9696

9797
public List<Integer> getIconAnchor()
@@ -101,9 +101,6 @@ public List<Integer> getIconAnchor()
101101

102102
/**
103103
* Anchor point of the icon in x, y px.
104-
*
105-
* @param x
106-
* @param y
107104
*/
108105
public void setIconAnchor(final int x, final int y)
109106
{
@@ -119,9 +116,6 @@ public List<Integer> getPopupAnchor()
119116

120117
/**
121118
* Anchor point of the Pop-up message in x,y px.
122-
*
123-
* @param x
124-
* @param y
125119
*/
126120
public void setPopupAnchor(final int x, final int y)
127121
{
@@ -164,4 +158,28 @@ public void setShadowAnchor(final int x, final int y)
164158
this.shadowAnchor.add(x);
165159
this.shadowAnchor.add(y);
166160
}
161+
162+
public static class IconSizeFilter
163+
{
164+
@SuppressWarnings("java:S1206") // Filter only uses equals
165+
@Override
166+
public boolean equals(final Object obj)
167+
{
168+
// true = filter out; false = keep
169+
170+
// Null is allowed
171+
if(obj == null)
172+
{
173+
return false;
174+
}
175+
176+
// Filter out empty collection
177+
return Optional.of(obj)
178+
.filter(Collection.class::isInstance)
179+
.map(Collection.class::cast)
180+
.map(Collection::isEmpty)
181+
// Wrong type (not a collection)
182+
.orElse(true);
183+
}
184+
}
167185
}

vaadin-maps-leaflet-flow/src/main/java/software/xdev/vaadin/maps/leaflet/flow/data/LMarker.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,6 @@ public class LMarker implements LComponent
3333

3434
/**
3535
* Creates a new Marker at the latitude, longitude
36-
*
37-
* @param lat
38-
* @param lon
3936
*/
4037
public LMarker(final double lat, final double lon)
4138
{
@@ -118,8 +115,6 @@ public String getPopup()
118115

119116
/**
120117
* Sets a Pop-up to the Marker
121-
*
122-
* @param popup
123118
*/
124119
public void setPopup(final String popup)
125120
{

0 commit comments

Comments
 (0)