DotSpatial使用说明.pdf
DotspatialDotspatial 开发文档开发文档1.1.图层加载图层加载引用类引用类:DotSpatial。Controlspublic virtual IMapLayer AddLayer();使用:使用:Map。AddLayer();2.2.图层放大图层放大引用类:引用类:DotSpatial。Controlspublic void ZoomIn();使用:使用:appManager。Map。FunctionMode=FunctionMode。ZoomOut;3.3.图层缩小图层缩小引用类:引用类:DotSpatial。Controlspublic void ZoomOut();使用:使用:Map。ZoomOut();4.4.全屏显示全屏显示引用类:引用类:DotSpatial.Controlspublic void ZoomToMaxExtent();使用:使用:Map.ZoomToMaxExtent();5.5.前一视图前一视图引用类引用类:DotSpatial。Controlspublic void ZoomToPrevious();使用:使用:Map。ZoomToPrevious();6.6.后一视图后一视图引用类引用类:DotSpatial.Controlspublic void ZoomToNext();使用使用:Map。ZoomToNext();7.7.平移平移引用类:引用类:DotSpatial。Controlspublic Function Mode Function Mode get;set;使用使用:Map。Function Mode=FunctionMode。Pan;8.8.点查询点查询引用类:引用类:DotSpatial。Controlspublic Function Mode Function Mode get;set;使用:使用:Map.Function Mode=FunctionMode.Info;9.9.框选框选引用类:引用类:DotSpatial.ControlsDotSpatial.Topology使用使用:Map_MouseDownGeoMouseArgs args=new GeoMouseArgs(e,map);/屏幕坐标到地图坐标转换_startPoint=e.Location;/屏幕起始点坐标_geoStartPoint=args.GeographicLocation;/地图起始点坐标Map_MouseUpGeoMouseArgs args=new GeoMouseArgs(e,map);/屏幕坐标到地图坐标转换IEnvelope env=new Envelope(_geoStartPoint.X,args.GeographicLocation.X,_geoStartPoint。Y,args。GeographicLocation.Y);/在地图坐标系中定义二维矩形区域Map。ViewExtents=env.ToExtent();/将二维矩形区域作为地图可视区域10.10.距离测量距离测量引用类:引用类:DotSpatial.ControlsDotSpatial。Plugins.Measure使用:使用:MapFunctionMeasure XXXXX=new MapFunctionMeasure(map);XXXXX.Activate();11.11.坐标定位坐标定位引用类引用类:using:usingDotSpatial.Controls使用使用:ZoomToCoordinatesDialog XXXXX=new ZoomToCoordinatesDialog(map);XXXXX.ShowDialog();12.12.鼠标移动显示地图坐标鼠标移动显示地图坐标Map_MouseMove/将地图和坐标函数绑定GeoMouseArgs args=new GeoMouseArgs(e,map);/求 X、Y 轴坐标string xpanel=String。Format(”X:0:0.00000”,args。GeographicLocation.X);string ypanel=String。Format(Y:0:0.00000”,args。GeographicLocation.Y);this.CoordateLabel。Text=xpanel+”+ypanel;13.13.草图功能草图功能1)1)画点画点/设置当前状态为画点状态_state=MapState。DrawPoint;/将点图层设置为当前选中图层_pointLayer。LockDispose();map.Layers。Remove(_pointLayer);_pointLayer。Projection=_mapBox.Projection;map.Layers。Add(_pointLayer);map.Layers.SelectedLayer=_pointLayer;_pointLayer.UnlockDispose();/画点的具体实现_addShape。Layer=_pointLayer;_addShape。Activate();2)2)画线画线/设置当前状态为画线状态_state=MapState。DrawLine;/将线图层设置为当前选中图层_lineLayer。LockDispose();map.Layers。Remove(_lineLayer);_lineLayer。Projection=_mapBox.Projection;map。Layers。Add(_lineLayer);map.Layers.SelectedLayer=_lineLayer;_lineLayer。UnlockDispose();/画线的具体实现_addShape.Layer=_lineLayer;_addShape.Activate();3)3)画面画面/设置当前状态为画面状态_state=MapState.DrawPolygon;/将面图层设置为当前选中图层_polygonLayer。LockDispose();map。Layers.Remove(_polygonLayer);_polygonLayer.Projection=_mapBox。Projection;map。Layers.Add(_polygonLayer);map。Layers。SelectedLayer=_polygonLayer;_polygonLayer.UnlockDispose();/画面的具体实现_addShape.Layer=_polygonLayer;_addShape.Activate();4)4)清除清除/清除点线面信息clearPointLayer();clearLineLayer();clearPolygonLayer();/清除点线面图层_pointLayer。LockDispose();map。Layers。Remove(_pointLayer);_pointLayer.UnlockDispose();_lineLayer。LockDispose();map.Layers.Remove(_lineLayer);_lineLayer。UnlockDispose();_polygonLayer。LockDispose();map。Layers.Remove(_polygonLayer);_polygonLayer。UnlockDispose();14.14.地图编辑地图编辑1)1)编辑工具编辑工具引用类:引用类:DotSpatial.Controlspublic Function Mode Function Mode get;set;使用使用:Map.Function Mode=FunctionMode。select;2)2)创建特征创建特征/根据选中图层选择画点、画线、还是画面_addShapeFunction=new AddShapeFunction(map)Name=”AddShape”;map。MapFunctions.Add(_addShapeFunction);_addShapeFunction.Layer=_activeLayer;SetSnapLayers(_addShapeFunction);_addShapeFunction.Activate();private void SetSnapLayers(SnappableMapFunction func)func.DoSnapping=this。_doSnapping;if(!this。_doSnapping)return;foreach(var layer in _geoMap.Layers)IFeatureLayer fl=layer as IFeatureLayer;if(fl!=null&fl!=_activeLayer fl。DataSet.FeatureType!=_activeLayer。DataSet.FeatureType)func.AddLayerToSnap(fl);3)3)属性表属性表引用类引用类:DotSpatial。Symbology;DotSpatial。Symbology.Form;使用:使用:/选择当前图层_activeLayer=map。Layers。SelectedLayer as IFeatureLayer;/显示当前图层属性FeatureLayerActions XXXXX=new FeatureLayerActions();XXXXX。ShowAttributes(_activeLayer);4)4)保存编辑保存编辑引用类:引用类:DotSpatial.Symbology;DotSpatial.Symbology.Form;使用使用:/选择当前图层_activeLayer=map.Layers.SelectedLayer as IFeatureLayer;/将当前图层信息导出FeatureLayerActions XXXXX=new FeatureLayerActions();XXXXX.ExportData(_activeLayer);