Sharpmap is a GIS map rendering component developed on the. NET platform. A geometric model framework based on OGC Standard is designed in Sharpmap, and a multi source vector map data adapter interface for Iprovider Strategy mode is designed, and the bottom layer of MAP element rendering is mainly changed by geometry. To convert geometry to. NET-supported geometric models such as System.Drawing.Point, System.Drawing.Rectangle, System.Drawing.Drawing2D.GraphicsPath and so on, then calls the System.Drawing.Graphics class draw method to realize the map element drawing. Within the Sharpmap because there is no architecture for symbol design, for the need to develop a real GIS system, you need to encapsulate the symbol architecture to achieve the thematic rendering and map symbol library.
Sharpmap provides us with the most basic functions of the GIS system, such as map visualization, spatial query and so on, so we can use some of the features provided by SHARPMAP to support our map visualization on the. NET platform without the need of some commercial components. This article will introduce some code examples based on SHARPMAP implementation part of the program, hope to study open source friend have enlightenment and help. Note: I have modified the sharpmap part of the bug, redesigned the architecture of the system, and developed some new modules. These will be elaborated in later articles.
Example of developing Windows applications based on Jackey.framework
Initialize the code, call the method in the form Mount event.
private void Init () {//set buddy control.
This.tocControl1.MapControl = This.mapcontrol1;
Create a vector layer and set the default renderer.
SharpMap.Layers.VectorLayer laycity=new SharpMap.Layers.VectorLayer ("City"); Laycity.datasource=new SharpMap.Data.Providers.ShapeFileProvider (@ "D:" ArcGIS "Developerkit" samplesnet "Data"
Gulfofstlawrence "Data" can_mjr_cities.shp "); ((SharpMap.Rendering.SimpleFeatureRenderer) laycity.renderer).
Symbol=new SharpMap.Symbols.MarkerSymbol (sharpmap.symbols.symboltype.circle,color.blue,10f);
Create a vector layer and set the default renderer.
SharpMap.Layers.VectorLayer layroad = new SharpMap.Layers.VectorLayer ("Road"); Layroad.datasource = new SharpMap.Data.Providers.ShapeFileProvider (@ "D:" ArcGIS "Developerkit" samplesnet "Data"
Gulfofstlawrence "Data" mjrroads.shp "); ((Sharpmap.renderiNg. Simplefeaturerenderer) layroad.renderer).
Symbol = new SharpMap.Symbols.LineSymbol (color.green, 2f);
Create a vector layer and set the default renderer.
SharpMap.Layers.VectorLayer laycoasts = new SharpMap.Layers.VectorLayer ("coasts"); Laycoasts.datasource = new SharpMap.Data.Providers.ShapeFileProvider (@ "D:" ArcGIS "Developerkit" samplesnet "Data"
Gulfofstlawrence "Data" coasts.shp "); ((SharpMap.Rendering.SimpleFeatureRenderer) laycoasts.renderer).
Symbol = new SharpMap.Symbols.FillSymbol (Color.lightcyan);
Add the layer to the map this.mapControl1.Map.Layers.Add (laycoasts);
THIS.MAPCONTROL1.MAP.LAYERS.ADD (Layroad);
THIS.MAPCONTROL1.MAP.LAYERS.ADD (laycity);
Zoom the "map to" full extent this.mapControl1.ZoomToFullExtent (); }