To create a mark using a FeatureCollection:

       //get the crsA from the schema
       crsA = featureSource.getSchema().getCoordinateReferenceSystem();

//add a 'mark' to the feature collection
        FeatureCollection<SimpleFeatureType, SimpleFeature> fc =
FeatureCollections.newCollection();
        fc.add(createDot(131.0, 30.0,crsA));
//create a new map context
        MapContext map = new MapDefaultMapContext(crsA); 
//add a layer containing your collection of 'mark's and create a style
        map.addLayer(fc,createPointStyle());

//the createPointStyle method
    private static Style createPointStyle() {
        Style style;
        PointSymbolizer symbolizer = styleFactory.createPointSymbolizer();
        
        symbolizer.getGraphic().setSize(filterFactory.literal(2)); //will
determine how big the 'mark' is
        Rule rule = styleFactory.createRule();
      
        rule.setSymbolizers(new Symbolizer[] { symbolizer });
        FeatureTypeStyle fts = styleFactory.createFeatureTypeStyle();
        
        fts.setRules(new Rule[] { rule });
        style = styleFactory.createStyle();
        style.addFeatureTypeStyle(fts);
        return style;
    }


now add the map to the JMapPane

Hope this helps.



sasi wrote:
> 
> Suppose i have read a shape file(countries.shp) and have showed this map.
> Then how can i place a mark in the map. The location of this mark is
> longitude:131 & latitude:30(Shanghai, China). 
> And how about if I wish the mark being displayed as an icon(*.ico file in
> local disk)? 
> I am appriciated if a demo code will be provided.
> 

-- 
View this message in context: 
http://n2.nabble.com/how-can-i-place-a-mark-in-an-map-tp2428304p2454244.html
Sent from the geotools-devel mailing list archive at Nabble.com.


------------------------------------------------------------------------------
_______________________________________________
Geotools-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-devel

Reply via email to