R: [OpenLayers-Dev] Features not visible

francescoboccacci at libero.it francescoboccacci at libero.it
Fri Mar 16 12:00:20 EDT 2012


Add another behavior..If add a new line with :
control = new OpenLayers.Control.DrawFeature(layer_line,
                            OpenLayers.Handler.Path);
i can see it with the as described in style_line.Any suggestion?
Thanks
Francesco




----Messaggio originale----

Da: francescoboccacci at libero.it

Data: 16/03/2012 14.33

A: <openlayers-dev at lists.osgeo.org>

Ogg: [OpenLayers-Dev] Features not visible



Hi all,  

I wrote this code to get data from a Geojson :

 var saveStrategy = new OpenLayers.Strategy.Save();
                saveStrategy.events.register('success', null, saveSuccess);
                saveStrategy.events.register('fail', null, saveFail);

var style_line =  new OpenLayers.StyleMap({
                        "default": new OpenLayers.Style(OpenLayers.Util.applyDefaults({
                        
                        strokeWidth: 3,
                        strokeColor: "green",
                        pointRadius: 3
                        }, OpenLayers.Feature.Vector.style["default"])),
                        "select": new OpenLayers.Style(OpenLayers.Util.applyDefaults({
                        
                        strokeWidth: 3,
                        strokeColor: "red",
                        pointRadius: 2
                        }, OpenLayers.Feature.Vector.style["select"]))
                        });

var myprotocol = new OpenLayers.Protocol.HTTP({
                    format: new OpenLayers.Format.GeoJSON(),
                    url: "/edit/data/Line",
                    params: {bbox: bb[0]+","+ bb[1]+"," + bb[2]+","+bb[3]}
                    
                });
                
               

                layer_line = new OpenLayers.Layer.Vector("Line", {
                projection: "EPSG:4326",
                strategies: [saveStrategy],
                protocol:myprotocol,
                styleMap: style_line

             
                });


                layer_line.protocol.read({
                                
                                    callback: function(resp) {
                                
                                
                                layer_line.addFeatures(resp.features);

                                }
                            });

                map.addLayer(layer_line);
In firebug i write command : layer_line.features.length and it show me a number. I think that it means that layer has feature but on map i can see the features. Where am i wrong?


Thanks
Francesco
 



-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-dev/attachments/20120316/2fab112d/attachment.html


More information about the Dev mailing list