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;


polyLayer is a Vector layer.

Adding point features to another vector layer works perfect.

Is there something that I'm doing wrong?

  • Are you creating new features with editing controls or requesting new features from somewhere? – neogeomat Aug 12 '13 at 16:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.