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.

I am new to GIS technolgies. I'm working on the final project of my career.

I need to have a background map of somewhere on this map I need to create 1 .. N layers in which a particular user can add, modify or delete information. I was able to create layers, and I was able to add or delete information about these. But I can not change information on the layers. By modified I mean move a point or polygon

My code is like this.

var objectListCustomLayer = jQuery.parseJSON(listCustomLayer);
for (var i=0; i < objectListCustomLayer.length; i++){
    var item = objectListCustomLayer[i];
    loadCustomLayers(item.nameLayerkey,item.layerkml,item.layerForm);
}

the objectListCustomLayer take info from server and have information over the layers. and here call the loadCustomLayers...

function loadCustomLayers(name,customKml,customForm){ var renderer = OpenLayers.Util.getParameters(window.location.href).renderer; renderer = (renderer) ? [renderer] : OpenLayers.Layer.Vector.prototype.renderers;

customLayer = new OpenLayers.Layer.Vector(name,renderer);

var info = new infoCustomLayer(customLayer.id,customForm,customLayer);
vectorCustomLayer.push(info);

map.addLayer(customLayer);  

deserialize(customKml,customLayer);

var drag = new OpenLayers.Control.DragFeature(customLayer,{ onStart: startDrag});
var select = new OpenLayers.Control.SelectFeature(customLayer, {box: true, multiple: true,onSelect: addSelected,onUnselect: clearSelected});

var drawOptionsPoint = {
    callbacks : {"done": doneHandlerPoint,
                "point": pointHandlerPoint
                 },
    };

var drawOptionsPath = {
    callbacks : {"done": doneHandlerPath},
    };

var drawOptionsPolygon = {
    callbacks : {"done": doneHandlerPolygon},
    };

controls = {
    point:  new OpenLayers.Control.DrawFeature(customLayer,OpenLayers.Handler.Point,drawOptionsPoint),
    line:   new OpenLayers.Control.DrawFeature(customLayer,OpenLayers.Handler.Path,drawOptionsPath),
    polygon:new OpenLayers.Control.DrawFeature(customLayer,OpenLayers.Handler.Polygon,drawOptionsPolygon),
    drag:   new OpenLayers.Control.DragFeature(customLayer,{ onStart: startDrag}),
    select: select
    };


for(var key in controls) {
            map.addControl(controls[key]);
        }

}

The function loadCustomLayers is call N times. My problem is when I select OpenLayers.Control.DragFeature this works over one layer, but does not work over the layer selected by me.

controls[key] is a vector that stores the name of the controls, is used by a call for a javascript event that allows me to indicate what to do (draw, select or drag) on a given layer.

share|improve this question

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.