1

I'd like to show the user the current map scale. I update the current map scale in a textblock everytime the map size/scale has changed. This is my code, to show the map scale (in C#):

private void Map_SizeChanged(object sender, SizeChangedEventArgs e){
    MapScaleTextBlock.Text = String.Format("Scale {0:N}", Map.Scale); //Note: It has to be formatted
}

and here is the xaml code:

<TextBlock Name="MapScaleTextBlock"></TextBlock>

The output is always this:

Scale n. def.

Whats wrong? I searched already but I found nothing helpful.

I'm using ESRI API for WPF and C# in Visual Studio 2010.

0

Have done it myself

It's not defined, because the method Map_SizeChanged(...) is not called in the initialization, it's called later. Got to put it somewhere else

EDIT:

Got to put it in here:

<esri:Map x:Name ="Map" ExtentChanged="Map_ExtentChanged" ... > ... </esri:Map>

and call it like this:

private void Map_ExtentChanged(object sender, ExtentEventArgs e){
    bool mustZoomToFullExtent = (e.NewExtent.Width > fullMapExtent.Width) || (e.NewExtent.Height > fullMapExtent.Height);
    if (mustZoomToFullExtent)
    {
        ZoomToFullExtent();
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.