hi, you can set an external stylemap and then color the polygons individually by attribute.
On Mon, Jun 20, 2011 at 7:35 AM, pday <[email protected]> wrote: > Hello, > > I am trying to pass in GeoJSON to a simple proof of concept mapping > example. > What I am hoping to do is pass a single GeoJSON file (hard-coded below only > for demo's sake, will be read in soon), with multiple polygons of different > colors. > > Can this be done in a single GeoJSON file or am I restricted to coloring > them all the same per file? I tried setting the fillColor property under > each polygon in the featurecollection below but was unsuccessful. > > My init() function is below that sets the map and parses two simple > polygons. Thank you > > -Pat > > function init(){ > map = new OpenLayers.Map( 'map' ); > layer = new OpenLayers.Layer.WMS( "OpenLayers WMS", > "http://vmap0.tiles.osgeo.org/wms/vmap0", > {layers: 'basic'} ); > map.addLayer(layer); > map.setCenter(new OpenLayers.LonLat(lon, lat), zoom); > var featurecollection = { > "type": "FeatureCollection", > "features": [ > {"geometry": { > "type": "GeometryCollection", > "geometries": [ > { > type: "Polygon", > coordinates: > [[ > [-14.7656, > 73.0309], > [-30.2344, > 46.0929], > [-9.8438, > -47.9709], > [-94.9219, > -59.1614], > [-124.4531, > -18.6194], > [-155.3906, > 45.6031], > [-137.1094, > 75.3272] > ]] > }, > { > type: "Polygon", > coordinates: > [[ > [-106.1719, > -28.8968], > [-16.1719, > 41.5298], > [39.3750, > -37.1377] > ]] > } > ], > }, > "type": "Feature", > "properties": {}} > ] > }; > var geojson_format = new OpenLayers.Format.GeoJSON(); > var vector_layer = new OpenLayers.Layer.Vector(); > map.addLayer(vector_layer); > vector_layer.addFeatures(geojson_format.read(featurecollection)); > > } > > -- > View this message in context: > http://osgeo-org.1803224.n2.nabble.com/GeoJSON-Fill-Colors-tp6495593p6495593.html > Sent from the OpenLayers Users mailing list archive at Nabble.com. > _______________________________________________ > Users mailing list > [email protected] > http://lists.osgeo.org/mailman/listinfo/openlayers-users >
_______________________________________________ Users mailing list [email protected] http://lists.osgeo.org/mailman/listinfo/openlayers-users
