当我使用 ShapeFile 作为矢量图层的数据源时,我尝试了矢量图层主题。但是当我试图用自定义多边形数据实现同样的事情时,它不起作用。
下面是我使用的代码:
Dictionary<string, SharpMap.Styles.IStyle> styles = new Dictionary<string, SharpMap.Styles.IStyle>();
styles.Clear();
styles.Add("NONE", m_noneStyleDefault);
foreach (ListViewItem tn in _arlv)
{
DataRow _row = (DataRow)tn.Tag;
r = labelData.NewRow();
var wkbreader = new NetTopologySuite.IO.WKTReader();
var geom = wkbreader.Read(_row["ogr_geometry"].ToString());
r["FID"] = (Int32)_row["ogr_fid"];
r["NAME"] = _row["sovereignt"].ToString();
r["SOV_A3"] = _row["sov_a3"].ToString().Trim().ToUpper();
r["TYPE"] = _row["mytype"].ToString();
r.Geometry = geom;
labelData.Rows.Add(r);
styles.Add(_row["sov_a3"].ToString().Trim().ToUpper(), m_selectStyleDefault);
}
m_vlCountries.DataSource = new SharpMap.Data.Providers.GeometryProvider(labelData);
//m_vlCountries.Style = m_selectStyleDefault;
m_vlCountries.Theme = new SharpMap.Rendering.Thematics.UniqueValuesTheme<string>("SOV_A3", styles, m_noneStyleDefault);