[OpenLayers-Dev] Features not visible
francescoboccacci at libero.it
francescoboccacci at libero.it
Fri Mar 16 09:33:09 EDT 2012
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/b4f1a753/attachment.html
More information about the Dev
mailing list