[OpenLayers-Users] Vector layer renders features joined together...

Christopher Schmidt crschmidt at metacarta.com
Fri Mar 27 07:30:35 EDT 2009


On Fri, Mar 27, 2009 at 02:35:54PM +1300, Robert Connolly wrote:
> Hi All,
> 
>  
> 
> I'm rendering a group of features in a vector layer, the rendering seems
> to be successful, however all the polygons are joined together by lines
> for some reason, here's the code I used to do the rendering:

This is too much data and code to investigate. Please break it down
further; perhaps by providing a simple two feature GeoJSON File which
does not work. (Your code looks correct.)

-- Chris

>  
> 
> var geojson_format = new OpenLayers.Format.GeoJSON();
> 
> var styleMap = new
> OpenLayers.StyleMap(OpenLayers.Util.applyDefaults({fillColor:
> fill_colour, fillOpacity: 0.8, strokeColor: stroke_colour},
> OpenLayers.Feature.Vector.style["default"]));
> 
> var vector_layer2 = new OpenLayers.Layer.Vector(catname+' (Areas)',
> {styleMap: styleMap}); 
> 
> map.addLayer(vector_layer2);
> 
> features = geojson_format.read(data);
> 
> for(var i in features)
> 
> {
> 
>                var feature = features[i];
> 
>                if(feature != null)
> 
>                {
> 
>                               feature.geometry.transform(new
> OpenLayers.Projection("EPSG:4326"), new
> OpenLayers.Projection("EPSG:900913"));
> 
>                }
> 
> }
> 
> vector_layer2.addFeatures(features);
> 
>  
> 
> You can see the affect at: http://www.chsrp.org.nz/geomap/ (takes a
> while to load, my code isn't particularly optimised yet and there's
> quite a lot of data).
> 
>  
> 
> Hope someone can help,
> 
>  
> 
> Cheers,
> 
>  
> 
> Rob Connolly
> 
>  
> 
>  
> 

> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users


-- 
Christopher Schmidt
MetaCarta



More information about the Users mailing list