This is a migrated thread and some comments may be shown as answers.

OnShapeClick is getting called on drag

8 Answers 64 Views
Map
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
Iron
Iron
Veteran
David asked on 24 Aug 2017, 02:51 PM

When map is getting dragged, OnShapeClick is getting called

Is there a way to eliminate this behavior?

8 Answers, 1 is accepted

Sort by
0
Vessy
Telerik team
answered on 28 Aug 2017, 03:54 PM
Hi David,

I tested the described scenario but only the OnPan event is triggered at my end when the map is dragged. I am testing the control's behavior in the following demo - are you able to replicate the problem in it?
http://demos.telerik.com/aspnet-ajax/map/examples/client-side-api/defaultcs.aspx

Regards,
Vessy
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
David
Top achievements
Rank 1
Iron
Iron
Veteran
answered on 28 Aug 2017, 04:00 PM

Hi Vessy,

  Your example uses OnClick, I on another hand making use of OnShapeClick event

0
Vessy
Telerik team
answered on 31 Aug 2017, 04:19 PM
Hi David,

Thank you for the clarification. I am afraid that I am not able to replicate the problem with OnShapeClick event as well. Can you share the  RadMap configuration you are using?

Can you also let us know the exact control version used in your application, is it the latest one (2017.2.711)? Are you facing the same problem in all browsers?

Regards,
Vessy
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
David
Top achievements
Rank 1
Iron
Iron
Veteran
answered on 05 Sep 2017, 01:06 PM

Will do.

I will open support ticket just to keep it isolated

Thank you

0
Vessy
Telerik team
answered on 05 Sep 2017, 02:05 PM
Hi,

Sure, David, we will expect your support ticket on the matter in order to continue the investigation of this case. Once we found the problem, you can feel free to update this thread with the solution, so it will be visible to the other forum members.

Regards,
Vessy
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Rumen
Telerik team
answered on 06 Sep 2017, 11:30 AM
Hi,

The filled shape and the canvas layer are two different layers with their own events. When you click on the filled shape to drag the map, the click event of the shape is fired because the map does not know whether the user intends to click the shape or pan the map. If we prevent the OnShapeClick event, this is going to bean unwanted breaking change.

What you can do in your scenario is to use the OnPan (fired while the map viewport is being moved) and OnPanEnd (fires after the map viewport has been moved) client events to check whether the map is being moved and if it is not to allow the OnShapeClick event, otherwise to cancel it.

Since the OnShapeClick is fired after OnPan execution, you can:
  • Create a global variable (flag) in which you store the coordinate of the map center, or of a shape or another position identifier
  • Check the coordinates in the OnPan event and if they are different from the ones stored in the flag variable cancel the OnShapeClick event (with return false). If the coordinates of the position identifier are the not changed (the map is not moved) then do not alter the execution of the OnShapeClick event and show the dialog.

Best regards,
Rumen
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
David
Top achievements
Rank 1
Iron
Iron
Veteran
answered on 08 Sep 2017, 06:03 PM

Hi Rumen,

Your suggestion helped to seemingly solve it.

In case it will help somebody here it is:

<asp:HiddenField ID="hdnWasPanned" value="false" runat="server" />

function OnPan(eventArgs) {
                $('#<%= hdnWasPanned.ClientID %>').val('true');
            }

and in the beginning of shapeClick code:           

                    if ($('#<%= hdnWasPanned.ClientID %>').val() == 'true') {
                        $('#<%= hdnWasPanned.ClientID %>').val('false');
                        return false;
                    }

 

Thank you

 

0
David
Top achievements
Rank 1
Iron
Iron
Veteran
answered on 06 Jul 2018, 02:44 PM

In case anybody interested, previous solution occasionally had some issues. So, to improve on it i implemented something that so far seems reliable.

 function shapeClick(e) {

           var dtPan = e.sender._panEndTS;

           if ((Date.now() - dtPan) < 1000) {
               return false;
           }     

          .....

Tags
Map
Asked by
David
Top achievements
Rank 1
Iron
Iron
Veteran
Answers by
Vessy
Telerik team
David
Top achievements
Rank 1
Iron
Iron
Veteran
Rumen
Telerik team
Share this question
or