ThinkGeo.com    |     Documentation    |     Premium Support

OnCurrentExtentChanged() is not working in Blazor app

<MapView Id="map" @ref="@map" 
MapViewSizeUnitType="MapViewSizeUnitType.Percentage" 
MapUnit="@ThinkGeo.Core.GeographyUnit.Meter"
         Center="@torringtonCenterPoint"
         Zoom="15" 
Width="100" 
Height="100" OnCurrentExtentChanged="OnMapExtentChanged" 
BackgroundColor="@(GeoColor.FromHtml("#ffffffff"))">
    <OverlaysSetting>
        <LayerOverlay id="customoverlay" TileCache="@tileCache"></LayerOverlay>
        @*<layeroverlay id="vectorlayer" layers="@vlayers"></layeroverlay>*@
    </OverlaysSetting>
    <MapToolsSetting>
        <MapTools>
            <ZoomBarMapTool Location="ZoomBarLocation.LowerRight" />
        </MapTools>
    </MapToolsSetting>
</MapView>

@code{

public MapView? map;
private PointShape torringtonCenterPoint = new PointShape(-8137421.8, 5133000.0);
private FileRasterTileCache tileCache = new FileRasterTileCache("./Data/MapTileCache", "PNG", RasterTileFormat.Png);

protected override void OnInitialized()
{
}
protected override void OnAfterRender(bool firstRender)
{
    mapControl.generalControl.Scale = "34353";
}
private void OnMapExtentChanged()
{
    mapControl.generalControl.Scale = "5345";
}

OnAfterRender() is working, but OnMapExtentChanged() is not working.
Please help me.
Thanks.

Hey @willson_sam,

For your code, it looks like you need to add the CurrentExtentChangedMapViewEventArgs to the OnMapExtentChanged() method. It should look like:

private void OnMapExtentChanged(CurrentExtentChangedMapViewEventArgs args)
{
    mapControl.generalControl.Scale = "5345";
}

Thanks,
Kyle

1 Like

Thanks. Kyle_Day!
I have resolved from your help.

Hey @willson_sam,

Good to hear! Closing.

Thanks,
Kyle