Register  |  Login   Search
ThinkGeo - GPS Tracking and Mapping Solutions  |  Home  |  Cygnus Track  |  Blog
 
LivePerson Chat

Discussion Forums

The online community for users of Map Suite GIS components

Subject: IconValueRenderer woes
Prev Next
You are not authorized to post a reply.
Author Messages
6/12/2008 7:52 AM  

I've been trying for some time to get an IconValueRenderer working, without success. I can see no obvious mistakes in my code, and yet nothing gets displayed on the map.

My code is as follows:

 

        Layer layer2 = new Layer("c:/path/to/shape/file", true);

        layer2.ThresholdUnit = ThresholdUnits.kilometres;

        Threshold threshold = new Threshold();
        threshold.UpperExtent = 50000;
        threshold.LowerExtent = 0;

        IconValueCollection IconValueCollection = new IconValueCollection();

        TextSymbolCollection TextSymbols = new TextSymbolCollection();
        TextSymbols.Add(new TextSymbol(new Font("Arial", 8, FontStyle.Bold), new SolidBrush(Color.Black), 1, -5));

       // "POLICE" is the value I want to match this icon to
        IconValueRenderer.IconValue IconValue1 = new IconValueRenderer.IconValue("POLICE", new Bitmap(this.Server.MapPath("") + @"\images\police.png"), TextSymbols);

        IconValueCollection.Add(IconValue1);

       // "TYPE" is the column that I want to match the value to, and "CITYNAME" is the column with the text to show as a label
        IconValueRenderer IconValueRenderer = new IconValueRenderer("TYPE", "CITYNAME", IconValueCollection);

        threshold.LabelRenderers.Add(IconValueRenderer);

        if (!layer2.HasIndex)
            layer2.BuildIndex();

        Map1.Layers.Add(layer2);

6/18/2008 2:26 AM  
Sorry, I see that the code ended up with a weird background colour. I duplicate below:

Layer layer2 = new Layer("c:/path/to/shape/file", true);

layer2.ThresholdUnit = ThresholdUnits.kilometres;

Threshold threshold = new Threshold();
threshold.UpperExtent = 50000;
threshold.LowerExtent = 0;

IconValueCollection IconValueCollection = new IconValueCollection();

TextSymbolCollection TextSymbols = new TextSymbolCollection();
TextSymbols.Add(new TextSymbol(new Font("Arial", 8, FontStyle.Bold), new SolidBrush(Color.Black), 1, -5));

// "POLICE" is the value I want to match this icon to
IconValueRenderer.IconValue IconValue1 = new IconValueRenderer.IconValue("POLICE", new Bitmap(this.Server.MapPath("") + @"\images\police.png"), TextSymbols);

IconValueCollection.Add(IconValue1);

// "TYPE" is the column that I want to match the value to, and "CITYNAME" is the column with the text to show as a label
IconValueRenderer IconValueRenderer = new IconValueRenderer("TYPE", "CITYNAME", IconValueCollection);

threshold.LabelRenderers.Add(IconValueRenderer);

if (!layer2.HasIndex)
layer2.BuildIndex();

Map1.Layers.Add(layer2);
7/04/2008 3:21 AM  

Hi,

I think you need more setting to the IconValue1's two other properties:

TextFieldValueStringLengthMin
TextFieldValueStringLengthMax

In your case, if the value of text field "CITYNAME" has a length between TextFieldValueStringLengthMin and TextFieldValueStringLengthMax, the icon displays on the Map control.

For example, if you set the two properties like this:

IconValue1.TextFieldValueStringLengthMin = 6;
IconValue1.TextFieldValueStringLengthMax = 7;

Then a record's text field "CITYNAME" has a value "Chicago", the icon will display.

Hope this can help you.

Sun

 

You are not authorized to post a reply.



ActiveForums 3.7