Instead of using freemicaps DLL to develop your own software, you can use the development plug-in for extension. But there is really no time to write plug-in development tutorials. Here is a simple example to show you how to use freemicaps's weathermap. DLL to make a weather map, a simple GIS system. This is to increase your interest or guide the development of freemicaps plug-ins.
In weathermap. dll, a map control is built in, and several lines of code can be used to create a map that can be dragged or scaled. However, to support plotting and map data, you need to implement classes in the corresponding data extension plug-in freemicaps.
Reference: weathermap. dll, readermd9.dll, readergeogrid. dll, readercaption. dll
If you don't talk nonsense, you can directly access the code, and there are few codes. It should be easy to understand:
Using system; </P> <p> using system. collections. generic; </P> <p> using system. componentmodel; </P> <p> using system. data; </P> <p> using system. drawing; </P> <p> using system. text; </P> <p> using system. windows. forms; </P> <p> using bexa. guojf. freemicaps. weathermaps; </P> <p> using bexa. guojf. freemicaps. layers; </P> <p> using bexa. guojf. freemicaps. data; </P> <p> namespace map1 </P> <p >{</P> <p> Public partial class form1: form </P> <p >{</P> <p> // <summary> </P> <p> // map object </P> <p> >/// </Summary> </P> <p> private mapview mapview1 = new mapview (); </P> <p> Public form1 () </P> <p >{</P> <p> // map magnification: 10.0 </P> <p> mapview1.map. scale = 10.0f; </P> <p> // map center latitude and longitude (105e, 35n) </P> <p> mapview1.map. center = new pointf (105.0f, 35f); </P> <p> // map full window </P> <p> mapview1.dock = dockstyle. fill; </P> <p> // map addition window </P> <p> controls. add (mapview1); </P> <p> // automatically generated code </P> <p> initializecomponent (); </P> <p> // Add to the latitude and longitude network layer factory </P> <p> layercreator. addfactory (New geogridfactory (); </P> <p> // Add the MICAPS 9th class format layer factory </P> <p> layercreator. addfactory (New md9factory (); </P> <p> // Add layer title layer factory </P> <p> layercreator. addfactory (New layercaptionfactory (); </P> <p >}</P> <p> private void form1_load (Object sender, eventargs E) </P> <p >{</P> <p> // open the latitude and longitude network layer ("geogrid" is the identification of the latitude and longitude network layer) </P> <p> mapview1.map. open ("geogrid"); </P> <p> // open map data in China (Micaps 9th format) </P> <p> mapview1.map. open ("map of China. dat "); </P> <p> // refresh the map to display </P> <p> mapview1.refresh (); </P> <p >}</P> <p>
Simple 10 lines of code, a map that can be dragged or scaled out!
Does the color look bad? You can use the layer returned by mapview1.map. open () to modify the layer style, such as color and font:
For example:
Private void form1_load (Object sender, eventargs E) </P> <p >{</P> <p> // open the latitude and longitude network layer ("geogrid" is the identification of the latitude and longitude network layer) </P> <p> mapview1.map. open ("geogrid"); </P> <p> // open map data in China (Micaps 9th format) </P> <p> customlayer [] layers = mapview1.map. open ("map of China. dat "); </P> <p> // modify the map color </P> <p> If (layers! = NULL & layers. length> 0) </P> <p >{</P> <p> layers [0]. layerstyle. brushcolor = color. lightgreen; </P> <p >}</P> <p> // refresh the map for display </P> <p> mapview1.refresh (); </P> <p >}</P> <p>
Using code to implement Layer Styles is not flexible enough. mapview also provides parameter files to set the basemap. There are two map parameter files and one map setting file, it is used to configure the coordinates and scaling multiples of the map center, and to save the parameters of the base map layer.
The parameter file is in XML format and is error-prone to manual writing. Copy it directly:
Map. xml
<? XML version = "1.0" encoding = "UTF-8"?> </P> <p> <map> </P> <p> <backcolor> lightblue </backcolor> </P> <p> <centerx> 102.982 </centerx> </P> <p> <centery> 36.31673 </centery> </P> <p> <scale> 10.0000 </scale> </P> <p> <projection> bexa. guojf. freemicaps. coordinates. projlbt </projection> </P> <p> </map> </P> <p>
Basemap. xml
<? XML version = "1.0"?> </P> <p> <layerlist> </P> <p> <layer> </P> <p> <layersource> world map. dat </layersource> </P> <p> <layername> World Map </layername> </P> <p> <isbasemap> true </isbasemap> </P> <p> <visible> true </visible> </P> <p> <mapstyle xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance" xmlns: XSD = "http://www.w3.org/2001/XMLSchema"> </P> <p> <font> tahoma, 8pt </font> </P> <p> <pencolor> black </pencolor> </P> <p> <brushcolor> seashell </brushcolor> </P> <p> <penwidth> 1 </penwidth> </P> <p> <pendashstyle> Solid </pendashstyle> </P> <p> <fontrotate> true </fontrotate> </P> <p> <smoothingmode> antialias </smoothingmode> </P> <p> <textrenderinghint> antialias </textrenderinghint> </P> <p> <maxvisible> 9999 </maxvisible> </P> <p> <minvisible> 0 </minvisible> </P> <p> <zorder> 0 </zorder> </P> <p> <ismask> false </ismask> </P> <p> </mapstyle> </P> <p> </layer> </P> <p> <layer> </P> <p> <layersource> map of China. dat </layersource> </P> <p> <layername> map of China </layername> </P> <p> <isbasemap> true </isbasemap> </P> <p> <visible> true </visible> </P> <p> <mapstyle xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance" xmlns: XSD = "http://www.w3.org/2001/XMLSchema"> </P> <p> <font> tahoma, 8pt </font> </P> <p> <pencolor> gray </pencolor> </P> <p> <brushcolor> lightcyan </brushcolor> </P> <p> <penwidth> 1 </penwidth> </P> <p> <pendashstyle> Solid </pendashstyle> </P> <p> <fontrotate> true </fontrotate> </P> <p> <smoothingmode> none </smoothingmode> </P> <p> <textrenderinghint> antialias </textrenderinghint> </P> <p> <maxvisible> 9999 </maxvisible> </P> <p> <minvisible> 0 </minvisible> </P> <p> <zorder> 0 </zorder> </P> <p> <ismask> false </ismask> </P> <p> </mapstyle> </P> <p> </layer> </P> <p> <layer> </P> <p> <layersource> chinamask. dat </layersource> </P> <p> <layername> chinamask </layername> </P> <p> <isbasemap> true </isbasemap> </P> <p> <visible> false </visible> </P> <p> <mapstyle xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance" xmlns: XSD = "http://www.w3.org/2001/XMLSchema"> </P> <p> <font> tahoma, 8pt </font> </P> <p> <pencolor> black </pencolor> </P> <p> <brushcolor> blue </brushcolor> </P> <p> <penwidth> 1 </penwidth> </P> <p> <pendashstyle> Solid </pendashstyle> </P> <p> <fontrotate> true </fontrotate> </P> <p> <smoothingmode> antialias </smoothingmode> </P> <p> <textrenderinghint> antialias </textrenderinghint> </P> <p> <maxvisible> 9999 </maxvisible> </P> <p> <minvisible> 0 </minvisible> </P> <p> <zorder> 0 </zorder> </P> <p> <ismask> true </ismask> </P> <p> </mapstyle> </P> <p> </layer> </P> <p> <layer> </P> <p> <layersource> longitude and latitude grid. dat </layersource> </P> <p> <layername> latitude and longitude grid </layername> </P> <p> <isbasemap> true </isbasemap> </P> <p> <visible> true </visible> </P> <p> <mapstyle xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance" xmlns: XSD = "http://www.w3.org/2001/XMLSchema"> </P> <p> <font> tahoma, 8pt </font> </P> <p> <pencolor> gray </pencolor> </P> <p> <brushcolor> gray </brushcolor> </P> <p> <penwidth> 1 </penwidth> </P> <p> <pendashstyle> dot </pendashstyle> </P> <p> <fontrotate> true </fontrotate> </P> <p> <smoothingmode> antialias </smoothingmode> </P> <p> <textrenderinghint> antialias </textrenderinghint> </P> <p> <maxvisible> 50 </maxvisible> </P> <p> <minvisible> 0 </minvisible> </P> <p> <zorder> 50 </zorder> </P> <p> <ismask> false </ismask> </P> <p> </mapstyle> </P> <p> </layer> </P> <p> <layer> </P> <p> <layersource> layer title. dat </layersource> </P> <p> <layername> layer title </layername> </P> <p> <isbasemap> true </isbasemap> </P> <p> <visible> true </visible> </P> <p> <captionstyle xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance" xmlns: XSD = "http://www.w3.org/2001/XMLSchema"> </P> <p> <font> tahoma, 10pt </font> </P> <p> <pencolor> black </pencolor> </P> <p> <brushcolor> midnightblue </brushcolor> </P> <p> <penwidth> 1 </penwidth> </P> <p> <pendashstyle> Solid </pendashstyle> </P> <p> <fontrotate> true </fontrotate> </P> <p> <smoothingmode> antialias </smoothingmode> </P> <p> <textrenderinghint> systemdefault </textrenderinghint> </P> <p> <maxvisible> 9999 </maxvisible> </P> <p> <minvisible> 0 </minvisible> </P> <p> <zorder> 100 </zorder> </P> <p> <drawposition> leftbottom </drawposition> </P> <p> </captionstyle> </P> <p> </layer> </P> <p> </layerlist> </P> <p>
The code is modified as follows:
Using system; </P> <p> using system. collections. generic; </P> <p> using system. componentmodel; </P> <p> using system. data; </P> <p> using system. drawing; </P> <p> using system. text; </P> <p> using system. windows. forms; </P> <p> using bexa. guojf. freemicaps. weathermaps; </P> <p> using bexa. guojf. freemicaps. layers; </P> <p> using bexa. guojf. freemicaps. data; </P> <p> using bexa. guojf. freemicaps. myplugin; </P> <p> namespace map1 </P> <p >{</P> <p> Public partial class form1: form </P> <p >{</P> <p> // <summary> </P> <p> // map object </P> <p> >/// </Summary> </P> <p> private mapview mapview1 = new mapview (); </P> <p> Public form1 () </P> <p >{</P> <p> // read parameters such as map center coordinates and scaling multiples </P> <p> mapview1.map. readmapsetting ("map. XML "); </P> <p> // map full window </P> <p> mapview1.dock = dockstyle. fill; </P> <p> // map addition window </P> <p> controls. add (mapview1); </P> <p> // automatically generated code </P> <p> initializecomponent (); </P> <p> // Add to the latitude and longitude network layer factory </P> <p> layercreator. addfactory (New geogridfactory (); </P> <p> // Add the MICAPS 9th class format layer factory </P> <p> layercreator. addfactory (New md9factory (); </P> <p> // Add layer title layer factory </P> <p> layercreator. addfactory (New layercaptionfactory (); </P> <p >}</P> <p> private void form1_load (Object sender, eventargs E) </P> <p >{</P> <p> // read the base map list </P> <p> mapview1.map. readlayers ("basemap. XML "); </P> <p> // refresh the map to display </P> <p> mapview1.refresh (); </P> <p >}</P> <p>
With less than 10 lines of code, you can create a map exactly like freemicaps.