[OpenLayers-Users] Changing style of feature parsed by GeoJSON

Christopher Schmidt crschmidt at metacarta.com
Mon May 4 06:46:31 EDT 2009


On Mon, May 04, 2009 at 12:39:59PM +0200, Stefan Lischke wrote:
> > On Wed, Apr 29, 2009 at 05:16:50PM +0200, Stefan Lischke wrote:
> > > Hi,
> > > 
> > > I desperatly try to change the style of a OpenLayers.Feature.Vector 
> > > that i parsed with OpenLayers.Format.GeoJSON. Since i 
> > cannot not give 
> > > the style in the Feature Constructor i'm searching for 
> > another way to do it.
> > > Is it possible to include the style atrributes within the GeoJSON?
> > > 
> > > I tried to use the old style by set the style attribute and 
> > redraw the 
> > > feature [1,2] but it did not work. Any other Ideas?
> > 
> > http://docs.openlayers.org/library/feature_styling.html#stylemap
> 
> Unfortunatly your link did not help me. To create a style-Map and gove it to
> the constructor of the vector is one solution that i cannot use because i do
> not call the constructor, the GeoJSON Parser creates the objects.

The StyleMap is added to the constructor of the *layer*, not the
features. It is specifcally designed to work when formats are being used
to parse the data.

-- Chris

> Please help me, hoc i can set the StyleMap to a Feature created by the
> GeoJSON parser.
> 
> Thanx
> 
> Stefan
> 

-- 
Christopher Schmidt
MetaCarta



More information about the Users mailing list