SharpMap中文乱码是因为编码问题
ShapeFile 的默认的Encoding为UTF7,而我们的中文一般为GB2312,用下面的代码就可以显示中文了。
//Set up the countries layer
SharpMap.Layers.VectorLayer layCH_Other = new SharpMap.Layers.VectorLayer("CH_Other");
//Set the datasource to a shapefile in the App_data folder
SharpMap.Data.Providers.ShapeFile shp = new SharpMap.Data.Providers.ShapeFile
(HttpContext.Current.Server.MapPath(@"~/App_data/CH/P1.shp"), true);
shp.Encoding = System.Text.Encoding.GetEncoding("gb2312");
layCH_Other.DataSource = shp ;
本文介绍了SharpMap中出现中文乱码的问题及解决方案。通过设置ShapeFile数据源的编码为GB2312,成功实现了地图中文标签的正常显示。
628

被折叠的 条评论
为什么被折叠?



