Quantcast
Viewing all articles
Browse latest Browse all 2341

New Post: Legend

Hello

I am using MapWinGIS.ocx from the MapWinGIS-only-v4.9.3.4-Win32.exe install set.

I am using the Map Control in an MS Access database project. I have successfully been able to import a shape file data layer and represent the data with a legend. What I would like to be able to do is present the user with a legend that relates describes the relationship between the numerical values and colors.

I have read this thread (http://mapwingis.codeplex.com/discussions/576621) many times and tried to use the functionality associated with the MWLite.Symbology.dll but Win7/VBA will not register/link this dll.

Because of the limited capability of VBA I may not be able to do what I am trying to do but I want to make sure I have exhausted all options before I give up.

Below is my code for loading the shapefile. Forgive its rudimentary structure I am just trying to make it work then I will make it pretty.

Thanks for your help.

Private Sub cmdAddLayer_Click()
 'Add Shapefile to Map
Dim hndl As Integer, SF As New MapWinGIS.Shapefile, test As Boolean
Dim cdl As CommonDlg, fileName As String
Dim catGen As Variant, scheme As ColorScheme, fieldIndex As Long

Set cdl = New CommonDlg
cdl.InitDir = "C:\"
cdl.Filter = "Shape File (*.shp)|*.shp| All Files (*.*)| *.*"
cdl.DialogTitle = "Choose the shape file?"
cdl.ShowOpen
fileName = cdl.fileName

'Open a shapefile
test = SF.Open(fileName)

'Add shapefile to map, saving layer handle
mwMapCtrl.TileProvider = tkTileProvider.GoogleTerrain
hnd = mwMapCtrl.AddLayer(SF, True)
mwMapCtrl.ScalebarVisible = True
mwMapCtrl.ShowCoordinates = True

SF.DefaultDrawingOptions.PointType = tkPointSymbolType.ptSymbolStandard
SF.DefaultDrawingOptions.PointShape = tkPointShapeType.ptShapeRegular
SF.DefaultDrawingOptions.PointRotation = 45
SF.DefaultDrawingOptions.PointSize = 15
SF.DefaultDrawingOptions.LineVisible = False

fieldIndex = SF.Table.FieldIndexByName("Norm")
'SF.Table.FieldIndexByName

SF.Categories.Generate fieldIndex, ctEqualCount, 9 'creates a new category legend (this is the number and breaking of the legend)

Set scheme = New ColorScheme 'creates a new color scheme

With scheme
    .SetColors2 tkMapColor.Yellow, tkMapColor.Green '4 Desert 'setting the color scheme to a predefined set of colors called Desert
End With

SF.Categories.ApplyColorScheme ctSchemeGraduated, scheme 'assigns the color scheme to each of the categories

Me.mwMapCtrl.CursorMode = 2


End Sub

Viewing all articles
Browse latest Browse all 2341

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>