diff --git a/src/dymaptic.GeoBlazor.Core/Components/Views/MapView.razor.cs b/src/dymaptic.GeoBlazor.Core/Components/Views/MapView.razor.cs
index 303ba7a5..4ce18ef2 100644
--- a/src/dymaptic.GeoBlazor.Core/Components/Views/MapView.razor.cs
+++ b/src/dymaptic.GeoBlazor.Core/Components/Views/MapView.razor.cs
@@ -1339,9 +1339,10 @@ public async Task AddLayer(Layer layer, bool isBasemapLayer = false)
{
Map!.Layers.Add(layer);
layer.Parent ??= Map;
- layer.JsModule ??= ViewJsModule;
}
+ layer.JsModule ??= ViewJsModule;
+
if (ViewJsModule is null) return;
if (ProJsViewModule is not null && layer.GetType().Namespace!.Contains("Pro"))
diff --git a/test/dymaptic.GeoBlazor.Core.Test.Blazor.Shared/Components/BaseMapTests.razor b/test/dymaptic.GeoBlazor.Core.Test.Blazor.Shared/Components/BaseMapTests.razor
index e91d10f2..710fb397 100644
--- a/test/dymaptic.GeoBlazor.Core.Test.Blazor.Shared/Components/BaseMapTests.razor
+++ b/test/dymaptic.GeoBlazor.Core.Test.Blazor.Shared/Components/BaseMapTests.razor
@@ -4,7 +4,35 @@
base.BuildRenderTree(__builder);
}
-@code {
+@code {
+ [TestMethod]
+ public async Task TestCanSetBaseMapLayerVisibility(Action renderHandler)
+ {
+ MapView? mapView = null;
+ async Task OnViewInitialized()
+ {
+ await mapView!.AddLayer(new ImageryTileLayer() { Url = "https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer" }, isBasemapLayer: true );
+ }
+ AddMapRenderFragment(
+ @
+
+ );
+
+ await WaitForMapToRender();
+
+ ImageryTileLayer? imageryTileLayer = mapView!.Map!.Basemap!.Layers.OfType().SingleOrDefault();
+
+ Assert.IsNotNull(imageryTileLayer);
+ Assert.IsNotNull(imageryTileLayer.JsModule);
+
+ await imageryTileLayer.SetVisibility(false);
+
+ Assert.IsFalse(imageryTileLayer.Visible);
+ }
[TestMethod]
public async Task TestCanRenderArcGisDefaultBasemap(Action renderHandler)