8 Answers, 1 is accepted
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
Hi Vessy,
Your example uses OnClick, I on another hand making use of OnShapeClick event
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
Will do.
I will open support ticket just to keep it isolated
Thank you
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
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
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
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;
}
.....