Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

When I add a polygon feature it shows on the map. When I add another one the first one disappears. The code for adding is below:

$.postJSON('@Url.Action("GetLayers")', { "planId": planId },
            function(data) {
                var features = [];
                $.each(data, function(i, item) {
                    var pointList = [];
                    $.each(item.Points, function(y, p) {
                        pointList.push(new OpenLayers.Geometry.Point(p.X, p.Y));
                    });
                    var ring = new OpenLayers.Geometry.LinearRing(pointList);
                    var feature = new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Polygon(ring));
                    feature.url = '@Request.Url.AbsoluteUri';
                    feature.fid = item.Id;
                    feature.geometry.id = "Link_" + item.Link;

                    features.push(feature);
                });
                polyLayer.addFeatures(features);
            }
        );

polyLayer is a Vector layer.

Adding point features to another vector layer works perfect.

Is there something that I'm doing wrong?

share|improve this question
    
Are you creating new features with editing controls or requesting new features from somewhere? –  neogeomat Aug 12 '13 at 16:37

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.