|
15 | 15 | */ |
16 | 16 | @FieldDefaults(level = AccessLevel.PRIVATE, makeFinal = true) |
17 | 17 | public class JLUiLayer extends JLLayer implements LeafletUILayerInt { |
18 | | - JLTransporter transporter; |
| 18 | + JLTransporter<Object> transporter; |
19 | 19 |
|
20 | 20 | public JLUiLayer(JLWebEngine<Object> engine, JLMapCallbackHandler callbackHandler) { |
21 | 21 | super(engine, callbackHandler); |
@@ -95,8 +95,29 @@ public boolean removePopup(String id) { |
95 | 95 | return Boolean.parseBoolean(result); |
96 | 96 | } |
97 | 97 |
|
| 98 | + /** |
| 99 | + * Adds an image overlay to the map at the specified bounds with the given image URL and options. |
| 100 | + * |
| 101 | + * @param bounds the geographical bounds the image is tied to |
| 102 | + * @param imageUrl URL of the image to be used as an overlay |
| 103 | + * @param options theming options for JLImageOverlay |
| 104 | + * @return the instance of added {@link JLImageOverlay} on the map |
| 105 | + */ |
98 | 106 | @Override |
99 | 107 | public JLImageOverlay addImage(JLBounds bounds, String imageUrl, JLOptions options) { |
100 | | - throw new UnsupportedOperationException(); |
| 108 | + // Convert options to JS object (simple: only opacity and zIndex for demo) |
| 109 | + String optionsJs = String.format("{opacity: %f, zIndex: %d}", |
| 110 | + options.getOpacity(), 1); |
| 111 | + // Call JS function to add image overlay |
| 112 | + String result = engine.executeScript(String.format( |
| 113 | + "addImageOverlay(%s, '%s', %s)", bounds, imageUrl, optionsJs)).toString(); |
| 114 | + JLImageOverlay overlay = JLImageOverlay.builder() |
| 115 | + .transport(transporter) |
| 116 | + .options(options) |
| 117 | + .bounds(bounds) |
| 118 | + .imageUrl(imageUrl) |
| 119 | + .build(); |
| 120 | + callbackHandler.addJLObject(result, overlay); |
| 121 | + return overlay; |
101 | 122 | } |
102 | 123 | } |
0 commit comments