public void NewMapTest1() { MapControl control = new MapControl(); Assert.IsNotNull(control, "初始化控件失败"); control.MapLayer = new MapByScalesLayer("1", "a", _url, _name, new double[] {1.0/40000000,1.0/20000000,1.0/10000000,1.0/5000000,1.0/2500000 }); Assert.IsNotNull(control.Scales, "初始化比例尺失败"); Assert.IsTrue(control.Zoom == 0, "初始缩放级别不为0"); Assert.IsTrue(control.Center != null, "初始化中心点失败"); Assert.IsTrue(control.Center.X == 96.1736997712 && control.Center.Y == 27.5734580668, "初始化中心点坐标不为地图默认中心点"); Assert.IsTrue(control.Bounds != null, "地图初始化范围为空"); Assert.IsTrue(control.Bounds.LeftBottom.X == -180 && control.Bounds.LeftBottom.Y == -90 && control.Bounds.RightTop.X == 180 && control.Bounds.RightTop.Y == 90, "初始化地图范围不正确"); control.PropertyChanged += new MapPropertyChangedHandler(control_PropertyChanged); control.Zoom += 1; }
/// <summary> /// 加载地图控件。 /// </summary> /// <param name="mapControl">需要操作的地图控件。</param> public virtual void OnLoad(MapControl mapControl) { Map = mapControl; Map.MouseDoubleClick += new MouseButtonEventHandler(Map_MouseDoubleClick); Map.MouseDown += new MouseButtonEventHandler(Map_MouseDown); Map.MouseEnter += new System.Windows.Input.MouseEventHandler(Map_MouseEnter); Map.MouseLeave += new System.Windows.Input.MouseEventHandler(Map_MouseLeave); Map.MouseLeftButtonDown += new MouseButtonEventHandler(Map_MouseLeftButtonDown); Map.MouseLeftButtonUp += new MouseButtonEventHandler(Map_MouseLeftButtonUp); Map.MouseMove += new MouseEventHandler(Map_MouseMove); Map.MouseRightButtonDown += new MouseButtonEventHandler(Map_MouseRightButtonDown); Map.MouseRightButtonUp += new MouseButtonEventHandler(Map_MouseRightButtonUp); Map.MouseUp += new MouseButtonEventHandler(Map_MouseUp); Map.MouseWheel += new MouseWheelEventHandler(Map_MouseWheel); Map.KeyDown += new System.Windows.Input.KeyEventHandler(Map_KeyDown); Map.KeyUp += new System.Windows.Input.KeyEventHandler(Map_KeyUp); }
/// <summary> /// 加载对应的地图控件。 /// </summary> /// <param name="mapControl">需要加载的地图控件。</param> public override void OnLoad(MapControl mapControl) { base.OnLoad(mapControl); ActionDescription = "拖动地图"; }