[OpenLayers-Users] Measure Control interfering with Drawing Control
Franz Buchinger
fbuchinger at gmail.com
Tue Nov 15 05:59:49 EST 2011
My map hosts a measure and a drawing control. The first should obviously
perform client-side measuring, the drawing control should post the drawn
geometry to the server on the featureAdded event.
The problem: after switching from drawing to measuring, the measuring
control mimics the behaviour of the drawing control: the measurement
geometry is also posted to the server after completing the measurement.
To circumvent this, I tried to restrict the controls to different vector
layers, but had no success so far. Here is the relevant code snippet:
var plotLayer = new OpenLayers.Layer.Vector();
var drawControl = new OpenLayers.Control.DrawFeature(
plotLayer, OpenLayers.Handler.Path,{ //plotLayer = vector layer
for drawing control
handlerOptions: {maxVertices: 2, freehandMode: function
(evt){return false;}},
featureAdded: function(feature){
var drawnLine = feature;
var drawnLinePoints = feature.geometry.getVertices();
$.post ('webservice.url', {line: drawnLinePoints},
function(response){
self.displayPlots(response);
})
}
});
var measureControl = new OpenLayers.Control.Measure(
OpenLayers.Handler.Path, {
persist: true,
layer: map.getLayersByName('vector')[0] //vector layer for measure
control
}
);
map.addControls([drawControl,measureControl]);
any ideas?
thanks,
Franz
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20111115/05635734/attachment.html
More information about the Users
mailing list