MapObjects inVBNET PDF
MapObjects inVBNET PDF
Add vector and raster data to a map, and perform queries on the map data
you added.
Control panning and zooming, display map layers based on scale, and
render use thematic renderers to draw data based on attribute values.
GETTING STARTED
4
5. Click OK to create the new project.
GETTING STARTED
GETTING STARTED
BASIC .NET
GETTING STARTED
3
2
Note: Choosing the ActiveX Properties option will
display the property sheet belonging to an ActiveX
control, if it has one.
Alternatively, you can click the Property Sheet button in
the Properties window.
3. In the Properties dialog box, click the Add button and
locate the folder containing the States sample data.
If you selected the defaults when you installed
MapObjects, the sample data will be located in
C:\Program Files\ESRI\MapObjects2\Samples\Data.
6
GETTING STARTED
BASIC .NET
Correct the listed errors as described. If you doubleclick the task, the line of code causing the error will
automatically be selected for you.
2. Click the Stop Debugging button on the Visual Studio
toolbar to stop running your application and return to
design mode.
3. You can check the results of the Build operation by
looking in the sub-directories of your project.
GETTING STARTED
You will write some code that the application will execute in
response to the MouseDownEvent event on the map.
If you wish to find out more about how events are raised
and handled in .NET, please read the MSDN
documentation included with Visual Studio .NET.
3. In the Method Name drop-down list, select
MouseDownEvent.
Tip: If you start by typing "AxMap1", the autocompletion feature of IntelliSense will allow you to
complete the item of code by pressing Tab.
GETTING STARTED
BASIC .NET
1
5
7
2
3
4
1. Classes are declared using the class keywordall code
between the curly braces belongs to a class.
8. Class and Method name drop-down lists are found at the top
of the code window, and are often used in VB .NET to construct
function stubs, particularly for event handlers. The Class Name
drop-down lists all the public classes declared in the module. The
Method Name drop-down lists all the members of the selected
class.
9. Namespaces are used to uniquely identify objects, and can be
used to organize objects hierarchically, regardless of where they
are defined. Objects in the ESRI.MapObjects2.Core and
ESRI.MapObjects2.Control assemblies all belong to the
ESRI.MapObjects2.Core namespace.
GETTING STARTED
10
GETTING STARTED
BASIC .NET
GETTING STARTED
11
12
GETTING STARTED
BASIC .NET
2
5
4
3
5. Set the buttons Style property to ToggleButton, its
ImageIndex property to 0, and its Pushed property to
True.
6. Add a second button, and set its Style to ToggleButton
and it's ImageIndex to 1.
GETTING STARTED
13
14
GETTING STARTED
BASIC .NET
This code specifies that for any button other than the
FullExtent button, the SetSelected procedure is called.
The FullExtent button is not a toggle button, so should
not change the state of any other button.
5. Below the ButtonClick procedure, add the following
function procedure.
GETTING STARTED
15
2. Click the map with the left mouse button and drag out a
rectangle.
6. Click the Full Extent button to redraw the map at the full
extent.
Save the project
1. Click the Stop Debugging button in Visual Studio to
return to design mode.
2. Click the File menu, then click Save All to save your
project.
4. Click the map with the right mouse button and drag to
pan the map.
16
GETTING STARTED
BASIC .NET
GETTING STARTED
17
18
BASIC .NET
The code then gets the value of the Shape field for the
first record. The code scales the Extent of the shape
and then sets it to be the extent of the map.
Finally, the map is redrawn using the CtlRefresh method,
and the shape is flashed three times. Note that the
CtrlRefresh method is used to redraw the map. This is
because the .NET host class, AxHost, has a method
called Refresh toothe Ctrl prefix is added to
differentiate the method of the host class from the
method of the underlying MapObjects Map class.
GETTING STARTED
19
20
GETTING STARTED
BASIC .NET
GETTING STARTED
21
You will add code to your application that will draw the
results of the spatial query on the map.
6
5
22
GETTING STARTED
BASIC .NET
23
24
GETTING STARTED
BASIC .NET
Statistical mapping
Currently the map displays no information about the layers
it contains.
GETTING STARTED
25
Dim i As Integer
For i = 0 To 6
If (breakVal >= stats.Min And _
breakVal <= stats.Max) Then
Dim breakCount As Integer = _
ctRnd.BreakCount
ctRnd.BreakCount = breakCount + 1
ctRnd.Break(breakCount) = breakVal
End If
breakVal = breakVal + stats.StdDev
Next
cntyRnd.RampColors(Convert.ToUInt32 _
(ColorConstants.moLimeGreen), Convert. _
ToUInt32(ColorConstants.moRed))
End Sub
Dim i As Integer
For i = 0 To regions.Count - 1
stRnd.Value(i) = regions.Item(i)
Next
End Sub
26
GETTING STARTED
BASIC .NET
GETTING STARTED
27
Event tracking
Some applications must display geographic entities on top of
the map, especially if those entities have a tendency to
move. For example, a vehicle tracking system would want
to update vehicle locations frequently over time, without
redrawing all the layers of the map each time a vehicle
changes location.
In this section, you will add an event tracking layer to your
application to simulate this requirement.
Add an event tool to your application's toolbar
1. Return to the Form Designer view, and click the ToolBar
to select it.
2. In the Properties window, select the Properties button,
then click the button next to the Buttons property.
6
3
28
GETTING STARTED
BASIC .NET
9
29
GETTING STARTED
BASIC .NET
GETTING STARTED
31
32
GETTING STARTED
BASIC .NET
GETTING STARTED
33
3. Click the File menu, then click Save All to save your
project.
You might like to add your own tool to locate the correct
extent (try using the Extent property of the
ImageLayer).
You could also rearrange the order of the MapLayers to
display the US Highways over the top of the
ImageLayer.
34
GETTING STARTED
BASIC .NET