Right Click / Context Popup does not appear to be working / accessible from with OpenLayers map component

I'd like to present a context menu upon right click within a map. I have tried to use onContextPopop, PopupMenu etc. But I am only presented a context menu from Edge which provides options to save the image etc. I have tried to find switches within Map/OpenLayers options and also investigated if I can implement the behaviour by using onMapClick/OnMarkerClick and detect if the right mouse button was used, but I fail in obtaining the event data which would tell me which mouse button was used.

Is there something I am missing? THanks for the support!

Hi Pieter,
thanks! For others being potentially interested in some point in time: Here's my slightly changed code for the custom event in VCL, with which I got it to work.

procedure TMainForm.TMSFNCOpenLayers1CustomEvent(Sender: TObject;
AEventData: TTMSFNCMapsEventData);
  s: string;
  e: TTMSFNCMapsEventData;
  p: TPoint;
  if AEventData.EventName = 'ContextMenuEvent' then
    e := TTMSFNCMapsEventData.create;
      e.JSON := AEventData.CustomData;
      p := TMSFNCOpenLayers1.ClientToScreen(TPoint.create(trunc(e.X),
      PopupMenu1.Popup(p.X, p.Y);

@Pieter_Scheldeman : A further question in this direction - i'd like the context menu to actually only react on markers. Is there also a way to achieve this? I don't appear to be able to hook into the OnMarkerClick event.

Have you tried using the OnMarkerRightClick event in combination with TMSFNCMaps?

Please note that this event not yet available in the TMSFNCOpenLayers component. It will become available with the next TMS FNC Maps release.

Hi Bart,
thanks! I am afraid I need to use OpenLayers because I need to use a rather new feature of yours, which is only implemented in openlayers as I understand: support for WMS layers.
Also I am not sure If that would work anyway respectively I don't understand why. I don't get the connection between the code provided in MapInitialized and the "onCustumEvent" Event. Is it a general mechanism that code I provide via MapInitialized is hooked up with "onCustomEvent"? At least it didn't work when linking the code from custom event to events like "onMarkerClick". My assumption would be that I would have to do something about the javascript code to have the event handler react to right clicks on markers to invoke context menus...? But I am not sure.

Hi Simon,

After further investigation we noticed it won't be possible to use the OnMarkerRightClick event in this case due to technical limitations.

We are currently working on an alternative solution using custom code in TTMSFNCOpenLayers and we'll report back as soon as possible.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.