[OpenLayers-Users] Measure Control interfering with Drawing
Control
Andreas Hocevar
ahocevar at opengeo.org
Tue Nov 15 08:37:30 EST 2011
Hi,
How do you switch from drawing to measuring? If you deactivate your drawControl when you activate the measureControl and vice verse, you should not run into this issue.
Andreas.
On Nov 15, 2011, at 11:59 , Franz Buchinger wrote:
> 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
> _______________________________________________
> Users mailing list
> Users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/openlayers-users
--
Andreas Hocevar
OpenGeo - http://opengeo.org/
Expert service straight from the developers.
More information about the Users
mailing list