Hi,
I'm having a problem in understanding how the MinScale property of MapView works. In attached picture, I have given MapView.MinScale a value but I can still zoom further out. However, setting MaxScale works fine and I cannot zoom further in than the given value. What is the difference in their functionality? I noticed that I can limit the zooming by setting a max extent but it does not work in a way I would like it to work.
Regards,
Tuukka Järvinen
Solved! Go to Solution.
I dug a little deeper into this and think you've uncovered an issue with the API. It appears that in order for the MinScale assignment to take effect, the MapView SpatialReference has to be established first. To test this you can take your MinScale assignment out of the XAML and move it to a MapView.SpatialReferenceChanged event handler hooked to the MapView in the code-behind:
MyMapView.SpatialReferenceChanged += (s, e) => { MyMapView.MinScale = 15000; };
That should give you the effect you're looking for - zoom should be limited by MinScale. You can also use your ViewModel to do the same thing, just make sure the MapView has a SpatialReference before setting MinScale.
I'll log an issue for this in our internal system. Thanks for posting.
Both MinScale and MaxScale should limit zooming in one direction or the other. I'm not sure why that isn't working for you. Could you share some code for your test app?
Here is some WPF XAML that should demonstrate the zoom limitations of MinScale / MaxScale:
<Grid> <esri:MapView x:Name="MyMapView" WrapAround="False"> <esri:Map> <esri:ArcGISTiledMapServiceLayer ID="Basemap" ServiceUri="http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer"/> </esri:Map> </esri:MapView> <Border Background="White" BorderBrush="Black" BorderThickness="2" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="30" Padding="20"> <StackPanel> <TextBlock Text="MinScale: " FontWeight="Bold" /> <TextBox Text="{Binding ElementName=MyMapView, Path=MinScale}" /> <TextBlock Text="MaxScale: " FontWeight="Bold" /> <TextBox Text="{Binding ElementName=MyMapView, Path=MaxScale}" /> <TextBlock Text="Current Scale: " FontWeight="Bold" Margin="0,10,0,0" /> <TextBox Text="{Binding ElementName=MyMapView, Path=Scale, Mode=OneWay, StringFormat=#}" /> </StackPanel> </Border> </Grid>
Here is my MapView in XAML.
I have also tried to set Min and MaxScale in the associated ViewModel but only the MaxScale seems to work. I also tried the example code that above and it works. The MapViewService is based on Esri Development summit example, could it cause problems with MinScale property?
I dug a little deeper into this and think you've uncovered an issue with the API. It appears that in order for the MinScale assignment to take effect, the MapView SpatialReference has to be established first. To test this you can take your MinScale assignment out of the XAML and move it to a MapView.SpatialReferenceChanged event handler hooked to the MapView in the code-behind:
MyMapView.SpatialReferenceChanged += (s, e) => { MyMapView.MinScale = 15000; };
That should give you the effect you're looking for - zoom should be limited by MinScale. You can also use your ViewModel to do the same thing, just make sure the MapView has a SpatialReference before setting MinScale.
I'll log an issue for this in our internal system. Thanks for posting.
Thanks a lot! I set the MinScale now after I have inserted a map and some layers to MapView so it has a SpatialReference and it works as you said.
Hello,
I have a similar problem. In my program the map is defined dynamically <esri:MapView x:Name="_MapView" Map="{Binding CurrentMap}" ...>
I tired to implement your workaround, but after changeging the map model the MinScale prroperty is loosing its functionallity. The SpatialReferenceChanged Event isnt't fired anymore, because the sptatial references will not change.
Do have any idea what to do now? Why is the MinScale property not working, although the property is set in the MapView?
And why is MaxScale working perfectly?
Regards