getsmap / smap-responsive

A JavaScript framework for simple creation of web maps with responsive design supporting a range of different browsers and devices
GNU General Public License v3.0
14 stars 12 forks source link

When a user draw a line it doesn’t show the length label (sometimes). #214

Closed mohammadamin46bd closed 8 years ago

mohammadamin46bd commented 8 years ago

There is a problem with draw line functionality. When a user draw a line it doesn’t show the length label for some line segment. It happens sometimes. It happens when a uses drwa a line too fast or click the map too fast (tested that problem for those cases). Attached an image showing the problem.

drawlinefirstlinetextproblem

johanlahti commented 8 years ago

I am now binding to ”mousedown” instead of ”click” to ensure that the label can finish rendering before the next node is interrupting (cancelling the rendering of previous node’s label).

Could you see if this solves the issue for you too @mohammadamin46bd (after getting the latest code)

mohammadamin46bd commented 8 years ago

Thanks a lot. It solves that problem but seems to be an another problem for that change. It also happens when a user draws a line too fast. Now it can't draw line when a user draws too fast but added the length label there. I have added an image for more description. drawlineproblem_hitondraw_problem

johanlahti commented 8 years ago

Yes, that was a stupid quick fix I can see now :smile: mousedown will be triggered as soon as the user drags the map, or clicks, since both will trigger mousedown… I will try to find a smarter way. Thanks.

johanlahti commented 8 years ago

I think the last commit solves it. The problem is that the Leaflet.draw library doesn't trigger any event when a new vertex is added. Therefore, I had to capture this using map "click" or "mousedown". The problem with these two events is that they don't guarantee that a vertex has actually been added. So I had to modify the Leaflet.draw library with an "init-hook" (See below of the MeasureDraw class) so that an event is triggered when a vertex is added (or modified).

Please try again @mohammadamin46bd

mohammadamin46bd commented 8 years ago

This works great now and thanks a lot. (Excellent!)

johanlahti commented 8 years ago

Happy to hear that :+1: I'm closing the issue.