ThinkGeo.com    |     Documentation    |     Premium Support

FeatureLayer doesn't display

I have built a Blazor Map.
This is the code.

@page "/"
<div class="mapview">
    <MapView Id="map" @ref="@map" MapUnit="@mapUnit" MapViewSizeUnitType="MapViewSizeUnitType.Percentage" Center="@centerPoint"
    Zoom="@zoomInt" Width="100" Height="100" OnCurrentExtentChanged="@OnMapExtentChanged" OnMouseMove="@OnMouseMoveEvent">
        <OverlaysSetting>
            <LayerOverlay Id="vectorLayer" Layers="@vectorLayers"></LayerOverlay>
        </OverlaysSetting>
        <MapToolsSetting>
            <MapTools>
                <ZoomBarMapTool Location="ZoomBarLocation.UpperRight"></ZoomBarMapTool>
            </MapTools>
        </MapToolsSetting>
    </MapView>
</div>
<div class="sidebar"></div>

@code{
    private MapView? map;
    private PointShape centerPoint = new PointShape(-8137421, 5133000);
    private int zoomInt = 3;
    private GeographyUnit mapUnit = GeographyUnit.Meter;
    GeoCollection<Layer> vectorLayers = new GeoCollection<Layer>();

    protected override void OnInitialized()
    {
        base.OnInitialized();
        string ConectionStr = "Data Source=(localdb)\\MSSQLLocalDB;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False";
        SqlServerFeatureLayer torringtonLayer = new SqlServerFeatureLayer(ConectionStr, "Vector_Worldcountries", "ID");
        torringtonLayer.Name = "TorringtonVectorLayer";
        torringtonLayer.FeatureSource.ProjectionConverter = new ProjectionConverter(Projection.GetWgs84ProjString(), Projection.GetSphericalMercatorProjString());
        //torringtonLayer.FeatureSource.ProjectionConverter = new ProjectionConverter(2234, 3857);

        torringtonLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = new AreaStyle(new GeoSolidBrush(GeoColor.FromArgb(50, GeoColors.Orange)));
        //torringtonLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle = new TextStyle("Portal_Name", new GeoFont("Arial", 14), new GeoSolidBrush(GeoColor.FromHtml("#21FF00")));
        //torringtonLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle.YOffsetInPixel = 5;
        torringtonLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle.FillBrush = new GeoSolidBrush(GeoColor.FromArgb(50, GeoColors.Orange));
        torringtonLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle.OutlinePen = new GeoPen(GeoColors.Red);
        torringtonLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

        vectorLayers.Add(torringtonLayer);
    }
    private void OnMapExtentChanged(CurrentExtentChangedMapViewEventArgs args)
    {

    }
    private void OnMouseMoveEvent(MouseMovingMapViewEventArgs args)
    {
        
    }
}

But, In my browser doesn’t display.
The country layer that previously appeared on the map no longer suddenly doesn’t appear.

hi @willson_sam,

Your code looks good, maybe you could check if your projection works. And did you see any errors?

Thanks,
Leo

Thanks Leo.
I have resolved that.
It was my fault.
In the connection string, there was no database name string.

Hey @willson_sam,

Ok, glad that you got the issue resolved. Closing.

Thanks,
Kyle