[OpenLayers-Users] Changing style of feature parsed by GeoJSON
Stefan Lischke
lischke at novacom.net
Mon May 4 07:00:59 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.
OK, so did i understand you right, i'm not able to display multiple features
(polygons) parsed by GeoJSON on one Layer? So i have to create one layer per
style/color of a polygon?
But when creating the feature by hand (calling the constructor) i can set
the style with the constructor and can create multiple polygons with
different colors on one layer.
Stefan
More information about the Users
mailing list