【发布时间】:2015-04-10 17:22:03
【问题描述】:
我正在测试使用 Geotools API 将点集合添加到地图中。我一直在尽我所能 Problem creating a point and adding it to FeatureCollection 关注这个例子,因为示例代码很旧,并且不推荐使用 FeatureCollections 之类的东西。我尝试使用 DefaultFeatureCollection 实例,但我不确定我是否正确使用它,这就是为什么这些点不会出现在地图上。我究竟做错了什么?这是我的一些代码:
private void plotMarkers() {
final SimpleFeatureType TYPE = this.createFeatureType();
final SimpleFeatureBuilder BLDR = new SimpleFeatureBuilder(TYPE);
DefaultFeatureCollection features = new DefaultFeatureCollection();
// arbitrary start position
Coordinate pos = new Coordinate(0, 0);
final double pointSpacing = 1.0;
String title = "Test";
features.add(creatureFeature(BLDR, pos, title));
// display points on screen
Style style = SLD.createPointStyle("circle", Color.RED, Color.RED, 1.0f, 5.0f);
Layer layer = new FeatureLayer(features, style);
this.getMapContent().addLayer(layer);
}
【问题讨论】:
-
您至少需要向我们展示 createFeatures 方法,我们才能提供帮助
-
你不能访问我提供的链接吗?在那个网站上。 osgeo-org.1560.x6.nabble.com/…
-
我们还需要看看您是如何设置地图的 - o,o 可能不在地图上
-
this.setMapContent(new MapContent());在构造函数中。
标签: gis point coordinate geotools