Mapwindow Gis Activex Control: Sample Project: Data Visualization Tool
Mapwindow Gis Activex Control: Sample Project: Data Visualization Tool
Introduction
Often, a full geographic information system is not needed for a given application
or task. In these cases, it is immensely useful to build a custom application from the
ground up. Adding GIS capabilities to a custom application is typically slow and difficult;
in this guide you will use the MapWinGIS ActiveX Control to vastly simplify this goal,
easily and quickly adding GIS functionality to a custom program.
The tool developed here is a simple data visualization tool, allowing the user to
view ESRI Shapefiles and most raster data formats including ECW, Mr. SID, GeoTIFF,
ASCII, ArcGrid and many other raster files.
A more advanced demonstration application, the Hike Difficulty Analysis Tool,
continues the concepts demonstrated here. This project is written using Microsoft Visual
Basic 2005 Express edition, and may be downloaded here:
http://www.mapwindow.org/download.php?show_details=24
Please follow the steps below to create the basic data viewer application.
Step 1:
Create a new VB.Net project using Microsoft Visual Studio.
Step 2:
Right-click in the Toolbox window and select Choose Items (Visual Studio 2005) or
Add Control (Visual Studio 2002-2003). Select the COM Components tab. Browse to
the location of the MapWindow GIS ActiveX control, typically:
C:\Program Files\MapWindow\MapWinGIS.ocx
This window is shown in figure 1:
Step 3:
Notice that Map Control has now been added to the list of tools that you may use. Select
this tool, and click in the default form that was created when your project was created.
Use the mouse to drag the corner, resizing it as desired.
Also add a button and a groupbox, and three radio buttons inside of the groupbox, as
shown in figure 2:
Step 4:
Change the names of the map, buttons and radio button. Change the text of the button and
radio buttons.
Map (Defaults to AxMap1):
Change name to Map or any name you prefer.
Button1:
Change text to Add Data.
Change name to btnAddData or any name you prefer.
RadioButton1:
Change text to Zoom In.
Change name to rdZoomIn or any name you prefer.
RadioButton2:
Change text to Zoom Out.
Change name to rdZoomOut or any name you prefer.
RadioButton3:
Change text to Pan.
Step 6:
Set the Checked property of the Zoom In radio button to true. This is because the default
cursor mode for the map is to zoom in.
Double-click the Add Data button. This will take you into the source code view. Add the
code beginning on the next page to the btnAddData_Click subroutine.
The code listing looks daunting at first; however, this code provides access to every file
format that the MapWinGIS ActiveX control supports. Supporting only a shapefile or
only a grid would be a substantially shorter code listing.
Step 7:
Press the Play button on the toolbar (figure 4) to start the program.
Click on your Add Data button, and select any common GIS data format file. You may
also click the Files of Type drop down to see what formats are supported (figure 5):
You will now see your data in the map (figure 6):
Step 8:
Double-click on the Zoom In radio button. Add the following code:
Map.CursorMode = MapWinGIS.tkCursorMode.cmZoomIn
Double-click on the Zoom Out radio button. Add the following code:
Map.CursorMode = MapWinGIS.tkCursorMode.cmZoomOut
Step 9:
Click the Play button once again to run the program. Your viewer can now zoom in,
zoom out, and pan as well as support a large number of data formats.
Additional Information:
For a much more detailed demonstration, please visit:
http://www.mapwindow.org/download.php?show_details=24