|
Map Suite gives you the ability to customize your map in a multitude of ways. For example, you can add gradient fills to your area shapes, add custom bitmaps to your point shapes, and create multicolor line shapes. In addition, depending on your zoom level, you can set up multiple thresholds to change all of the renderers.
While these approaches can help you create a professional and vibrant map, there might be situations, depending on the extent of the map (i.e. zoomed out a great deal), where your complex renderers may cause a large increase in rendering time or the zoom level may make the map too small for normal use. Therefore, the solution to keeping the map looking professional is proper use of thresholds and restricting the user from reaching undesirable extents.
In the following example, we are restricting the user from zooming to an extent with a width of less than 2 kilometers or a width of greater than 2500 kilometers. The map will simply return to its previous extent if these requirements are not met.
Please note that on the load event, the map (Current Extent) has not yet been created, so we need to wait until the map has been rendered the first time.
VB.NET
'Form Level Flag
Private mflag As Integer = 0
'Form Load
Private Sub Load()
Map1.Refresh()
mflag = 1
End Sub
Private Sub map1_BeforeLayersDraw(ByVal G As Graphics) Handles map1.BeforeLayersDraw
If (m_flag = 1) Then
If (map1.CurrentExtent.Width(map1.MapUnit, MapLengthUnits.kilometres) < 1) Or (map1.CurrentExtent.Width(map1.MapUnit, MapLengthUnits.kilometres) > 2500) Then
map1.GetPreviousExtent()
End If
End If
End Sub
C#
//Form Level Flag
private int mflag = 0;
//Form Load
private void Load()
{
Map1.Refresh();
mflag = 1;
}
private void map1_BeforeLayersDraw(Graphics G)
{
if (m_flag == 1)
{
if ((map1.CurrentExtent.Width(map1.MapUnit, MapLengthUnits.kilometres) < 2) | (map1.CurrentExtent.Width(map1.MapUnit, MapLengthUnits.kilometres) > 2500))
map1.GetPreviousExtent();
}
}
In addition, you can also restrict where your users can pan by implementing the code below:
VB.NET
Private Sub map1_BeforeLayersDraw(ByVal G As Graphics) Handles map1.BeforeLayersDraw
Dim center As PointR = Map1.CurrentExtent.Centroid
Dim llp As PointR = Map1.FullExtent.LowerLeftPoint
Dim lrp As PointR = Map1.FullExtent.LowerRightPoint
Dim ulp As PointR = Map1.FullExtent.UpperLeftPoint
Dim urp As PointR = Map1.FullExtent.UpperRightPoint
If (center.X > lrp.X) Or center.X < llp.X Or center.Y > urp.Y Or center.Y < llp.Y Then
Map1.GetPreviousExtent()
End If
End Sub
C#
private void map1_BeforeLayersDraw(Graphics G)
{
private PointR center = Map1.CurrentExtent.Centroid;
private PointR llp = Map1.FullExtent.LowerLeftPoint;
private PointR lrp = Map1.FullExtent.LowerRightPoint;
private PointR ulp = Map1.FullExtent.UpperLeftPoint;
private PointR urp = Map1.FullExtent.UpperRightPoint;
if ((center.X > lrp.X) | center.X < llp.X | center.Y > urp.Y | center.Y < llp.Y)
Map1.GetPreviousExtent();
}
|