Gets or sets the maximum scale at which the layer displays.
Syntax
Visual Basic (Declaration) | |
---|
Public Overridable Property MaxScale As String |
Visual Basic (Usage) | Copy Code |
---|
Dim instance As Layer
Dim value As String
instance.MaxScale = value
value = instance.MaxScale |
C# | |
---|
public virtual string MaxScale {get; set;} |
Example
The following example checks whether a layer is visible at the current map scale. If it is not visible, the map is set to match one of either the MinScale or MaxScale, and a map image is drawn and displayed in an image web control. This code assumes an existing MapView.
C# | Copy Code |
---|
FeatureLayer citiesLayer = (FeatureLayer) mapView.Layers.FindByName("Cities");
mapView.Extent = new Envelope(-160, -80, 160, 80);
// If layer is not visible at current scale,
// change extent to one of the scale factors
if (!citiesLayer.IsVisibleAtScale)
{
// At least one of MinScale/MaxScale will be set if layer not visible at this scale
// Note: Conversions assume scales are already in map units/pixel format
// (will fail for dynamic layers if scale set with relative RF format)
double newScale = 0;
if (citiesLayer.MinScale != String.Empty)
newScale = Convert.ToDouble(citiesLayer.MinScale);
else
newScale = Convert.ToDouble(citiesLayer.MaxScale);
// Zoom the map to the new scale by calculating an envelope at this scale
double newWidth = newScale * mapView.ImageDescriptor.Width;
double newHeight = newScale * mapView.ImageDescriptor.Height;
double mapCenterX = (mapView.Extent.XMax + mapView.Extent.XMin) / 2;
double mapCenterY = (mapView.Extent.YMax + mapView.Extent.YMin) / 2;
mapView.Extent = new Envelope(mapCenterX - newWidth / 2, mapCenterY - newHeight / 2,
mapCenterX + newWidth / 2, mapCenterY + newHeight / 2);
}
Image1.ImageUrl = mapView.Draw().Url; |
Visual Basic | Copy Code |
---|
Dim citiesLayer As FeatureLayer = CType(mapView.Layers.FindByName("Cities"), FeatureLayer)
mapView.Extent = New Envelope(-160, -80, 160, 80)
' If layer is not visible at current scale,
' change extent to one of the scale factors
If Not citiesLayer.IsVisibleAtScale
' At least one of MinScale/MaxScale will be set if layer not visible at this scale
' Note: Conversions assume scales are already In map units/pixel Format
' (will fail For dynamic layers if scale set with relative RF Format)
Dim newScale As Double = 0
If citiesLayer.MinScale <> String.Empty Then
newScale = Convert.ToDouble(citiesLayer.MinScale)
Else
newScale = Convert.ToDouble(citiesLayer.MaxScale)
End If
' Zoom the map to the new scale by calculating an envelope at this scale
Dim newWidth As Double = newScale * mapView.ImageDescriptor.Width
Dim newHeight As Double = newScale * mapView.ImageDescriptor.Height
Dim mapCenterX As Double = (mapView.Extent.XMax + mapView.Extent.XMin) / 2
Dim mapCenterY As Double = (mapView.Extent.YMax + mapView.Extent.YMin) / 2
mapView.Extent = New Envelope(mapCenterX - newWidth / 2, mapCenterY - newHeight / 2, _
mapCenterX + newWidth / 2, mapCenterY + newHeight / 2)
End If
Image1.ImageUrl = mapView.Draw().Url |
Remarks
Requirements
Target Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Windows Vista, Windows Server 2008 family
See Also