Quantcast
Channel: DotSpatial
Viewing all articles
Browse latest Browse all 3973

Created Unassigned: AddLabels throws error [25759]

$
0
0
Sometimes when we are trying to add labels to a layer so do we get an error, "Index was outside the bounds of the array.", and we have no clue why.

We guess it's because we are loading a shape file with only text. I have attached one of our shape files that cause this error.

This is the stack trace:
```
at DotSpatial.Symbology.LabelLayer.CreateIndexedLabels()
at DotSpatial.Symbology.LabelLayer.CreateLabels()
at DotSpatial.Controls.IFeatureLayerExtensions.AddLabels(IFeatureLayer featureLayer, String expression, String filterExpression, ILabelSymbolizer symbolizer, String name)
```

This is an example how our code could look like (the values are actually read from a XML file, but in this example so have I just put in some hardcoded values).
```
Dim ls As New LabelSymbolizer()
ls.FontFamily = "Verdana"
ls.FontSize = 10
ls.LabelAngleField = "0"
ls.UseLabelAngleField = True

layer.AddLabels("[TEXT]", "", ls, 500) ' NOTE: Throws error here!
```

We are using DotSpatial 1.7.

Viewing all articles
Browse latest Browse all 3973

Trending Articles



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