MapWindow 4 - ActiveX Control Programming : MapWindow Discussion Forum
I've tried the following, from examples on the site, but the legend does not display. Dim indx As Long Dim cs As ColorScheme Dim lg As ShapefileColorScheme Dim lgcb As ShapefileColorBreak Dim lgHandle As Long sfWorld.Open App.Path
How do I display a legend?
Posted by: bendel_boy ()
Date: March 11, 2012 05:44AM

I've tried the following, from examples on the site, but the legend does not display.

Dim indx As Long
Dim cs As ColorScheme
Dim lg As ShapefileColorScheme
Dim lgcb As ShapefileColorBreak
Dim lgHandle As Long

sfWorld.Open App.Path & "\500polygon.shp"
hwnLayer = mapGIS.AddLayer(sfWorld, False)
indx = 12 ' Field that holds data to be plotted
Set cs = New ColorScheme
cs.AddBreak 0, Blue
cs.AddBreak 0.33, Yellow
cs.AddBreak 0.67, Green
cs.AddBreak 1, Red
sfWorld.Categories.Generate 12, ctStandardDeviation, 60
sfWorld.Categories.ApplyColorScheme3 ctSchemeGraduated, cs, shElementFill, 0, 60
sfWorld.Categories.ApplyExpressions
Set lg = New ShapefileColorScheme
lg.LayerHandle = hwnLayer
lg.FieldIndex = 11
Set lgcb = New ShapefileColorBreak
lgcb.Caption = "0 - 0.33"
lgcb.StartColor = Blue
lgcb.EndColor = Yellow
lgcb.StartValue = 0
lgcb.EndValue = 0.33
lg.Add lgcb
Set lgcb = New ShapefileColorBreak
lgcb.Caption = "0.33 - 0.67"
lgcb.StartColor = Yellow
lgcb.EndColor = Green
lgcb.StartValue = 0.33
lgcb.EndValue = 0.67
lg.Add lgcb
Set lgcb = New ShapefileColorBreak
lgcb.Caption = "0.67 - 1"
lgcb.StartColor = Yellow
lgcb.EndColor = Red
lgcb.StartValue = 0.67
lgcb.EndValue = 1
lg.Add lgcb
mapGIS.ApplyLegendColors lg
mapGIS.LayerVisible(hwnLayer) = True
mapGIS.ReDraw

Options: ReplyQuote
Re: How do I display a legend?
Posted by: sindizzy ()
Date: March 14, 2012 05:28PM

Try this. It took me a year to realize this was avaialable:
myLeg.Layers.ItemByHandle(hndMyLayer).Expanded = True

AGP

Options: ReplyQuote
Re: How do I display a legend?
Posted by: sindizzy ()
Date: March 14, 2012 05:33PM

Unless you dont have a legend object. Some sample projects here:

[www.mapwindow.org]

AGP

Options: ReplyQuote
Re: How do I display a legend?
Posted by: bendel_boy ()
Date: March 15, 2012 03:47AM

The legend PCX depends upon a resizer OCX which is not part of the project, and which I do not have. I do have a resizer OCX control, but clearly not the one that was expected with the mapLegend control.

The legend control was developed in an earlier version of MapWindows. Would it work with Version 4.8, or have there been changes that would break any expected compatability? (I cannot test, as the legend OCX cannot run on my machine as it is missing the binary dependency on the resizer OCX.)

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: