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. ------------------------------------------------------------------------------ Master SQL Server Development, Administration, T-SQL, SSAS, SSIS, SSRS and more. Get SQL Server skills now (including 2012) with LearnDevNow - 200+ hours of step-by-step video tutorials by Microsoft MVPs and experts. SALE $99.99 this month only - learn more at: http://p.sf.net/sfu/learnmore_122512 _______________________________________________ GeoTools-GT2-Users mailing list GeoTools-GT2-Users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users