geoJSON Styling

Hey there!

Is is possible to set styling-attributes for an feature in geoJSON?

The following Code is saying yes, but there is no visible effect…

{
    "type": "Feature",
    "geometry": {
        "type": "Polygon",
        "coordinates": [
            [
                [-180, 10],[20, 90],[180, -5],[-30, -90]
            ]
        ]
    },
    "style": {
        "stroke-width": "3",
        "fill-opacity": 0.6
    },
    "className": {
        "baseVal": "highway_primary"
    }
}

Thanks in advance!!

What renderer or display do you use? I think there are many ways to display the content of a geoJSON file.

By now i am using this code to display the featurecollection :

geojson_layer = new OpenLayers.Layer.Vector("GeoJSON", {
		projection : projLonLat,
		strategies : [ new OpenLayers.Strategy.Fixed() ],
		protocol : new OpenLayers.Protocol.HTTP({
			url : "polygons.geojson",
			format : new OpenLayers.Format.GeoJSON()
		}),
		styleMap : stylemap.styles["yellow"]
	});
	
	map.addLayer(geojson_layer);

the Problem is that i can only use the same stylemap for the whole collection :expressionless:

Hi,

Have you asked from the OpenLayers users mailing list? This feels like a general OpenLayers question and the best experts are probably there.

Solution:

	// Style fuer Polygon
	var polygon_style = {
		
			fillColor : '${color}',
			strokeColor : '${color}',
			strokeOpacity : "0.9",
			fillOpacity : "0.2"
	};
	
	geojson_layer = new OpenLayers.Layer.Vector("GeoJSON", {
		projection : projLonLat,
		strategies : [ new OpenLayers.Strategy.Fixed() ],
		protocol : new OpenLayers.Protocol.HTTP({
			url : url_geoJSON_Polygon,
			format : new OpenLayers.Format.GeoJSON()
		}),
		styleMap :new OpenLayers.StyleMap(polygon_style)
	});
	
	map.addLayer(geojson_layer);
{
      "type": "Feature",
      "properties": {"color": "#2EFE2E"},
      "geometry": {
        "type": "Point",
        "coordinates": [
          13.41379165649414,
          52.54431222846979
        ]
      }
    }