|
From: Boided <ric...@gm...> - 2013-01-15 11:02:07
|
Hi guys,
I tried the above example for adding the polygon on a map.. but
my new layer is not getting displayed on the map.. instead the point is
displayed when i click reset and that too out of the map..
what could be the reason for this? below is the code..
public static Layer getPointLayer(double latitude, double longitude) throws
ParseException, SchemaException {
final SimpleFeatureType TYPE = DataUtilities.createType(
"Location", // <- the name for our feature type
"location:Point:srid=4326," + // <- the geometry attribute:
Point type
"name:String" // <- a String attribute
);
GeometryFactory geometryFactory =
JTSFactoryFinder.getGeometryFactory();
SimpleFeatureCollection features =
FeatureCollections.newCollection();
float lat = (float) latitude;
float lng = (float) longitude;
SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder();
builder.setName("Location");
builder.setCRS(DefaultGeographicCRS.WGS84); // <- Coordinate
reference system
builder.add("Location", Point.class);
builder.length(15).add("Name", String.class); // <- 15 chars width
for name field
SimpleFeatureBuilder featureBuilder = new
SimpleFeatureBuilder(TYPE);
com.vividsolutions.jts.geom.Point point =
geometryFactory.createPoint(new Coordinate(lng, lat));
featureBuilder.add(point);
featureBuilder.add("abc");
SimpleFeature feature = featureBuilder.buildFeature(null);
features.add(feature);
Style style = SLD.createPointStyle("circle", Color.BLUE, Color.BLUE,
0.3f, 30);
Layer pointLayer = new FeatureLayer(features, style);
return pointLayer;
}
--
View this message in context: http://osgeo-org.1560.n6.nabble.com/How-to-add-polygons-on-existing-map-tp5027259p5027538.html
Sent from the geotools-gt2-users mailing list archive at Nabble.com.
|