MapWinGIS ActiveX Sample Code : MapWindow Discussion Forum
Help would be greatly appreciated. I'm developing a MapWindow application using VB 2008 Express to customize map symbology (a HUC12 shape file). Trying to apply differenct color schemes to watersheds based on an attribute of the shape file -- for example, there's a Val
Sample Code for Manipulating Symbolody Doesn't Work
Posted by: jyang03 ()
Date: March 01, 2012 08:05AM

Help would be greatly appreciated.

I'm developing a MapWindow application using VB 2008 Express to customize map symbology (a HUC12 shape file).

Trying to apply differenct color schemes to watersheds based on an attribute of the shape file -- for example, there's a Value field, and if values withing a certain range, fill those watersheds (shapes of the HUC12 shape file) with a certain color.

VB.NET code, exactly same as the code examples given in Documentaion of this site "Introduction to Custom GIS Application Development for Windows", works in applying global color scheme to the layer, but not for individule shapes. Then I test run the example written in the Doc, using shape file provided in the Sample Projects included in MapWinGIS, get same results.

Is this a bug in VB code, or in shape file, or in MapWinGIS (V.4.8.6)? Below is the VB code snippet copied from examples in the MapWin documentation:

Private Sub loadWorldShape()
'
Dim myWorldShape As New MapWinGIS.Shapefile
myWorldShape.Open("C:\Program Files\MapWindow\Sample \world\Shapefiles\world_adm0.shp")
Dim hndWorldShape As Integer
hndWorldShape = AxMap1.AddLayer(myWorldShape, True)
'
Dim FillColor As UInt32
Dim LineColor As UInt32
Dim LineWidth As Single
FillColor = Convert.ToUInt32(RGB(100, 255, 0))
LineColor = Convert.ToUInt32(RGB(125, 125, 125))
LineWidth = 2.0
'
With AxMap1
.set_ShapeLayerFillColor(hndWorldShape, FillColor)
.set_ShapeLayerLineColor(hndWorldShape, LineColor)
.set_ShapeLayerLineWidth(hndWorldShape, LineWidth)
End With
'
Dim ShapeNum As Integer
Dim Region As String
Dim FieldNum As Integer
FieldNum = 2
For ShapeNum = 0 To myWorldShape.NumShapes - 1
Region = myWorldShape.CellValue(FieldNum, ShapeNum)
Select Case Region
Case "Antarctica"
AxMap1.set_ShapeFillColor(hndWorldShape, ShapeNum, Convert.ToUInt32(RGB(100, 50, 0)))
Case "Asia"
AxMap1.set_ShapeFillColor(hndWorldShape, ShapeNum, Convert.ToUInt32(RGB(120, 70, 20)))
Case "Australia"
AxMap1.set_ShapeFillColor(hndWorldShape, ShapeNum, Convert.ToUInt32(RGB(140, 90, 40)))
Case "Caribbean"
AxMap1.set_ShapeFillColor(hndWorldShape, ShapeNum, Convert.ToUInt32(RGB(160, 110, 60)))
Case "Europe"
AxMap1.set_ShapeFillColor(hndWorldShape, ShapeNum, Convert.ToUInt32(RGB(180, 130, 80)))
Case "Latin America"
AxMap1.set_ShapeFillColor(hndWorldShape, ShapeNum, Convert.ToUInt32(RGB(200, 150, 100)))
Case "North America"
AxMap1.set_ShapeFillColor(hndWorldShape, ShapeNum, Convert.ToUInt32(RGB(220, 170, 120)))
Case "NorthAfrica"
AxMap1.set_ShapeFillColor(hndWorldShape, ShapeNum, Convert.ToUInt32(RGB(240, 190, 140)))
Case "Pacific"
AxMap1.set_ShapeFillColor(hndWorldShape, ShapeNum, Convert.ToUInt32(RGB(250, 210, 160)))
Case "Sub Ssharan Africa"
AxMap1.set_ShapeFillColor(hndWorldShape, ShapeNum, Convert.ToUInt32(RGB(255, 230, 180)))
End Select
Next
'
End Sub

Options: ReplyQuote
Re: Sample Code for Manipulating Symbolody Doesn't Work
Posted by: jyang03 ()
Date: March 01, 2012 11:50AM

Reply to myself -- Issue Solved!

We have find out the problem: The version I used is 4.8.6. The color sheme works with an older version, v4.7.5.

This is strange, but at least I am able to continue with my application development on the older version, and hope this won't happen with version 6, dotSpatial.

Options: ReplyQuote
Re: Sample Code for Manipulating Symbolody Doesn't Work
Posted by: pmeems ()
Date: March 01, 2012 02:41PM

The symbology has been drastically improved in v4.8.6
You need to work with categories now to assign colors to your shapes.
Use the new documentation for more info:
[www.mapwindow.org]

--
Don't forget to read the new documentation: www.mapwindow.org/documentation/mapwingis4.8
Join us Google+: MapWindow GIS Google+ Community
Join the MapWindow Group on LinkedIn! LinkedIn - MapWindow Group

Download the latest beta installer at:
tinyurl.com/mwMonthly 32-Bit
tinyurl.com/mwMonthlyx64 64-Bit
Follow me on Twitter MapWindow_nl to read when a new installer is published.

---
Paul Meems
The Netherlands
[www.bontepaarden.nl]
Release manager, configuration manager and
forum moderator of MapWindow GIS

Owner of MapWindow.nl - Support for
Dutch speaking users: www.mapwindow.nl

*******
Everything I say or write is my personal opinion and
not the opinion of the company I work for.
*******
View my profile on LinkedIn

Options: ReplyQuote
Re: Sample Code for Manipulating Symbolody Doesn't Work
Posted by: jyang03 ()
Date: March 20, 2012 07:57AM

Thank you Paul. The links about samples, updates, etc, are very helpful.
Sincerely,

Jim Yang

Options: ReplyQuote


Sorry, only registered users may post in this forum.





Banner Exchange




GISCP.com




Send us your banner logo (160x120) for the space above, and add this MapWindow banner ad to your site:

Just paste this text in your page: