Skip to content

Commit b6f8cb9

Browse files
committed
Enhance JLImageOverlayBuilder to set bounds using JLLatLng for improved coordinate handling
Signed-off-by: makbn <[email protected]>
1 parent ac7d9da commit b6f8cb9

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

jlmap-api/src/main/java/io/github/makbn/jlmap/model/builder/JLImageOverlayBuilder.java

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import io.github.makbn.jlmap.model.JLBounds;
44
import io.github.makbn.jlmap.model.JLImageOverlay;
5+
import io.github.makbn.jlmap.model.JLLatLng;
56
import lombok.AccessLevel;
67
import lombok.experimental.FieldDefaults;
78

@@ -20,6 +21,7 @@ public JLImageOverlayBuilder setImageUrl(String imageUrl) {
2021

2122
/**
2223
* Set bounds using two double arrays: [lat, lng] for southwest and northeast corners.
24+
* First item is southwest and second is northeast.
2325
*/
2426
public JLImageOverlayBuilder setBounds(List<double[]> bounds) {
2527
if (bounds == null || bounds.size() != 2)
@@ -62,10 +64,27 @@ public String buildJsElement() {
6264

6365
@Override
6466
public JLImageOverlay buildJLObject() {
67+
// first element is southWest [lat, lng]
68+
var southWest = JLLatLng.builder()
69+
.lat(bounds.get(0)[0])
70+
.lng(bounds.get(0)[1])
71+
.build();
72+
73+
// second element is northEast [lat, lng]
74+
var northEast = JLLatLng.builder()
75+
.lat(bounds.get(1)[0])
76+
.lng(bounds.get(1)[1])
77+
.build();
78+
79+
var jlBounds = JLBounds.builder()
80+
.northEast(northEast)
81+
.southWest(southWest)
82+
.build();
83+
6584
return JLImageOverlay.builder()
6685
.id(uuid)
6786
.imageUrl(imageUrl)
68-
.bounds(JLBounds.builder().build())
87+
.bounds(jlBounds)
6988
.options(jlOptions)
7089
.transport(transporter)
7190
.build();

0 commit comments

Comments
 (0)