2.11 SketchStarted

classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

2.11 SketchStarted

fell_runner
I have a drawfeature control with a path handler on a vector layer.  In 2.10 the 'sketchstarted' event was triggered when the user clicked on map now it is triggered on 'mousemove' - this seems wrong as I haven't actually started drawing yet [i.e. clicked the mouse first].
Reply | Threaded
Open this post in threaded view
|

Re: 2.11 SketchStarted

erilem
On Tue, Mar 6, 2012 at 11:50 AM, fell_runner <[hidden email]> wrote:
> I have a drawfeature control with a path handler on a vector layer.  In 2.10
> the 'sketchstarted' event was triggered when the user clicked on map now it
> is triggered on 'mousemove' - this seems wrong as I haven't actually started
> drawing yet [i.e. clicked the mouse first].


But the initial point is there already. The snapping control listens
to sketchstarted for activating snapping.



--
Eric Lemoine

Camptocamp France SAS
Savoie Technolac, BP 352
73377 Le Bourget du Lac, Cedex

Tel : 00 33 4 79 44 44 96
Mail : [hidden email]
http://www.camptocamp.com
_______________________________________________
Dev mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/openlayers-dev
Reply | Threaded
Open this post in threaded view
|

Re: 2.11 SketchStarted

fell_runner
Thanks for the reply, but I don't understand your answer.

The vector layer has no features to start with.  The user activates the drawfeature control and I'm using the 'sketchstarted' event to determine the co-ordinates of where the user has started drawing.

So, I'm not sure about your comments regards the initial point already being there and I've never used the snapping control.

Am I using the wrong technique the get the co-ordinates of where the user has started to draw?

Thanks
Reply | Threaded
Open this post in threaded view
|

Re: 2.11 SketchStarted

erilem
On Tue, Mar 6, 2012 at 2:15 PM, fell_runner <[hidden email]> wrote:
> Thanks for the reply, but I don't understand your answer.
>
> The vector layer has no features to start with.

When you move the mouse over the map there should a vector point following.

> The user activates the
> drawfeature control and I'm using the 'sketchstarted' event to determine the
> co-ordinates of where the user has started drawing.

You can try this (untested):

new OpenLayers.Control.Draw(layer, OpenLayers.Handler.Path, {
    callbacks: {
        point: function(point, line) {
            if (line.components.length == 2) {
                // user has actually started to draw,
                // and "point" is the first draw point
            }
        }
    }
});


--
Eric Lemoine

Camptocamp France SAS
Savoie Technolac, BP 352
73377 Le Bourget du Lac, Cedex

Tel : 00 33 4 79 44 44 96
Mail : [hidden email]
http://www.camptocamp.com
_______________________________________________
Dev mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/openlayers-dev
Reply | Threaded
Open this post in threaded view
|

Re: 2.11 SketchStarted

fell_runner
In reply to this post by fell_runner
Ok that does work.

But it still seems [to me] a [very] non-intuitive way of catching the users first drawing point on a line.

Thanks for your help.
Reply | Threaded
Open this post in threaded view
|

Re: 2.11 SketchStarted

Xavier Mamano (jorix)
In reply to this post by erilem
Hi,

For other reasons (http://trac.osgeo.org/openlayers/ticket/3319) I was looking at the third parameter ("drawing") on "modify" callback.

And I thought ... "point" callback ("point" only occurs when drawing) could receive a "drawing" parameter and for the first point would be false. So this would be the first point.

What opinion about it?

Xavier Mamano

erilem wrote
On Tue, Mar 6, 2012 at 2:15 PM, fell_runner <[hidden email]> wrote:
> Thanks for the reply, but I don't understand your answer.
>
> The vector layer has no features to start with.

When you move the mouse over the map there should a vector point following.

> The user activates the
> drawfeature control and I'm using the 'sketchstarted' event to determine the
> co-ordinates of where the user has started drawing.

You can try this (untested):

new OpenLayers.Control.Draw(layer, OpenLayers.Handler.Path, {
    callbacks: {
        point: function(point, line) {
            if (line.components.length == 2) {
                // user has actually started to draw,
                // and "point" is the first draw point
            }
        }
    }
});


--
Eric Lemoine

Camptocamp France SAS
Savoie Technolac, BP 352
73377 Le Bourget du Lac, Cedex

Tel : 00 33 4 79 44 44 96
Mail : [hidden email]
http://www.camptocamp.com
_______________________________________________
Dev mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/openlayers-dev
Reply | Threaded
Open this post in threaded view
|

Re: 2.11 SketchStarted

erilem


On Tuesday, March 6, 2012, Xavier Mamano (jorix) <[hidden email]> wrote:
> Hi,
>
> For other reasons (http://trac.osgeo.org/openlayers/ticket/3319) I was
> looking at the third parameter ("drawing") on "modify" callback.
>
> And I thought ... "point" callback ("point" only occurs when drawing) could
> receive a "drawing" parameter and for the first point would be false. So
> this would be the first point.
>
> What opinion about it?

I think we should add a sketchcreated event to the layer. This event will be triggered by the DrawFeature's create callback. The sketchstarted event would now be triggered by a point callback when this is the point point being added. This would require changing the Snapping control a bit, to make it listen to sketchcreated instead of sketchstarted. How does that sound?

--
Eric Lemoine

Camptocamp France SAS
Savoie Technolac, BP 352
73377 Le Bourget du Lac, Cedex

Tel : 00 33 4 79 44 44 96
Mail : [hidden email]
http://www.camptocamp.com


_______________________________________________
Dev mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/openlayers-dev
Reply | Threaded
Open this post in threaded view
|

Re: 2.11 SketchStarted

Xavier Mamano (jorix)
Hi Eric,

Sounds good, yet I still have not worked with the Snapping code. I understand that would be two steps, first handlers (#3319, Path and Polygon ...), then Snapping (and docs Layers.Vector ...), so two pulls.


erilem wrote
On Tuesday, March 6, 2012, Xavier Mamano (jorix) <[hidden email]>
wrote:
> Hi,
>
> For other reasons (http://trac.osgeo.org/openlayers/ticket/3319) I was
> looking at the third parameter ("drawing") on "modify" callback.
>
> And I thought ... "point" callback ("point" only occurs when drawing)
could
> receive a "drawing" parameter and for the first point would be false. So
> this would be the first point.
>
> What opinion about it?

I think we should add a sketchcreated event to the layer. This event will
be triggered by the DrawFeature's create callback. The sketchstarted event
would now be triggered by a point callback when this is the point point
being added. This would require changing the Snapping control a bit, to
make it listen to sketchcreated instead of sketchstarted. How does that
sound?

--
Eric Lemoine

Camptocamp France SAS
Savoie Technolac, BP 352
73377 Le Bourget du Lac, Cedex

Tel : 00 33 4 79 44 44 96
Mail : [hidden email]
http://www.camptocamp.com

_______________________________________________
Dev mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/openlayers-dev
Reply | Threaded
Open this post in threaded view
|

Re: 2.11 SketchStarted

rgreenwood
In reply to this post by fell_runner
fell_runner wrote
Ok that does work.

But it still seems [to me] a [very] non-intuitive way of catching the users first drawing point on a line.

Thanks for your help.
I'm with fell_runner on this. I had been relying on the sketchstarted event to catch the first drawn point of an object until the 2.11 change in behavior. I can see the need to detect that the user is going to drawn an object, but I think a new event such as beforesketchstarted might have been a more graceful way of handling it.

Best regards,
Rich
Reply | Threaded
Open this post in threaded view
|

Re: 2.11 SketchStarted

Xavier Mamano (jorix)
Hi,

Of course!, but there is some work. And so I know it is difficult to enter 2.12.

(I'll work on it at intervals these days)

Xavier

rgreenwood wrote
fell_runner wrote
Ok that does work.

But it still seems [to me] a [very] non-intuitive way of catching the users first drawing point on a line.

Thanks for your help.
I'm with fell_runner on this. I had been relying on the sketchstarted event to catch the first drawn point of an object until the 2.11 change in behavior. I can see the need to detect that the user is going to drawn an object, but I think a new event such as beforesketchstarted might have been a more graceful way of handling it.

Best regards,
Rich
Reply | Threaded
Open this post in threaded view
|

Re: 2.11 SketchStarted

Xavier Mamano (jorix)
In reply to this post by rgreenwood
Hi Rich,

I did not read carefully enough the last part of your message. About "beforesketchstarted" I think it's better to be called "sketchcreated". "beforexxxx" usually is associated with the option to cancel by return false.

From 2.11 sketch is usually created before starting, and is a problem not knowing when it starts (first point). In this we agree.

Best regards,

Xavier

rgreenwood wrote
fell_runner wrote
Ok that does work.

But it still seems [to me] a [very] non-intuitive way of catching the users first drawing point on a line.

Thanks for your help.
I'm with fell_runner on this. I had been relying on the sketchstarted event to catch the first drawn point of an object until the 2.11 change in behavior. I can see the need to detect that the user is going to drawn an object, but I think a new event such as beforesketchstarted might have been a more graceful way of handling it.

Best regards,
Rich
Reply | Threaded
Open this post in threaded view
|

Re: 2.11 SketchStarted

rgreenwood
Xavier,

Good point. That makes sense.

Thanks,
Rich



On Thu, Mar 8, 2012 at 12:37 PM, Xavier Mamano (jorix) [via OSGeo.org]
<[hidden email]> wrote:

> Hi Rich,
>
> I did not read carefully enough the last part of your message. About
> "beforesketchstarted" I think it's better to be called "sketchcreated".
> "beforexxxx" usually is associated with the option to cancel by return
> false.
>
> From 2.11 sketch is usually created before starting, and is a problem not
> knowing when it starts (first point). In this we agree.
>
> Best regards,
>
> Xavier
>
> rgreenwood wrote
>
> fell_runner wrote
> Ok that does work.
>
> But it still seems [to me] a [very] non-intuitive way of catching the users
> first drawing point on a line.
>
> Thanks for your help.
>
> I'm with fell_runner on this. I had been relying on the sketchstarted event
> to catch the first drawn point of an object until the 2.11 change in
> behavior. I can see the need to detect that the user is going to drawn an
> object, but I think a new event such as beforesketchstarted might have been
> a more graceful way of handling it.
>
> Best regards,
> Rich
>
>
>
> ________________________________
> If you reply to this email, your message will be added to the discussion
> below:
> http://osgeo-org.1560.n6.nabble.com/2-11-SketchStarted-tp4550864p4559721.html
> To unsubscribe from 2.11 SketchStarted, click here.
> NAML



--
Richard Greenwood
[hidden email]
www.greenwoodmap.com