先来看下效果
代码如下
File file = JFileDataStoreChooser.showOpenFile("shp", null);
if (file == null) {
return;
}
FileDataStore store = FileDataStoreFinder.getDataStore(file);
//设置编码格式
((ShapefileDataStore) store).setCharset(Charset.forName("GBK"));
SimpleFeatureSource featureSource = store.getFeatureSource();
// Create a map context and add our shapefile to it
MapContext map = new DefaultMapContext();
//获取sld文件
org.geotools.styling.StyleFactory styleFactory = CommonFactoryFinder.getStyleFactory();
File stylefile = new File("sld文件路径xxx.sld");
SLDParser stylereader = new SLDParser(styleFactory, styl