If m_TempLayer.AllFeatures.Count = 0 Then '矩形边框还没有 '设置矩形边框样式 Set tempStyle = New MapXLib.Style tempStyle.RegionPattern = miPatternNoFill tempStyle.RegionBorderColor = 255 tempStyle.RegionBorderWidth = 2 '在临时图层添加大小为Map1的边界的Rectangle对象 Set tempFea = Map2.FeatureFactory.CreateRegion(Map1.Bounds, tempStyle) Set m_Fea = m_TempLayer.AddFeature(tempFea) Set tempStyle = Nothing Else '根据Map1的视野变化改变矩形边框的大小和位置 With m_Fea.Parts.Item(1) .RemoveAll .AddXY Map1.Bounds.XMin, Map1.Bounds.YMin .AddXY Map1.Bounds.XMax, Map1.Bounds.YMin .AddXY Map1.Bounds.XMax, Map1.Bounds.YMax .AddXY Map1.Bounds.XMin, Map1.Bounds.YMax End With m_Fea.Update End If End Sub '下面代码和API方式实现的一样 Private Sub Map2_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) Dim MapX As Double Dim MapY As Double bDown = True Map2.ConvertCoord X, Y, MapX, MapY, miScreenToMap Map1.CenterX = MapX Map1.CenterY = MapY End Sub Private Sub Map2_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) Dim MapX As Double Dim MapY As Double If bDown Then Map2.ConvertCoord X, Y, MapX, MapY, miScreenToMap Map1.CenterX = MapX Map1.CenterY = MapY End If End Sub Private Sub Map2_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single) bDown = False End Sub(责任编辑:admin) |