Skip to content

Commit 582f4b5

Browse files
authored
Merge pull request #86 from mh-xdev/bugfix/058_leafletmap-overrides-vaadin
#58 Add HasStyle and z-index
2 parents 1b05ab2 + 1579320 commit 582f4b5

File tree

1 file changed

+15
-2
lines changed
  • vaadin-maps-leaflet-flow/src/main/java/software/xdev/vaadin/maps/leaflet/flow

1 file changed

+15
-2
lines changed

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

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import com.vaadin.flow.component.ComponentEventListener;
3131
import com.vaadin.flow.component.ComponentUtil;
3232
import com.vaadin.flow.component.HasSize;
33+
import com.vaadin.flow.component.HasStyle;
3334
import com.vaadin.flow.component.Tag;
3435
import com.vaadin.flow.component.dependency.JsModule;
3536
import com.vaadin.flow.component.dependency.NpmPackage;
@@ -46,7 +47,7 @@
4647
@NpmPackage(value = "leaflet", version = "^1.6.0")
4748
@Tag("leaflet-map")
4849
@JsModule("./leaflet/leafletCon.js")
49-
public class LMap extends Component implements HasSize
50+
public class LMap extends Component implements HasSize, HasStyle
5051
{
5152

5253
private static final String SET_VIEW_POINT_FUNCTION = "setViewPoint";
@@ -65,6 +66,7 @@ public LMap(final double lat, final double lon, final int zoom)
6566
super();
6667
this.center = new LCenter(lat, lon, zoom);
6768
this.setViewPoint(this.center);
69+
this.setFixZIndexEnabled(true);
6870
}
6971

7072
public LMap()
@@ -86,7 +88,18 @@ public void setTileLayer(final LTileLayer tl)
8688
{
8789
this.getElement().callJsFunction(TILE_LAYER_FUNCTION, tl.toJson());
8890
}
89-
91+
92+
/**
93+
* This fixes situations where the leafletmap overlays components like Dialogs
94+
*
95+
* @param enabled
96+
* enable or disable the fix
97+
*/
98+
protected void setFixZIndexEnabled(final boolean enabled)
99+
{
100+
this.getStyle().set("z-index", enabled ? "1" : null);
101+
}
102+
90103
/**
91104
* add a Leaflet Component to the map.
92105
*

0 commit comments

Comments
 (0)